Bragg’s Law Calculator

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.

Pick what you want to calculate. The calculator will use Bragg’s law: n*lambda = 2*d*sin(theta).
XRD plots usually use 2-theta. Bragg’s law uses theta (half of 2-theta).
Enter theta or 2-theta in degrees based on the setting above. For 2-theta use 0 to 180. For theta use 0 to 90.
Wavelength of the X-rays. A common lab value is Cu Kalpha around 1.5406 A.
Distance between parallel crystal planes (interplanar spacing). You can pick a unit in Advanced options.
Diffraction order. Usually 1. Must be a positive integer.
Advanced options
Units
Sets the unit for the wavelength input and wavelength output.
Sets the unit for the d-spacing input and d-spacing output.
Presets and output
If you pick a preset, it will overwrite the wavelength field using a common approximate value.
Choose degrees (typical for XRD) or radians (common in trig formulas).
Calculating…
Theta (Bragg angle)
–
Use this theta in n*lambda = 2*d*sin(theta).
2-theta (XRD angle)
–
Most powder XRD peak positions are reported as 2-theta.
d-spacing (interplanar spacing)
–
Larger d usually means smaller diffraction angles (for fixed wavelength and order).
Wavelength
–
For typical lab XRD, wavelength is often fixed by the X-ray source.
Order n
–
In Bragg diffraction, n should be a positive integer.
Feasibility check
–
If infeasible, change n, lambda, d, or angle until you get a real solution.
Did we solve your problem today?

How to use our Bragg's Law Calculator

  1. Choose Solve for to pick what you want to calculate (d, wavelength, angle, or order n).
  2. 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.
  3. Enter Angle (degrees) (the number must match your chosen angle input type).
  4. Enter Wavelength and d-spacing for the fields that are not being solved for.
  5. Enter Order n as a positive integer (usually 1) unless you are solving for n.
  6. 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.
  7. Click Calculate.
  8. Read Theta and 2-theta together so you can copy the correct angle for your homework or XRD plot.
  9. 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]


Sources