Distance modulus calculator
A star of apparent magnitude 10 and absolute magnitude 5 has a distance modulus of 5 and lies 100 parsecs away, or 326.1563777167 light-years. Enter the two magnitudes to get the modulus and both distances. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Apparent magnitude
- 10
- Absolute magnitude
- 5
- Distance modulus
- 5
- Distance parsecs
- 100
- Distance light years
- 326.1563777167
- Unit parsecs
- pc
The distance modulus links how bright a star looks in the sky to how bright it truly is, and from that difference you recover how far away the star must be. Astronomers write the modulus as apparent magnitude minus absolute magnitude, then convert to parsecs with a fixed base-ten power law that places every star of modulus zero at exactly ten parsecs.
What the distance modulus tells you
A star's apparent magnitude says how bright it looks from Earth; its absolute magnitude says how bright it would look from a standard distance of 10 parsecs. The gap between the two, apparent minus absolute, is the distance modulus. Because larger magnitude numbers mean fainter light, a star that looks dimmer than its true brightness has a larger modulus and lies farther away. Two stars with the same absolute magnitude can therefore be ranked by distance just by comparing how bright they appear in the sky.
How the distance is worked out and common slips
The calculator subtracts the absolute magnitude from the apparent one, adds 5, divides by 5 and raises 10 to that power to get parsecs, then converts parsecs to light-years with a fixed factor. A star of magnitude 10 with an absolute magnitude of 5 comes out at 100 parsecs. Frequent mistakes are swapping the two magnitudes, which flips the sign of the modulus, mixing magnitudes from different color bands, and forgetting that interstellar dust is not corrected, so a dimmed star looks farther away than it is.
What you can do with it
Planetarium and science outreach
Talk scripts and kiosks turn catalogue magnitudes into parsecs and light-years for the audience without embedding astronomy libraries or hard-coding the modulus formula.
FAQ
What is the distance modulus?
It is μ = m − M. Zero modulus means the star is at exactly 10 parsecs. Larger positive moduli mean greater distances on the magnitude scale.
What happens if I send non-numeric input?
Non-numeric strings, missing fields, Infinity and NaN are rejected and not charged.
Is the distance modulus calculator free?
The browser tool runs free on your device.
Does this correct for interstellar extinction?
No. This capability applies the classical vacuum distance-modulus formula only. Extinction or reddening corrections are out of scope and would be a different product intent.
How far away is a star of apparent magnitude 10 and absolute magnitude 5?
100 parsecs, or 326.1563777167 light-years. The difference between the two magnitudes, the distance modulus, is 5, and ten raised to (5 + 5) divided by 5 gives 100 parsecs.
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/astro/distance-modulus \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"apparent_magnitude":10,"absolute_magnitude":5}'const res = await fetch("https://api.kit.forhosting.com/astro/distance-modulus", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"apparent_magnitude": 10,
"absolute_magnitude": 5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/astro/distance-modulus",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"apparent_magnitude": 10,
"absolute_magnitude": 5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/astro/distance-modulus", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"apparent_magnitude":10,"absolute_magnitude":5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"apparent_magnitude":10,"absolute_magnitude":5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/astro/distance-modulus", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"apparent_magnitude": 10,
"absolute_magnitude": 5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "astro.distance_modulus",
"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
This capability takes two finite numbers—the apparent magnitude m and the absolute magnitude M—and returns the modulus, the distance in parsecs, and the equivalent distance in light-years using International Astronomical Union length scales, so classroom worksheets, planetarium talkbacks, and lightweight catalogue pipelines get the same deterministic JSON every time. Non-numeric input fails with a clear invalid_input error and is not charged.
What the distance modulus is and how parsecs are recovered
Apparent magnitude m measures how bright a star appears from Earth on the logarithmic magnitude scale; absolute magnitude M is the magnitude the same star would have if placed at a standard distance of ten parsecs. Their difference mu equals m minus M is called the distance modulus. The classical relation is mu equals five times the base-ten logarithm of the distance in parsecs, minus five, which rearranges to distance in parsecs equals ten raised to the power of open parenthesis mu plus five close parenthesis divided by five. Brighter-looking stars with the same absolute magnitude yield smaller moduli and nearer distances; fainter apparent magnitudes yield larger moduli and greater distances. Send the required fields apparent_magnitude and absolute_magnitude as JSON numbers or numeric strings; aliases m, apparent, app_mag and mag_apparent map to the first field, and M, absolute, abs_mag and mag_absolute map to the second. Non-numeric strings, missing fields, Infinity and NaN raise invalid_input. The engine is pure floating-point arithmetic with a published magnitude cap so Worker isolates stay bounded. Identical inputs always produce identical JSON because there is no network, no model and no wall clock involved in the path.
Reading the response: modulus, parsecs, light-years and formula
The field distance_parsecs is the Euclidean distance implied by the modulus formula; distance_light_years multiplies that parsec value by a fixed IAU-derived light-year per parsec factor built from the exact speed of light, the Julian year, the exact astronomical unit and the IAU geometric parsec definition. Unit labels unit_parsecs and unit_light_years document the symbols pc and ly for user interfaces that render column headers without hard-coding strings. The constants object exposes ly_per_pc so a notebook or grading oracle can recompute the light-year column and compare. The formula string always states d_pc equals ten to the power of open parenthesis m minus M plus five close parenthesis over five, and method is always distance_modulus so downstream code can branch without sniffing shapes. Use distance_parsecs when matching textbook stellar-parallax problems or professional catalogue conventions; use distance_light_years for public outreach, planetarium scripts and popular-science copy that quotes light-years. This product does not apply interstellar extinction, reddening corrections or cosmological luminosity-distance models—those are different intents. Missing magnitudes, pure text that is not a number, and non-finite values all fail with invalid_input and are not charged after the engine rejects the request.
API usage, pricing, classroom workflows and practical limits
Call the free in-browser distance modulus calculator for homework checks, lecture demos, astronomy club worksheets and quick mental-math verification without installing an astronomy library or a full CAS. Extremely large positive moduli push the exponential distance past the published range and are rejected so isolates stay safe; prefer classroom-scale and nearby-star magnitudes for grading oracles. Authors shipping SDKs can map the modulus and dual distance fields directly into UI tables that show mu, parsecs and light-years—the same shape students expect when they apply the distance modulus by hand with a scientific calculator. Send a JSON body with the required finite numbers apparent_magnitude and absolute_magnitude, or the documented aliases when your client already names the fields m and M. Use the prepaid API when an education platform, outreach site, game world-builder, catalogue pipeline or science FAQ bot needs a stable contract under KIT balance at $0.002 per successful item; validation failures never consume balance. Pair this endpoint with a light-year unit converter when the next step is kilometres or astronomical units, but remember that conversion is a separate SEO intent served by another capability—this product owns the modulus-to-distance calculation.
Integration use cases
Homework and exam verification
Students and graders compute stellar distance from m and M, check the ten-parsec modulus-zero case, and get a clear invalid_input error on non-numeric magnitudes.
Catalogue and game pipelines
Scripts that store apparent and absolute magnitudes call a stable prepaid endpoint to fill parsec and light-year distance columns for maps and exports.
Technical questions
How do I calculate distance from apparent and absolute magnitude?
Send JSON with apparent_magnitude (m) and absolute_magnitude (M). The response includes distance_modulus (m−M), distance_parsecs and distance_light_years using d_pc = 10^((m−M+5)/5).