Planet year length calculator
A star of 1.98847e+30 kg and an orbit of 149597870700 m give a year of 365.251375845 days, or 31557718.873 seconds. Enter any star and orbit size to find a planet's orbital year, not a calendar year. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Stellar mass
- 1,988,470,000,000,000,000,000,000,000,000
- Semi major axis
- 149,597,870,700
- G
- 0.0000000001
- Mu
- 132,716,453,210,000,000,000
- A cubed
- 3,347,928,975,810,000,000,000,000,000,000,000
- Year length seconds
- 31,557,718.873
A planet's year is the time it takes to complete one full orbit around its star. Under Newtonian gravity that sidereal period follows Kepler's third law: T equals two pi times the square root of a cubed over G times the stellar mass, where a is the orbital semi-major axis, M★ is the star's mass, and G is the gravitational constant. Non-positive semi-major axis is also rejected because it cannot define a closed Keplerian orbit.
How Kepler's third law sets a planet's year length
Start from two-body gravity with a star of mass M★ that dominates the planet, so the reduced-mass correction can be ignored or already folded into M★. The mean motion of the relative orbit is the square root of G M★ over a cubed, where a is the semi-major axis of the conic. The orbital period—the planet's sidereal year—is then T equals two pi over that mean motion, which expands to the closed form T equals two pi times the square root of a cubed over G M★.
Squaring both sides recovers the classical statement that T squared is proportional to a cubed with proportionality constant four pi squared over G M★. Stellar mass M★ must be a finite positive number of kilograms; zero and negative values fail with invalid input because they are non-physical under Kepler's third law and would divide by zero or produce imaginary periods. Semi-major axis must likewise be finite and positive so a cubed stays positive and the square root is real.
This page intentionally uses the two-body stellar-mass-dominates approximation only; n-body perturbations, tidal locking seasons, calendar definitions that mix solar days with orbital years, and general-relativistic precession are separate search intents and separate landings.
What you send and what you get back
Stellar mass is the central star mass M★ in kilograms and must be strictly greater than zero; for the Sun use about one point nine eight eight times ten to the thirty kilograms. Semi-major axis is the orbital size parameter a in metres and must also be strictly greater than zero; for Earth about the Sun use roughly one point four nine six times ten to the eleven metres, which is one astronomical unit.
Classic checks include one AU about solar mass recovering roughly one Earth year, and Mars at about one point five two AU recovering roughly one point eight eight Earth years. Wire the free browser form for homework and public demos, then call the identical contract from scripts when you need bulk answer keys, catalogue enrichment, or grading oracles. Keep units consistent: convert astronomical units, solar masses, and Earth masses to metres and kilograms before calling so the numeric product matches the SI interpretation your report claims.
Where planet year length calculators show up in real work
Secondary-school and introductory university astronomy courses assign solar-system year drills and exoplanet comparison worksheets that rearrange the same formula; a single trusted oracle speeds grading and demo setup. Science museums and planetarium exhibit authors convert tabulated semi-major axes and stellar masses into human-readable year lengths for labels and interactive kiosks. Amateur astronomers and outreach teams compare how long a year lasts on Mars, Jupiter, or a hot Jupiter around a nearby star without re-deriving constants each time.
Data journalists and catalogue tools enrich open exoplanet tables with year-length columns before charts and rankings. If you later need synodic periods between two planets, orbital energy, circular velocity, or full n-body ephemerides, treat those as separate search intents and landings rather than overloading this planet year length calculator page.
What you can do with it
Homework and exam answer keys
Compute a planet's sidereal year from stellar mass and semi-major axis so students and auto-graders share one closed-form ground truth in seconds, days, and Earth years.
Exoplanet and solar-system demos
Turn catalogue a and M★ values into exhibit-friendly year lengths for planetariums, classroom widgets, and public science pages.
FAQ
What formula does this planet year length calculator use?
The two-body approximation assumes the planet mass is negligible compared with the star, or already folded into M★.
What happens if stellar mass is zero or negative?
Non-positive stellar mass is non-physical under Kepler's third law and would make the year length undefined or non-real.
What units should I use?
SI: stellar mass in kilograms and semi-major axis in metres. Convert AU and solar masses yourself before calling.
Is this a sidereal year or a calendar year?
It is the sidereal orbital period—the time for one full 360° revolution about the star. It does not model seasons, leap years, or the difference between solar and sidereal days on the planet's surface.
What does it cost?
The browser tool is free and runs locally.
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/planet-year-length \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"stellar_mass":1.98847e+30,"semi_major_axis":149597870700}'const res = await fetch("https://api.kit.forhosting.com/astro/planet-year-length", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"stellar_mass": 1.98847e+30,
"semi_major_axis": 149597870700
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/astro/planet-year-length",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"stellar_mass": 1.98847e+30,
"semi_major_axis": 149597870700
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/astro/planet-year-length", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"stellar_mass":1.98847e+30,"semi_major_axis":149597870700}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"stellar_mass":1.98847e+30,"semi_major_axis":149597870700}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/astro/planet-year-length", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"stellar_mass": 1.98847e+30,
"semi_major_axis": 149597870700
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "astro.planet_year_length",
"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
Students convert textbook solar-system distances into human-scale year lengths for Earth, Mars, and gas giants; science communicators turn exoplanet catalogue rows into exhibit-friendly year facts; teachers and auto-graders need a deterministic oracle that never drifts between the free browser demo and the paid API. This calculator accepts stellar mass in kilograms and semi-major axis in metres, returns the year length in seconds with day and Julian-year convenience fields, gravitational parameter mu, and intermediate a cubed for audit, and rejects non-positive stellar mass so a zero or negative star never becomes a silent NaN.
How Kepler's third law sets a planet's year length
The calculator evaluates that closed form in deterministic floating-point arithmetic with the CODATA two thousand eighteen value of G: no random seeds, no wall-clock timestamps, no network calls, and no model drift, so identical inputs always produce identical JSON.
What you send and what you get back
Send two required finite numbers under the fields stellar_mass and semi_major_axis. Missing fields, non-numeric strings, NaN, Infinity, non-positive stellar mass, and non-positive semi-major axis fail with invalid_input and are not charged. On success the response echoes cleaned stellar_mass and semi_major_axis, exposes G as the fixed CODATA constant, mu as G times M★, a_cubed as a to the third power, year_length_seconds as the primary SI result, year_length_days as that period divided by eighty-six thousand four hundred, year_length_earth_years as the period divided by a Julian year of three hundred sixty-five point two five days, includes a units hint object, sets method to kepler_third_law, formula to T equals two pi times the square root of a cubed over G M★, and approximation to two_body_stellar_mass_dominates for honest scope. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.
Where planet year length calculators show up in real work
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
Catalogue enrichment scripts
Bulk-fill year_length_seconds for open planet tables from SI stellar mass and semi-major axis columns without spreadsheet formula drift.