Use this Bragg’s law calculator to solve for d-spacing, wavelength, angle, or diffraction order n, with a clear theta vs 2-theta (XRD) toggle. It also checks if your inputs can produce a real diffraction angle and shows both theta and 2-theta in the results.
Advanced options
How to use our Bragg's Law Calculator
- Choose Solve for to pick what you want to calculate (d, wavelength, angle, or order n).
- Set Angle input type to match your data: 2-theta (XRD) if you are reading a powder XRD peak position, or theta if you already have the Bragg angle.
- Enter Angle (degrees) (the number must match your chosen angle input type).
- Enter Wavelength and d-spacing for the fields that are not being solved for.
- Enter Order n as a positive integer (usually 1) unless you are solving for n.
- Open Advanced options if you need to change wavelength units, d-spacing units, use an X-ray preset (like Cu Kalpha), or switch angle outputs to radians.
- Click Calculate.
- Read Theta and 2-theta together so you can copy the correct angle for your homework or XRD plot.
- Check the Feasibility check: if it says there is no real solution, adjust n, wavelength, d, or angle until the sine/arcsine step becomes possible.
Definitions
Bragg's law: A diffraction rule written as n*lambda = 2*d*sin(theta). It links wavelength, plane spacing, and angle for constructive interference in crystals. [1]
n (order): A positive integer (1, 2, 3, ...) that counts the diffraction order. In basic XRD, n is usually 1. [2]
lambda (wavelength): The X-ray wavelength. Lab XRD often uses a fixed source wavelength (for example, Cu Kalpha). [1]
d (d-spacing): The distance between parallel crystal planes that cause the reflection. [2]
theta (Bragg angle): The angle used inside the sine in Bragg's law. In many XRD plots the x-axis is 2-theta, so theta is half of the reported angle. [2]
2-theta: Twice the Bragg angle. Powder XRD instruments commonly report peaks at 2-theta. [2]
Feasibility (real solution): A solution is real only if the arcsin input is between -1 and 1 (with positive inputs, that means between 0 and 1). If it is bigger than 1, no real diffraction angle exists for those inputs. [1]
Methodology
What the calculator solves
This calculator rearranges Bragg's law and keeps the angle convention clear: the trig functions always use the Bragg angle theta, even if you typed an XRD-style 2-theta value. [2]
Angle handling (theta vs 2-theta)
if angle input type is 2-theta: theta = (angle_deg) / 2
if angle input type is theta: theta = angle_deg
two_theta = 2 * theta
If you choose radians output, the calculator converts degrees to radians only for display and for trig math, using pi/180. It does not mix degree trig with radian trig.
Core equation
n * lambda = 2 * d * sin(theta)
This is the standard Bragg condition for constructive interference in a crystal. [1]
Rearranged forms (based on what you solve for)
d = (n * lambda) / (2 * sin(theta))
lambda = (2 * d * sin(theta)) / n
theta = arcsin((n * lambda) / (2 * d))
n_raw = (2 * d * sin(theta)) / lambda
Unit conversions (wavelength and d-spacing)
The calculator converts wavelength and d-spacing to meters internally so you can use different units for each input (for example, lambda in nm and d in Angstrom) and still get consistent results.
meters = value * unit_scale_to_meters
unit_scale_to_meters(A) = 1e-10; unit_scale_to_meters(nm) = 1e-9; unit_scale_to_meters(pm) = 1e-12
Feasibility check (no real-solution cases)
When solving for theta, the calculator checks the arcsin input value x = (n*lambda)/(2*d). With positive inputs, a real solution needs 0 <= x <= 1. If x > 1, it reports "No real solution" and suggests increasing d, decreasing n, or decreasing lambda. [2]
x = (n * lambda) / (2 * d)
real angle possible only if -1 <= x <= 1
When solving for d, the calculator blocks division by zero when sin(theta) = 0 (for example, theta = 0 degrees). In that case d is shown as N/A because no finite plane spacing can satisfy the equation.
Order n output rule
When solving for n, the computed n_raw is only reported as an integer if it is extremely close to an integer. Otherwise the output is N/A, because diffraction order is defined as an integer in Bragg's law. [1]