F-stop calculator
Turn focal length and aperture diameter into the f-number printed on a lens: a 50 mm lens with a 25 mm entrance pupil is f/2, with a relative aperture of 0.5. Use the same unit for both lengths. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Focal length
- 50
- Entrance pupil
- 25
- F number
- 2
- Relative aperture
- 0.5
- F stop label
- f/2
The f-number, also called the relative aperture or photographic f-stop, is the dimensionless ratio of a lens focal length to the diameter of its entrance pupil. Photographers write it as f over N, for example f slash two when a fifty millimeter lens is stopped down to a twenty-five millimeter effective aperture. Optical designers, camera app engineers, and classroom teachers all need the same reliable conversion from two lengths into that single number, without unit confusion and without silent division by zero when the aperture collapses. This capability accepts any consistent length unit for focal length and aperture diameter, returns the cleaned f-number, the reciprocal relative aperture, and a printable f-stop label, and rejects a zero or non-positive diameter with a clear validation error instead of emitting Infinity.
How the f-number is defined and computed
Start with two lengths measured in the same unit: the focal length f of the lens and the diameter D of the entrance pupil, which is the image of the physical aperture stop as seen from object space. The classical definition of the f-number is simply N equals f divided by D.
Because both quantities share a length unit, N is dimensionless, which is why a fifty millimeter f slash two lens and a one hundred millimeter f slash two lens share the same geometric light-gathering label even though their absolute pupil sizes differ. Photographers also speak of f-stops as discrete steps along a geometric sequence, but the underlying continuous quantity is always this ratio; converting N into a stop number or exposure value is a separate concern.
Focal length must be strictly positive; a zero or negative f is not a usable thin-lens focal length for this formula.
Where f-stop calculators show up in real work
Photography courses constantly assign problems that convert a stated focal length and physical aperture ring diameter into the f-number printed on a lens barrel; a single trusted oracle speeds grading and demo setup. Camera firmware, mobile photography apps, and lens-design spreadsheets need the same ratio when building EXIF-style metadata, comparing relative light-gathering power across primes, or sanity-checking catalog entries before a product page goes live.
If you later need depth-of-field tables, exposure EV from shutter and ISO, Snell's law refraction angles, or thin-lens magnification, treat those as separate search intents and landings rather than overloading this f-stop calculator page.
What you can do with it
Homework and lens lab answer keys
Convert textbook focal length and pupil diameter pairs into f-numbers and f/N labels so teachers and auto-graders share one ground truth.
Optical design sanity checks
Verify that a proposed pupil diameter for a given focal length matches the target f-number before deeper diffraction or DOF work.
FAQ
What formula does this f-stop calculator use?
The classical definition N = f / D, where f is focal length and D is aperture (entrance pupil) diameter in the same length unit. The response also returns relative aperture D/f and a printable f/N label.
Do focal length and diameter need the same units?
Yes. Both lengths must use the same unit (for example both in millimeters). The f-number is dimensionless; mixing mm and m would silently give a wrong ratio.
Is the f-number the same as a full f-stop step?
The f-number N is the continuous ratio f/D. Photographic full-stop sequences (f/1.4, f/2, f/2.8…) are discrete points on a geometric progression of N; this tool returns the exact continuous value, not a rounded stop index.
What does it cost?
The browser tool is free and runs locally.
Why do a 50 mm lens and a 100 mm lens both show f/2?
Because the f-number is a ratio, not a size. A 50 mm lens with a 25 mm pupil and a 100 mm lens with a 50 mm pupil both give 2, even though the second pupil is twice as wide.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/optics/f-number \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"focal_length":50,"aperture_diameter":25}'const res = await fetch("https://api.kit.forhosting.com/optics/f-number", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"focal_length": 50,
"aperture_diameter": 25
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/optics/f-number",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"focal_length": 50,
"aperture_diameter": 25
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/optics/f-number", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"focal_length":50,"aperture_diameter":25}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"focal_length":50,"aperture_diameter":25}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/optics/f-number", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"focal_length": 50,
"aperture_diameter": 25
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "optics.f_number",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How the f-number is defined and computed
Aperture diameter must also be strictly positive: when D approaches zero the formal ratio diverges, and an exact zero would divide by zero, so the request fails with invalid input rather than returning Infinity or NaN.
What you send and what you get back
Both fields are required. Classic textbook checks include a fifty millimeter lens with a twenty-five millimeter pupil yielding N equals two, an eighty millimeter lens with a ten millimeter pupil yielding N equals eight, and a one hundred millimeter lens with a fifty millimeter pupil again yielding f slash two. Send two finite positive numbers under the fields focal_length and aperture_diameter, using any consistent length unit such as millimeters for camera work or meters for large telescope optics. Aliases accepted by the solver include f, focal, fl, and focal_length_mm for the first length, and diameter, D, aperture, pupil_diameter, and aperture_diameter_mm for the second. Missing fields, non-numeric strings, NaN, and Infinity fail with invalid_input and are not charged. When aperture_diameter is zero, negative, or vanishingly close to zero, the request fails with a message that N equals f over D would divide by zero, so clients can prompt for a real pupil size instead of guessing. On success the response echoes cleaned focal_length and aperture_diameter, the dimensionless f_number, the reciprocal relative_aperture equal to D over f, a human-readable f_stop_label such as f slash two, the formula string N equals f slash D, and unit set to dimensionless. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.
Where f-stop calculators show up in real work
Optical engineering notebooks relate entrance-pupil diameter to diffraction, depth of field, and etendue, and often start from N equals f over D before more advanced calculations; having a pure parse endpoint avoids re-implementing unit handling in every notebook cell. Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.
Integration use cases
Camera app and EXIF-style metadata
Compute relative aperture from measured or catalog focal length and entrance-pupil diameter when building lens metadata or product fixtures.
Technical questions
What happens if aperture diameter is zero?
The request fails with invalid_input. F-number N = f/D is undefined when D = 0, so the solver rejects zero or non-positive diameter instead of returning Infinity.