Gravitational force calculator
Earth pulls on a 70 kg person at its surface with 687.421160537 newtons. Enter two masses in kilograms and the distance between their centres in metres to get the attractive force and the acceleration of each body. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Mass1
- 5,972,200,000,000,000,000,000,000
- Mass2
- 70
- Distance
- 6,371,000
- G
- 0.0000000001
- R squared
- 40,589,641,000,000
- Mass product
- 418,054,000,000,000,000,000,000,000
- Force
- 687.421160537
Newton's law of universal gravitation states that every pair of masses attracts with a force proportional to the product of the masses and inversely proportional to the square of the distance between their centres. In SI units the magnitude is F equals G times m1 times m2 over r squared, where G is the gravitational constant, m1 and m2 are the two masses in kilograms, and r is the centre-to-centre separation in metres. Negative separation and non-positive masses are also rejected with clear validation errors.
How Newton's law of universal gravitation works
Start from the classical statement that the gravitational force between two point masses is attractive, acts along the line joining the centres, and has magnitude F equals G times m1 times m2 divided by r squared. The constant G is fixed here at the CODATA two thousand eighteen value of six point six seven four three times ten to the minus eleven cubic metres per kilogram per second squared, so identical SI inputs always produce identical force numbers.
The inverse-square dependence means that doubling the separation quarters the force, while doubling either mass doubles the force; the product m1 times m2 appears because gravity couples every mass to every other mass. For perfect spheres or spherical shells of uniform density the exterior field is identical to a point mass at the centre, which is why textbook Earth-surface and planetary checks use mean radius and total mass.
The calculator evaluates the closed form in deterministic floating-point arithmetic: no random seeds, no wall-clock timestamps, no network calls, and no model drift. Distance r must be a finite strictly positive number of metres; zero fails with invalid input because the law divides by r squared and the force is undefined at coincident centres. Negative separation is rejected as non-physical for a centre-to-centre distance.
Each mass must likewise be finite and positive so the product stays non-negative and the force is a well-defined attraction. This page intentionally uses the Newtonian point-mass magnitude only; orbital periods, general-relativistic corrections, multipole gravity, and tidal gradients are separate search intents and separate landings.
What you send and what you get back
Send three required finite numbers under the fields mass1, mass2, and distance. Mass1 and mass2 are the two body masses in kilograms and must each be strictly greater than zero; for Earth use about five point nine seven two times ten to the twenty-four kilograms, for a typical human body about seventy kilograms, and for the Moon about seven point three four two times ten to the twenty-two kilograms.
Distance is the centre-to-centre separation r in metres and must also be strictly greater than zero; for a point near Earth's mean surface use about six million three hundred seventy-one thousand metres. Classic textbook checks include two one-kilogram masses one metre apart recovering F equal to G, and Earth mass with a seventy-kilogram person at mean Earth radius recovering a weight near six hundred eighty-six newtons.
Keep units consistent: convert grams, tonnes, kilometres, and Earth radii to kilograms and metres before calling so the numeric product matches the SI interpretation your report claims.
Where gravitational force calculators show up in real work
Secondary-school and introductory university physics and astronomy courses assign inverse-square drills, Earth-surface weight checks, and two-body attraction estimates that rearrange the same formula; a single trusted oracle speeds grading and demo setup. Planetary science and mission concept teams convert tabulated masses and separations into rough Newtonian forces before full gravity-field models and numerical propagators. Science communicators convert human-scale masses at laboratory distances into tiny forces to illustrate how weak gravity is compared with electromagnetism.
Game and simulation authors seed n-body toy demos with closed-form pairwise forces when they want a transparent ground truth without floating-point surprises from ad-hoc constants. If you later need orbital period from semi-major axis and central mass, surface gravity tables with local g, tidal force gradients, or general-relativistic geodesics, treat those as separate search intents and landings rather than overloading this gravitational force calculator page.
What you can do with it
Homework and exam answer keys
Compute Newtonian attraction F from two masses and separation so students and auto-graders share one closed-form ground truth in newtons with audit intermediates.
Earth-surface weight checks
Combine Earth mass with a body mass at mean Earth radius to recover weight near m·g without relying on a pre-baked local-g table.
Mission and planetarium demos
Turn tabulated planetary masses and distances into pairwise forces for concept studies, exhibits, and curriculum widgets.
FAQ
What formula does this gravitational force calculator use?
Newton's law of universal gravitation: F = G·m1·m2 / r², with G fixed at the CODATA 2018 value. The result is the attractive force magnitude between two point masses (or exterior spherical bodies) in newtons when SI units are used.
What happens if distance is zero?
Newton's law divides by r², so zero separation is undefined and is rejected with a clear validation message instead of returning Infinity or NaN.
What units should I use?
SI: masses in kilograms and distance in metres. The force is returned in newtons (N). Convert grams, tonnes, kilometres, and Earth radii yourself before calling.
What does it cost?
The browser tool is free and runs locally.
What happens to the force if the distance doubles?
It drops to a quarter, because the force depends on the inverse square of the distance. Doubling either mass, by contrast, doubles the force, since gravity grows with the product of the two masses.
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/gravitational-force \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"mass1":5.9722e+24,"mass2":70,"distance":6371000}'const res = await fetch("https://api.kit.forhosting.com/astro/gravitational-force", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"mass1": 5.9722e+24,
"mass2": 70,
"distance": 6371000
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/astro/gravitational-force",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"mass1": 5.9722e+24,
"mass2": 70,
"distance": 6371000
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/astro/gravitational-force", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"mass1":5.9722e+24,"mass2":70,"distance":6371000}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"mass1":5.9722e+24,"mass2":70,"distance":6371000}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/astro/gravitational-force", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"mass1": 5.9722e+24,
"mass2": 70,
"distance": 6371000
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "astro.gravitational_force",
"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
What you send and what you get back
Missing fields, non-numeric strings, NaN, Infinity, non-positive masses, zero distance, and negative distance fail with invalid_input and are not charged. On success the response echoes cleaned mass1, mass2, and distance, exposes G as the fixed CODATA constant, r_squared as distance squared, mass_product as mass1 times mass2, force as the primary SI result in newtons, accel_on_mass2 as G times mass1 over r squared, accel_on_mass1 as G times mass2 over r squared, includes a units hint object, sets method to newton_universal_gravitation, and formula to F equals G times m1 times m2 over r squared. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.
Where gravitational force 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.
Technical questions
Does it return acceleration as well as force?
Yes. The response includes accel_on_mass2 = G·m1/r² and accel_on_mass1 = G·m2/r² so you can check that force equals each mass times the acceleration it experiences.