Depth of field calculator

Enter focal length, f-number, focus distance, and sensor format (which sets the circle of confusion). The tool returns near limit, far limit, total depth of field, and hyperfocal distance. This is not a focus-stacking planner and does not account for lens breathing or pupil magnification.

Lens and subject

Formulas

H = f^2 / (N * c)

Dn = H * D / (H + D)

Df = H * D / (H - D) (for D < H; infinite when D >= H)

DoF = Df - Dn

Where f = focal length in metres; N = f-number; c = circle of confusion in metres; D = focus distance in metres; H = hyperfocal distance in metres; Dn = near limit of acceptable sharpness in metres; Df = far limit of acceptable sharpness in metres; DoF = total depth of field in metres.

All distances converted to metres internally; inputs and outputs in mm (focal, coc) or metres (focus_distance, outputs).

When focus distance is at or beyond hyperfocal, far limit and total DoF are infinite; the tool refuses and reports "Focus distance is at or beyond hyperfocal distance; far limit is infinite."

Checked examples

50 mm lens at f/2.8 focused at 3 m on full frame gives hyperfocal 29.76 m, near limit 2.73 m, far limit 3.34 m, total DoF 0.61 m.

24 mm lens at f/11 focused at 1.5 m on APS-C gives hyperfocal 2.62 m, near limit 0.95 m, far limit 3.51 m, total DoF 2.56 m.

85 mm lens at f/1.4 focused at 1.5 m on full frame gives hyperfocal 172.02 m, near limit 1.49 m, far limit 1.51 m, total DoF 0.026 m.

Limits

Thin-lens approximation, paraxial rays, and a single circle-of-confusion criterion. Sensor format chooses a standard CoC; you can override by selecting Custom in future versions. Focus distance must be positive. Focal length and f-number must be positive. When focus distance >= hyperfocal distance, far limit and total DoF are infinite and the tool refuses. Not for: focus-stacking step calculators; macro photography with pupil magnification corrections; lens breathing or focus-shift compensation.

Wikipedia — Hyperfocal distance and Wikipedia — Depth of field.