---
slug: diffraction-grating-calculator
title: "Diffraction Grating Calculator"
category: scientific
updated: 2026-11-18
canonical: https://calcseed.com/c/scientific/diffraction-grating-calculator/
html: /c/scientific/diffraction-grating-calculator/
---

# Diffraction Grating Calculator

Calculate the diffraction angle of a maximum for a grating from the line spacing, wavelength and order.

## Quick answer

**Quick answer:** with the default inputs (600 1/mm, 500 nm, 1), the diffraction angle is **17.46**. Change any input to update the result.

## Default calculation

Values computed by this calculator at exactly the default inputs listed below.

### Inputs (defaults)

| Input | Value | Unit |
| --- | --- | --- |
| Lines per mm | 600 | 1/mm |
| Wavelength | 500 | nm |
| Order | 1 |  |

### Outputs at these defaults

| Output | Value | Unit |
| --- | --- | --- |
| Diffraction angle | 17.4576 |  |

## Formula

```text
d sin&theta; = n&lambda;
```

## Inputs

| Variable | Type | Unit | Default |
| --- | --- | --- | --- |
| Lines per mm | number | 1/mm | 600 |
| Wavelength | number | nm | 500 |
| Order | number |  | 1 |

## Outputs

| Result | Format |
| --- | --- |
| Diffraction angle | primary |
| Diffraction angle | number |

## How it works

### What this calculator returns

The output is the diffraction angle &theta; in degrees for one chosen order n. At the defaults — a grating of 600 lines/mm, light at 500 nm and first order — the angle is 17.46&deg;. If n&lambda; is larger than the line spacing, no maximum exists at that order and the result is undefined.

### Getting the line spacing right first

The equation works in metres, but gratings are sold in lines per millimetre. Convert before you start: d = 1 ÷ (lines per mm × 1000). A 600 line/mm grating has 600,000 lines per metre, so d = 1 ÷ 600,000 = 1.6667 × 10^−6 m, or 1666.7 nm.

That spacing is only about three times the wavelength of green light, which is why such a grating spreads visible light across wide angles. A coarser 100 line/mm grating has d = 10,000 nm and produces maxima packed close to the straight-through direction.

A useful sanity check before you compute anything: d should always be a few hundred to a few thousand nanometres for visible-light work. If your spacing comes out below 300 nm, no visible order can exist; if it comes out above 20,000 nm, the maxima will be almost impossible to separate by eye.

### Worked example at the defaults

With N = 600 lines/mm, &lambda; = 500 nm = 500 × 10^−9 m and n = 1: sin&theta; = n&lambda; ÷ d = (1 × 500 × 10^−9) ÷ (1.6667 × 10^−6) = 0.300. Then &theta; = arcsin(0.300) = 17.46&deg;, which is what the calculator prints.

The second order doubles the numerator, so sin&theta; = 0.600 and &theta; = 36.87&deg;. The third gives 0.900 and 64.16&deg;. The fourth would need sin&theta; = 1.200, which no angle can satisfy, so the pattern stops at three orders on each side.

### Orders for 600 lines/mm at 500 nm

| Order n | sin&theta; | Angle &theta; | Notes |
| --- | --- | --- | --- |
| 0 | 0 | 0&deg; | Straight-through beam |
| 1 | 0.300 | 17.46&deg; | Default result |
| 2 | 0.600 | 36.87&deg; | Weaker, more spread out |
| 3 | 0.900 | 64.16&deg; | Grazing, low intensity |
| 4 | 1.200 | none | Physically impossible |

#### Why higher orders vanish

The maximum order is the largest integer below d ÷ &lambda;. Here 1666.7 ÷ 500 = 3.33, so orders 0 to 3 exist and order 4 does not. Push the wavelength to 600 nm and the ratio drops to 2.78, leaving only two orders; drop to 400 nm and 4.17 allows four.

### How far apart the colours land

| Wavelength | sin&theta; (n = 1) | Angle |
| --- | --- | --- |
| 400 nm (violet) | 0.240 | 13.89&deg; |
| 500 nm (green) | 0.300 | 17.46&deg; |
| 600 nm (orange) | 0.360 | 21.10&deg; |
| 700 nm (red) | 0.420 | 24.83&deg; |

The red end lands about 11&deg; further out than the violet end in first order, which is the visible rainbow a grating throws on a wall. In second order the same 300 nm span stretches across roughly 28&deg;, and third order spreads it wider still but at much lower brightness.

#### Angular dispersion

The rate of change near the first-order maximum is d&theta;/d&lambda; = n ÷ (d cos&theta;). With cos(17.46&deg;) = 0.954, that is 1 ÷ (1.6667 × 10^−6 × 0.954) = 6.3 × 10^5 rad/m, or about 0.036&deg; per nm. A 100 nm band therefore spreads over 3.6&deg;, matching the 13.89&deg; to 17.46&deg; step in the table.

### What moves the angle

- Wavelength: longer light bends further, red further than blue at every order.
- Line density: doubling to 1200 lines/mm halves d to 833.3 nm and pushes first order from 17.46&deg; to 36.87&deg;.
- Order: each step up multiplies sin&theta; by the same factor, so order 2 sits near 36.87&deg; rather than double 17.46&deg;.
- Grating constant: a coarse 300 line/mm grating halves the angle to 8.63&deg; for the same 500 nm light.
- Index of the surrounding medium: immersing the grating in liquid shortens the effective wavelength and shrinks every angle.

Check the 300 line/mm case: d = 3333.3 nm, sin&theta; = 500 ÷ 3333.3 = 0.150, and arcsin(0.150) = 8.63&deg;. Halving the line density halves sin&theta;, but because arcsin is nonlinear the angle does not simply halve from 17.46&deg;.

### Mistakes that break the result

The first is unit mixing. Entering d in nanometres while &lambda; is in metres gives an error of 10^9. Keep both in metres, or both in nanometres, and the ratio is safe because it is dimensionless.

The second is confusing lines per mm with lines per metre. A 600 line/mm grating is 600,000 lines/m, not 600. Using 600 directly makes d 1000 times too large and collapses every angle toward zero.

The third is expecting a result at high order for coarse light. If the calculator returns nothing, the order simply does not exist for that spacing and wavelength; reduce n or use a finer grating rather than adjusting the wavelength to force a number.

### Resolving power

A grating separates two close wavelengths by R = nN, where N is the total number of illuminated lines. A 25 mm wide patch of a 600 line/mm grating has 15,000 lines, so first order resolves R = 15,000 and second order 30,000. At 500 nm that first-order figure means a smallest resolvable gap of 500 ÷ 15,000 = 0.033 nm.

- 600 lines/mm gives d = 1666.7 nm, about 3.3 wavelengths of 500 nm light.
- 1200 lines/mm halves d to 833.3 nm and leaves only one visible order at 500 nm.
- 300 lines/mm doubles d to 3333.3 nm and moves first order in to 8.63&deg;.

## FAQ

### What is the diffraction grating equation?

It is d sin&theta; = n&lambda;: spacing times the sine of the angle equals order times wavelength. For d = 1666.7 nm, &lambda; = 500 nm and n = 1, sin&theta; = 0.300 and &theta; = 17.46&deg;.

### How do I find the line spacing d?

Take the reciprocal of the line density in lines per metre. A 600 line/mm grating has 600,000 lines/m, so d = 1 ÷ 600,000 = 1.6667 × 10^−6 m.

### Why does my grating show only three orders?

The highest order is the integer below d ÷ &lambda;. At 1666.7 nm spacing and 500 nm light, 1666.7 ÷ 500 = 3.33, so orders 0 through 3 exist and order 4 cannot.

### Why is red diffracted more than blue?

Angle rises with wavelength. At 600 lines/mm in first order, 400 nm lands at 13.89&deg; and 700 nm at 24.83&deg;, a gap of nearly 11&deg;.

### What happens if I double the lines per mm?

Halving d doubles sin&theta;. Going from 600 to 1200 lines/mm moves 500 nm first order from 17.46&deg; to 36.87&deg;, and cuts the number of visible orders from three to one.

### Can the angle exceed 90 degrees?

No. When n&lambda; ÷ d is greater than 1 there is no real angle, and the calculator returns no maximum. That is a physical cutoff, not a rounding issue.

### What is the angular dispersion?

It is d&theta;/d&lambda; = n ÷ (d cos&theta;). At the defaults that works out to about 0.036&deg; per nm in first order, so a 100 nm band spreads over 3.6&deg;.

### How many lines do I need to resolve two wavelengths?

Use R = nN. To separate 500.00 nm from 500.01 nm you need R = 50,000, which is 50,000 illuminated lines in first order or 25,000 in second.

### Why do gratings create rainbows?

Each wavelength satisfies the equation at a different angle. White light therefore splits, with 400 nm at 13.89&deg; and 700 nm at 24.83&deg; under the default setup.

## Method and sources

Methodology: Physical constants follow CODATA 2022 recommended values, and formulas follow standard physics definitions.

Last updated: 2026-11-18.
- Diffraction grating equation d sin θ = nλ; line spacing d = 1/(lines per metre).
