Gravitational potential energy calculator
Lift 2 kg by 5 m with g at 9.8 m/s² and it stores 98 J relative to where it started. Below the reference level the energy turns negative. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Mass
- 2
- Height
- 5
- Gravitational acceleration in m/s²
- 9.8
- Pe
- 98 J
- Precision
- 10
This gravitational potential energy calculator finds the near-constant-g potential energy of an object when you know its mass, its height relative to a chosen reference level, and the local gravitational acceleration. The definition is the closed form PE equals m times g times h, which is the standard introductory model used in mechanics homework, energy conservation problems, and first-order engineering checks. When mass is given in kilograms, g in metres per second squared, and height in metres, the result is reported in joules; any consistent unit triple works the same way. Zero mass or zero height is valid and yields zero potential energy; negative height means the object sits below the reference and produces a negative PE; negative mass is rejected because it has no physical meaning in this model. The engine is fully deterministic arithmetic: no network calls, no sampling, and no date-dependent shortcuts.
What potential energy means and what you get back
In Newtonian mechanics near a planet or moon, when gravitational acceleration is treated as constant over the region of interest, the gravitational potential energy of a point mass relative to a reference height is PE equals m times g times h. Mass is the intrinsic property of the object, g is the local gravitational acceleration, and h is the vertical coordinate measured from whatever zero height you choose—the floor of a lab, the ground of a roller coaster, sea level, or any other convenient reference.
Changing the reference shifts PE by a constant and does not change energy differences that appear in work–energy theorems. Along a chosen vertical axis a positive height above the reference with positive g and positive mass produces a positive PE in the usual SI convention; a negative height yields a negative signed energy, which is useful when comparing levels in the same problem set.
Potential energy is not the same as kinetic energy or mechanical work already done: it is a state variable of position in the gravitational field under the constant-g model. Zero mass or zero height is valid and yields zero PE when the other factors are finite.
Where gravitational potential energy fits in study, design, and software
Students meet PE equals m g h when a textbook introduces mechanical energy, when a conservation problem asks how much kinetic energy appears after a drop of height h, or when a contest problem gives mass, a planetary g, and a height and asks for PE without calculus. Teachers can pre-generate answer keys for modest mass, height, and g values without trusting opaque calculator apps that silently switch units or confuse mass with weight or energy.
Developers call the same contract from scripts to seed deterministic test vectors for game physics demos, to normalize user-entered elevations before an energy diagram, or to satisfy programming-challenge statements that demand joules rather than a hand-waved sketch. Structural and product first-order checks use PE equals m g h when only mass, local g, and a lift height are known before safety factors or multi-axis dynamics are modeled.
What you can do with it
Homework and lab checks
Compute PE = m·g·h from mass, height, and local g before grading worksheets or comparing energy balances.
Tutoring and teaching software
Normalize user-entered mass, height, and gravity into PE for interactive lessons and step helpers.
FAQ
What does the gravitational potential energy calculator cost?
It is free in your browser on this page.
What formula is used for gravitational potential energy?
Gravitational potential energy is PE = m · g · h, where m is mass, g is gravitational acceleration, and h is height relative to a reference. With SI inputs (kg, m/s², m) the unit is joules (J).
What happens if mass is negative?
Negative mass is not accepted because PE = m·g·h has no standard meaning for negative mass in this calculator.
Can height be negative?
Yes. A negative height means the object is below the chosen reference level and yields a negative PE. Zero height yields zero PE for any finite mass and g.
Which value of g should I use?
Use the local or problem-stated value. Standard Earth gravity is often taken as 9.80665 m/s²; the Moon is about 1.62 m/s². The calculator does not hard-code a planet.
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/mech/potential-energy \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"mass":2,"height":5,"g":9.8}'const res = await fetch("https://api.kit.forhosting.com/mech/potential-energy", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"mass": 2,
"height": 5,
"g": 9.8
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/mech/potential-energy",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"mass": 2,
"height": 5,
"g": 9.8
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/mech/potential-energy", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"mass":2,"height":5,"g":9.8}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"mass":2,"height":5,"g":9.8}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/mech/potential-energy", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"mass": 2,
"height": 5,
"g": 9.8
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "mech.potential_energy",
"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.
Limits
max_abs_mass | 1000000000000000 |
max_abs_g | 1000000 |
max_abs_height | 1000000000000000 |
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
What gravitational potential energy means and what the response contains
This calculator returns the normalized inputs mass, height, and g, the computed pe, the precision used, a method tag potential_energy, a short formula reminder, and a unit hint J for SI inputs. There is no numerical integration of a gravity field, no inverse-square orbital potential, and no Monte Carlo sampling: the engine either evaluates the product inside the supported numeric range or rejects the input with invalid_input. Rejected cases include a missing mass, height, or g, non-finite values, magnitudes above the documented ceilings, and any mass that is negative, because negative mass is not accepted in this calculator.
How mass, height, and g are read and how PE stays reproducible
Zero mass is allowed and returns zero PE. Height may be positive, zero, or negative; negative values place the object below the reference and produce negative PE, which is intentional for multi-level energy diagrams. Use approximately 9.80665 for standard Earth gravity, about 1.62 for the Moon, or a measured local value from a lab; the tool does not hard-code a planet and does not convert unit systems for you. Optional leading plus signs and scientific notation on numeric strings are allowed when they parse as finite decimals; embedded spaces and non-numeric tokens are rejected. The preferred field for mass is mass, but aliases m and M are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. Mass must be finite and non-negative: a negative value fails with invalid_input and a message that names the field and explains that PE equals m times g times h is undefined for negative mass in this calculator, so a bad cell does not become a silent nonsense result. The preferred field for height is height, with aliases h, H, and elevation. The preferred field for gravitational acceleration is g, with aliases gravity, gravity_accel, gravitational_acceleration, and accel_g. An optional precision field, with aliases decimals and dp, chooses how many decimal places to expose for the numeric outputs, defaulting to ten and capped at fifteen so JSON goldens stay stable. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing the potential-energy formula yourself.
Where gravitational potential energy fits in study, design, and software
Product and education tools use the endpoint when a learner types mass, height, and gravity and the UI must show joules. On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. Pair it with weight force or free-fall time helpers when you need related mechanics, and with other math endpoints when you are building a small lab of free, deterministic physics calculators.
Integration use cases
Deterministic test fixtures
Generate reproducible potential-energy values for unit tests, game-physics demos, and CI assertions on PE = m·g·h.