HomePhotography & Optics › Depth of Field Calculator

Depth of Field Calculator

Computes the near and far limits of acceptable sharpness, the total depth of field and the hyperfocal distance from focal length, f-number, focus distance and the sensor's circle of confusion, using the standard thin-lens depth-of-field equations.

When to use

You need to know how much of a scene is acceptably sharp for given camera settings, or how far sharpness extends in front of and behind the focused subject.

Do not use when: You only need the focus distance that maximises depth of field (use hyperfocal-distance), or you shoot macro above about 0.2× magnification where lens extension and pupil magnification make the thin-lens equations inaccurate.

Formula

H = f² / (N·c) + f; near = s·(H − f) / (H + s − 2f); far = s·(H − f) / (H − s) when s < H, otherwise infinity (f = focal_length_mm, N = aperture_f, c = coc_mm, s = focus_distance_m × 1000, all in mm)

Thin-lens approximation with a sensor-dependent circle of confusion (diagonal / 1500 convention). Lens makers and apps use slightly different CoC values, so limits can differ by 10–20 %; distances are measured from the sensor plane.

Inputs

ParameterTypeUnitRequiredDescription
focal_length_mmnumbermmyesActual (not equivalent) focal length of the lens in millimetres. Range: ≥ 1, ≤ 5000
aperture_fnumberyesLens f-number, e.g. 2.8 for f/2.8. Range: ≥ 0.5, ≤ 128
focus_distance_mnumbermyesDistance from the camera's sensor plane to the focused subject in metres. Range: > 0, ≤ 100000
sensorenum: full_frame | aps_c | aps_c_canon | micro_four_thirds | one_inch | medium_format_44x33 | smartphone_1_over_2_3default full_frameSensor format; selects the circle of confusion (0.030 mm full frame, 0.020 mm APS-C, 0.015 mm Micro Four Thirds ...).
coc_mmnumbermmnoOptional acceptable circle-of-confusion diameter; overrides the preset value (full frame 0.030, APS-C 0.020, Micro Four Thirds 0.015, 1-inch 0.011 mm). Range: > 0, ≤ 1

Outputs

OutputTypeUnitDescription
hyperfocal_mnumbermH = f²/(N·c) + f: focusing here gives sharpness from H/2 to infinity.
near_limit_mnumbermClosest distance that is acceptably sharp.
far_limit_mnumbermFarthest distance that is acceptably sharp; omitted when it is infinite (see far_limit_text).
far_limit_textstringFar limit as text, 'infinity' when the focus distance is at or beyond the hyperfocal distance.
total_dof_mnumbermfar − near; omitted when the far limit is infinite.
in_front_of_subject_mnumbermfocus_distance − near limit.
behind_subject_mnumbermfar limit − focus_distance; omitted when infinite.
coc_used_mmnumbermmCircle of confusion diameter applied (preset or override).

Example

50 mm, f/2.8, focused at 3 m, full frame: {"focal_length_mm":50,"aperture_f":2.8,"focus_distance_m":3,"sensor":"full_frame"}{"hyperfocal_m":29.812,"near_limit_m":2.729,"far_limit_m":3.33,"total_dof_m":0.601,"coc_used_mm":0.03}

24 mm, f/8, focused at 5 m, full frame (beyond hyperfocal): {"focal_length_mm":24,"aperture_f":8,"focus_distance_m":5,"sensor":"full_frame"}{"hyperfocal_m":2.424,"near_limit_m":1.627,"far_limit_text":"infinity","in_front_of_subject_m":3.373}

GET https://tttkmbb.com/api/v1/calculate/depth-of-field?focal_length_mm=50&aperture_f=2.8&focus_distance_m=3&sensor=full_frame

Machine access

Sources

FAQ

Why does the sensor size change the depth of field?

Smaller sensors are enlarged more for the same print, so the acceptable blur (circle of confusion) is smaller: 0.020 mm for APS-C versus 0.030 mm for full frame. For the same lens and settings that shrinks the depth of field slightly.

Why is the far limit 'infinity'?

When the focus distance is at or beyond the hyperfocal distance H, everything from the near limit to infinity is acceptably sharp, so the far limit and total depth of field are unbounded.

Is the 1/3 in front, 2/3 behind rule built in?

No, the split is computed exactly; it is close to 1/3–2/3 only at moderate distances and approaches 1/2–1/2 in macro range and 'to infinity' near the hyperfocal distance.

Related calculators