Diffraction Grating Calculator

Work out the angle of each diffracted order from a diffraction grating, and where that order lands on a screen.

Physics and EnergyUpdated 2026-10-214 min read
Diffraction Grating Calculator
Switches the groove density and the screen distance. Wavelength stays in nanometres, the unit used for light in both systems.
Order 1 is the first bright line away from the straight ahead direction.
Diffraction angle
...
Position of the order on the screen...
Groove spacing...
Highest visible order...

What it does

A diffraction grating is a large family of evenly spaced parallel slits, and it does something a single slit cannot: it splits light into sharp, separate colours. OpenStax describes it plainly, noting that a grating produces an interference pattern much like a double slit but sharper, with narrower and brighter bright regions, which is exactly why spectroscopes use gratings rather than slits. The same section points out that a compact disc is a grating, with the rainbow you see on the wall coming from the track spacing on the disc.

The physics is one line. Light passing through neighbouring grooves travels different distances to reach the same point, and when that extra distance is a whole number of wavelengths the waves arrive in step and reinforce each other. College Physics gives the condition as d sin theta equals m lambda, where d is the distance between grooves, theta is the angle from the straight ahead direction and m is the order of the maximum. Each order therefore sits at a different angle, and each colour in the light lands at its own place within that order.

The numbers that matter in practice are the groove density and the wavelength. A grating sold for spectroscopy is often labelled with its density in lines per millimetre, and the density sets the spacing d, which is simply the reciprocal of that number. The wavelength of the light is what decides whether a given order exists at all, because m lambda can never be larger than d, since that would need a sine above one.

This page takes the density, the wavelength and the order you care about, and gives back the angle, the position of that order on a screen at any distance, the groove spacing and the highest order the grating can show. It works in metric or imperial units for the density and the screen distance. The wavelength stays in nanometres, because that is the unit used for light everywhere, from laser safety labels to astronomical spectroscopy.

Real gratings have more going on than the ideal equation. Not every groove is illuminated equally, the coating is usually blazed so that one order is brighter than the others, and the resolution depends on how many grooves the light actually crosses. The numbers here are the geometry, which is the starting point for any of that.

How to use

  1. Pick metric or imperial units for the groove density and the screen distance.
  2. Enter the groove density of the grating, in lines per millimetre or lines per inch. The label on a grating usually gives it.
  3. Enter the wavelength of the light in nanometres, for example 633 for a helium neon laser or 532 for a green laser.
  4. Choose the order you want. Order 1 is the first bright line away from the centre.
  5. Enter how far the screen sits from the grating to get the position of that order on the screen.
  6. Read the highest visible order as well, since it tells you which orders the grating can produce at that wavelength.

Formula

d sin(theta) = m lambda, with d the groove spacing, lambda the wavelength and m the order. Groove spacing d = 1 / N for N grooves per millimetre. The angle is theta = arcsin(m lambda / d) and the position of the order on a screen at distance L is y = L x tan(theta).
d
Distance between neighbouring grooves, the reciprocal of the groove density.
lambda
Wavelength of the light in nanometres.
m
Order of the maximum, 1 for the first bright line.
theta
Angle between the diffracted beam and the straight ahead direction.
L
Distance from the grating to the screen.

The equation only holds for light hitting the grating at a right angle, which is the normal arrangement. Because a sine cannot exceed one, the highest order is the whole number below d divided by lambda, and any order above that does not exist. The screen position uses a tangent rather than a sine because the beam travels a slant distance to reach the screen, while the angle is measured from the grating.

Worked example

Example: a 600 line per mm grating with a 633 nm laser

Defaults: metric units, 600 lines per millimetre, 633 nm of light, first order, and a screen 1 m away.

  1. Groove spacing: d = 1 / 600 mm = 0.001667 mm = 1666.7 nm.
  2. Condition for the first order: sin(theta) = m lambda / d = 1 x 633 / 1666.7 = 0.3798.
  3. Angle: theta = arcsin(0.3798) = 22.32 degrees.
  4. Position on a screen 1 m away: y = L x tan(theta) = 1 x tan(22.32 degrees) = 0.4106 m = 410.6 mm.
  5. Highest order: the whole number below d / lambda = 1666.7 / 633 = 2.63, so order 2 is the last one this grating can show.
  6. The tool shows 22.32 degrees, 410.6 mm, a groove spacing of 1.667 µm and a highest visible order of 2.

Reference table

Angles of the first and second orders for a 600 line per mm grating, with the first order position on a screen 1 m away
WavelengthFirst order angleSecond order angleFirst order at 1 m
405 nm14.06 degrees29.08 degrees250.5 mm
450 nm15.66 degrees32.68 degrees280.4 mm
532 nm18.61 degrees39.67 degrees336.8 mm
633 nm22.32 degrees49.43 degrees410.6 mm
1064 nm39.67 degreesnot possible829.4 mm

Limits

  • The geometry assumes the light hits the grating at a right angle, which is how a simple spectrometer is set up.
  • Grating efficiency and blaze angle are ignored, so the page gives angles but not how bright each order will be.
  • The screen position uses small angle geometry only through the tangent, so it stays accurate for wide angles but does not model a curved detector.
  • Finite width of the light source and the number of grooves actually illuminated, which set the resolution, are not part of the calculation.

Common mistakes

  • Mixing up the groove density with the groove spacing. A grating with 600 lines per mm has a spacing of 1.667 micrometres, not 600.
  • Forgetting that the highest order is limited. For 633 nm on a 600 line per mm grating, the third order cannot exist.
  • Using a sine where a tangent is needed. The angle comes from the sine, but the distance across the screen is L x tan(theta).
  • Working in micrometres while the wavelength is in nanometres. Convert before you divide, or the answer is off by a factor of 1000.
  • Assuming every order is equally bright. Most gratings are blazed so that one order carries most of the light.

Try it yourself

Quick checks. Answers sit tucked under each question.

At what angle does 633 nm light leave a grating with 600 lines per millimetre in first order?

22.32 degrees. The groove spacing is 1666.7 nm, so sin(theta) = 633 / 1666.7 = 0.3798 and theta = 22.32 degrees.

Where does that first order land on a screen 1 m from the grating?

410.6 mm from the centre, because y = L x tan(theta) = 1 x tan(22.32 degrees) = 0.4106 m.

What is the highest order a 600 line per mm grating can show at 532 nm?

Order 3. The spacing fits 1666.7 / 532 = 3.13 wavelengths, so the whole number below that is 3.

Questions

What does a diffraction grating do?

It splits light into separate colours by sending each wavelength into its own direction. The bright lines of a spectrum come from the orders of the grating.

What is the groove spacing of a grating?

The distance between neighbouring grooves, which is the reciprocal of the groove density. A grating with 600 lines per millimetre has a spacing of 1.667 micrometres.

How many orders can a grating produce?

The highest order is the whole number below the groove spacing divided by the wavelength. A 600 line per mm grating at 633 nm stops at order 2.

Why does a compact disc show a rainbow?

The data track on the disc is a reflection grating with a very fine, even spacing, so the grooves split white light into its colours at the same angle the geometry predicts.

Does the light have to hit the grating at a right angle?

For the equation on this page, yes. With light arriving at an angle the grating equation picks up an extra term, which is how blazed gratings are designed to send more light into one order.

What sets the resolution of a grating?

The number of grooves the light crosses and the total width of the illuminated area. A wider beam across more grooves separates close wavelengths more clearly.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.