Diffraction Grating Calculator
Enter your grating line density, wavelength, diffraction order, and angle of incidence to instantly solve for any unknown in the diffraction grating equation. Switch between seven calculation modes to find the diffraction angle, wavelength, line density, grating spacing, maximum order, angular dispersion, or resolving power. The show-your-work panel and multi-order chart update live as you type.
Formula
Worked example
A 600 lines/mm grating illuminated at normal incidence (theta_i = 0) by 550 nm green light: d = 1 / (600 x 1000) = 1.667 micrometers. First-order angle: sin(theta_1) = 1 x 550e-9 / 1.667e-6 = 0.330, so theta_1 = arcsin(0.330) = 19.2 degrees. Angular dispersion = 1 / (1.667e-6 x cos(19.2 deg)) = 633,200 rad/m = 0.0361 deg/nm. A 25 mm wide grating has N_total = 600 x 25 = 15,000 slits and resolving power R = 1 x 15,000 = 15,000.
What is a diffraction grating?
A diffraction grating is an optical component with a periodic array of slits, grooves, or lines ruled onto its surface. When light strikes the grating, each slit acts as a source of secondary waves. These waves interfere constructively only at specific angles determined by the wavelength and the grating spacing, so different wavelengths emerge at different angles. This angular separation of wavelengths is the basis of every optical spectrometer: from the rainbow you see on a CD to the instruments that measure stellar compositions. Transmission gratings let light through the slits; reflection gratings (by far the most common in spectroscopy) diffract light from a mirrored surface ruled with thousands of parallel grooves per millimetre.
The diffraction grating equation
The fundamental relationship is m x lambda = d x (sin(theta_i) + sin(theta_m)), where m is the diffraction order (1, 2, 3...), lambda is the wavelength, d is the spacing between adjacent grooves, theta_i is the angle of incidence measured from the grating normal, and theta_m is the angle of the m-th order diffracted beam. At normal incidence (theta_i = 0) this simplifies to m x lambda = d x sin(theta_m). Grating spacing d is the reciprocal of the line density N: a grating ruled at 600 lines/mm has d = 1/600 mm = 1.667 micrometers. The sign convention for theta_i and theta_m follows whether both beams are on the same side of the normal.
Angular dispersion and resolving power
Angular dispersion (dtheta/dlambda = m / (d x cos(theta_m))) measures how far apart two wavelengths are spread per nanometre of separation. A high line density, a high diffraction order, and a large diffraction angle all increase dispersion. Resolving power R = m x N_total, where N_total is the total number of illuminated slits (line density times illuminated width). R equals the wavelength divided by the minimum wavelength difference the grating can distinguish (lambda / delta_lambda). A 25 mm wide, 1200 lines/mm grating used in second order achieves R = 2 x 30,000 = 60,000, meaning it can separate two sodium D lines only 0.6 nm apart at 589 nm. Maximum diffraction order m_max = floor(d / lambda) when theta_i = 0: above this, the grating equation has no real solution and the order does not exist.
How to use this calculator
Select the quantity you want to solve for from the Solve for menu. The inputs change to match the chosen mode. Enter your grating line density (typically 300 to 1800 lines/mm for visible-light work), the wavelength of interest, the diffraction order, and the angle of incidence (leave at 0 for normal incidence). The result updates instantly and the Show your work panel below the output shows each arithmetic step. The multi-order bars chart shows diffraction angles for orders 1 through 5 at a glance. The angle-vs-wavelength chart shows how the diffraction angle changes across a wavelength range for orders 1, 2, and 3, so you can see at a glance how much the grating disperses light across its working bandwidth.
Common diffraction grating specifications
| Line density (lines/mm) | Grating spacing (micrometers) | 1st-order angle at 550 nm | Typical application |
|---|---|---|---|
| 30 | 33.33 | 0.94 deg | Infrared spectroscopy, echelle gratings |
| 150 | 6.67 | 4.73 deg | Mid-IR monochromators |
| 300 | 3.33 | 9.49 deg | Near-IR spectrometers |
| 600 | 1.67 | 19.2 deg | Visible spectroscopy (standard) |
| 830 | 1.20 | 27.0 deg | CD/DVD laser optics |
| 1200 | 0.83 | 41.3 deg | UV-visible high resolution |
| 1800 | 0.56 | Limit zone | UV spectroscopy |
| 3600 | 0.28 | UV only | Deep UV, requires short wavelength |
Typical line densities and their grating spacings, with representative first-order diffraction angles at 550 nm (normal incidence).
Frequently asked questions
What is the diffraction grating equation?
The grating equation is m x lambda = d x (sin(theta_i) + sin(theta_m)). Here m is the diffraction order (a positive integer), lambda is the wavelength of light, d is the groove spacing (1 divided by the line density), theta_i is the angle at which light hits the grating relative to the grating normal, and theta_m is the angle at which the m-th order emerges. At normal incidence, theta_i is zero and the equation simplifies to m x lambda = d x sin(theta_m).
What does line density (lines/mm) mean?
Line density is the number of parallel grooves or slits per millimetre ruled on the grating surface. A value of 600 lines/mm means there are 600 grooves in every millimetre, giving a groove spacing of 1/600 mm = 1.667 micrometers. Higher line densities produce larger diffraction angles and greater angular dispersion at visible wavelengths, which is useful for separating closely spaced spectral lines.
What is the maximum diffraction order?
The maximum order m_max is the largest integer m for which the grating equation has a physical solution, that is, the absolute value of sin(theta_m) does not exceed 1. For normal incidence, m_max = floor(d / lambda). For a 600 lines/mm grating (d = 1.667 micrometers) at 550 nm, m_max = floor(1667 nm / 550 nm) = floor(3.03) = 3. Orders 1, 2, and 3 exist; order 4 would require sin(theta_4) greater than 1, which is impossible.
How is resolving power defined?
Resolving power R is defined as lambda / delta_lambda, where delta_lambda is the minimum wavelength difference the grating can distinguish. It equals m x N_total, where N_total is the total number of illuminated slits (line density times the illuminated width of the grating). A wider grating or a higher order gives higher resolving power. For example, a 25 mm wide, 1200 lines/mm grating in first order has R = 1 x (1200 x 25) = 30,000, meaning it can resolve two wavelengths 589 nm / 30,000 = 0.02 nm apart.
What is angular dispersion and why does it matter?
Angular dispersion is the rate at which the diffraction angle changes with wavelength: dtheta/dlambda = m / (d x cos(theta_m)), in units of radians per metre (or degrees per nanometre). A high angular dispersion spreads different wavelengths far apart in angle, making it easier to separate them spatially onto a detector or slit. It increases with diffraction order and decreases as cos(theta_m) gets smaller, meaning dispersion rises as you approach grazing angles.
Why do CDs create rainbow patterns?
A CD surface has a spiral track with a pitch of about 1.6 micrometers, which is close to visible wavelengths. This acts like a reflection diffraction grating, diffracting different wavelengths at different angles. When white light falls on the disc, you see the spectrum spread across the surface because each colour (wavelength) emerges at a different angle, producing the rainbow effect. The same principle is used in scientific spectrometers, just with far finer, more precisely ruled gratings.
What is the difference between a transmission grating and a reflection grating?
A transmission grating diffracts light as it passes through the ruled surface, similar to how a prism refracts light. A reflection grating diffracts light that reflects off a mirrored, grooved surface. Reflection gratings are more common in instruments because they can be used across a wider wavelength range, do not absorb UV light the way glass does, and can be blazed (shaped grooves angled to concentrate light into a chosen diffraction order) for higher efficiency.