A depth of field (DoF) calculator for photographers that goes beyond a simple lookup table. Enter your sensor format, focal length, f-number and subject distance, and the tool returns the near limit, far limit, total depth of field, in-front / behind split and the hyperfocal distance — all in metres or feet/inches. It also solves in reverse: give it a target DoF and it tells you which aperture, subject distance or focal length achieves it.
How the maths works
Every depth-of-field calculation starts with the hyperfocal distance H, the focus distance at which depth of field extends from H/2 to infinity:
H = f² ÷ (N · c) + f
where f is focal length in millimetres, N is the f-number and c is the circle of confusion — the sensor-format-specific tolerance for blur. Once H is known, the near and far limits for a subject at distance s are:
Near = s(H − f) ÷ (H + s − 2f)
Far = s(H − f) ÷ (H − s)
When s ≥ H the denominator of the far formula becomes zero or negative, meaning the far limit is infinite. Total depth of field is simply Far − Near. The diagram in the tool maps all four distances on a single log-scale axis so the relative proportions are immediately visible.
Worked example — 50 mm portrait lens
Suppose you are shooting a full-frame sensor camera (c = 0.029 mm) with a 50 mm lens at f/2.8, subject at 3 m:
- Hyperfocal: H = 50² ÷ (2.8 × 0.029) + 50 ≈ 30,829 mm (30.8 m)
- Near limit: 3000 × (30829 − 50) ÷ (30829 + 3000 − 100) ≈ 2,743 mm (2.74 m)
- Far limit: 3000 × (30829 − 50) ÷ (30829 − 3000) ≈ 3,321 mm (3.32 m)
- Total DoF: 3321 − 2743 = 578 mm (about 58 cm)
- In front: 3000 − 2743 = 257 mm · Behind: 3321 − 3000 = 321 mm · ratio ≈ 1.25× more behind
Stop down to f/8 and the DoF grows to roughly 1.8 m, enough to keep both eyes and ears sharp on a three-quarter headshot. Open up to f/1.4 and it collapses to about 16 cm, isolating a single eye.
| Focal length | Aperture | Distance | Total DoF |
|---|---|---|---|
| 50 mm | f/1.8 | 3 m | ~0.25 m |
| 50 mm | f/2.8 | 3 m | ~0.58 m |
| 50 mm | f/5.6 | 3 m | ~1.18 m |
| 85 mm | f/1.8 | 5 m | ~0.29 m |
| 24 mm | f/8 | 3 m | ~3.2 m |
Landscape use-case — hyperfocal focusing
Set a 24 mm lens at f/8 on full frame (H ≈ 2.5 m). Focus at 2.5 m and everything from 1.25 m to infinity is sharp — you can include a rock in the foreground and a mountain on the horizon in the same frame without focus-stacking. The aperture comparison table in the tool shows you every f-stop so you can trade sharpness for diffraction consciously.
Reverse-solve modes
The calculator supports three solve-for directions, each using iterative bisection on the forward formula:
- Find aperture — given a desired DoF, the current focal length and subject distance, find the exact f-number (and nearest standard stop).
- Find distance — given a desired DoF, the current focal length and aperture, find the subject distance that produces it.
- Find focal length — given a desired DoF, a target aperture and subject distance, find the focal length that achieves it.
These modes are particularly useful when planning a shot before the photoshoot: you can lock in a desired subject-to-background separation and the tool tells you exactly what to put on the lens.