Light-year converter
Turn light-years into kilometres, parsecs and astronomical units in one step: one light-year is 9,460,730,472,580.8 km, about three tenths of a parsec. Handy for stars, clusters and nearby galaxies. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Distance in light-years
- 1
- Kilometres
- 9,460,730,472,580.8
- Parsecs
- 0.3066013938
- Astronomical units
- 63,241.0770842663
- Unit light years
- ly
A light-year is the distance light travels in vacuum in one Julian year, and it is one of the units astronomers use for stars, clusters and nearby galaxies when metres become awkward. This capability takes a single finite distance in light-years and returns three equivalent lengths: kilometres for engineering-scale intuition, parsecs for the unit preferred in professional catalogues and papers, and astronomical units for Solar-System scale comparisons.
What a light-year is and which constants this converter uses
By definition a light-year is the distance electromagnetic radiation travels in free space during one Julian year of exactly three hundred sixty-five point two five days. With the exact SI speed of light two hundred ninety-nine million seven hundred ninety-two thousand four hundred fifty-eight metres per second, one light-year is a fixed length: roughly nine point four six times ten to the fifteen metres, or about nine point four six trillion kilometres.
The engine multiplies your light-year input by that fixed scale to produce kilometres, then scales the same length into astronomical units using the exact IAU value one hundred forty-nine million five hundred ninety-seven thousand eight hundred seventy point seven hundred metres per AU, and into parsecs using the IAU geometric definition one parsec equals six hundred forty-eight thousand over pi astronomical units. Those three scales are returned both as the converted distances and as the constants block so you can audit the factors without reverse-engineering the code.
What you can do with it
Homework and planetarium demos
Students and educators convert nearby-star distances from light-years into kilometres, parsecs and AU for worksheets, quizzes and live planetarium talkbacks with a clear error on non-numeric input.
Science outreach and content tools
Blog generators, FAQ bots and museum kiosks turn a ly figure into km, pc and AU without embedding astronomy libraries or hard-coding constants that drift between articles.
FAQ
Which definition of the light-year and parsec do you use?
IAU-aligned constants: light-year from exact c times a Julian year, exact AU of 149597870700 m, and one parsec equals 648000/π astronomical units.
Is the light-year converter free?
The browser tool runs free on your device.
Can I convert from kilometres back to light-years?
No. This capability accepts light-years as input only and returns km, pc and AU. Reverse conversion is a different product intent.
How many kilometres are in one light-year?
9,460,730,472,580.8 kilometres. That is the distance light travels in vacuum during one Julian year, at the fixed speed of light.
Is a light-year a measure of time?
No, it is a distance. The word year only describes how long the light travels; the result is a fixed length, which is why it converts directly to kilometres, parsecs and astronomical units.
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/light-year-distance \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"light_years":1}'const res = await fetch("https://api.kit.forhosting.com/astro/light-year-distance", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"light_years": 1
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/astro/light-year-distance",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"light_years": 1
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/astro/light-year-distance", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"light_years":1}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"light_years":1}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/astro/light-year-distance", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"light_years": 1
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "astro.light_year_distance",
"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
The conversion uses fixed International Astronomical Union constants—exact speed of light, Julian year, exact astronomical unit, and the IAU parsec definition—so identical inputs always produce identical JSON with no network call, no random seed and no wall clock. Non-numeric input fails with a clear invalid_input error and is not charged.
What a light-year is and which constants this converter uses
Send the required field light_years as a JSON number or a numeric string; aliases ly, distance_ly, light_year and distance are accepted. Negative distances are rejected as non-physical for this product; non-numeric strings, missing input and non-finite values raise invalid_input. The algorithm is pure multiply-and-round 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 clock involved.
Reading kilometres, parsecs, AU and the response shape
Use kilometres when you need SI-adjacent magnitude for popular science or engineering estimates; use parsecs when matching SIMBAD, Gaia-style distances or textbook stellar parallax relations (roughly three point two six light-years per parsec); use astronomical units when comparing a stellar distance to the Earth–Sun baseline. Unit labels unit_light_years, unit_kilometres, unit_parsecs and unit_astronomical_units document the symbols ly, km, pc and AU for UIs that render column headers without hard-coding strings. The constants object lists km_per_ly, au_per_ly and pc_per_ly—the same scale factors the engine applied—so a homework checker or scientific notebook can recompute the product and compare. The method field is always iau_light_year so downstream code can branch without sniffing shapes. One light-year is about sixty-three thousand two hundred forty-one AU and about zero point three zero seven parsecs; those textbook order-of-magnitude checks appear automatically when you convert light_years equal to one. Missing light_years, pure text that is not a number, Infinity, NaN and negative 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 light-year converter for homework checks, planetarium demos, blog illustrations and quick mental-math verification without installing an astronomy library. Keep magnitudes within the published cap for isolate safety and prefer classroom-scale inputs for grading oracles. Authors shipping SDKs can map the three distance fields directly into UI tables that show km, pc and AU columns—the same shape students expect when they convert stellar distances by hand with a fixed constant card. Send a JSON body with the required finite non-negative number light_years, or one of the documented aliases when your client already names the field ly or distance. 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 orbital or kinematics tools when the next step is travel time or scale-model sizing, but remember this product is Euclidean length conversion only—it does not apply cosmological redshift, luminosity distance or expanding-space models.
Integration use cases
Catalogue and game pipelines
Scripts that store star data in light-years call a stable prepaid endpoint to fill km, parsec and AU columns for maps, scale models and export formats.
Technical questions
How do I convert light-years to kilometres, parsecs and AU?
Send JSON with light_years set to a finite non-negative number (for example light_years: 1). The response includes kilometres, parsecs and astronomical_units plus the scale constants used.
What happens if the input is not a number?
The request fails with invalid_input. Non-numeric strings, missing light_years, NaN and Infinity are rejected and not charged.