Skip to content

Throw stars, planets and black holes into space and watch gravity take over, in 2D or 3D, with real orbits and units.

Drag from where it starts, in the direction it should fly. Dragging as far as it is from a star gives a circle.
Inner planets
Speed: 6 months a second
    What to add
    Mass: 1 Earth
      Colour
      Found it useful? or .

      What is Gravity Simulator?

      Gravity Simulator is a space sandbox in your browser where every body pulls on every other by Newton’s law of gravity. Throw a planet past a star and watch it fall into an orbit, crash in or fly away; drop in a black hole; lay a ring of dust; or start from a ready-made universe, from the inner planets to two galaxies colliding. It is an orbit simulator and an n-body simulation at once, in real units: distances in AU, time in days and years, masses in suns, Jupiters and Earths.

      Two disks of stars torn into tails as their galaxies collide, and the inner planets on their orbits in 3D, made with the Gravity Simulator
      Two disks of stars torn into tails as their galaxies collide, and the inner planets on their orbits in 3D, made with the Gravity Simulator

      What it can do

      • Throw anything: stars, black holes, gas giants, planets, moons, asteroids and massless probes, each with its own mass. Drag to throw, and a dotted line shows where it will go before you let go.
      • Orbits in one click: the Orbit tool starts a body on a circular orbit around whatever pulls hardest where you click; the Dust tool lays a whole ring of dust.
      • Real numbers: choose a body to see its speed, the speed it needs to escape, its orbit (circle, ellipse, parabola or hyperbola), its eccentricity, period and closest and farthest points, with its Kepler orbit drawn.
      • Your rules: make gravity weaker or stronger, and let bodies that touch merge, bounce or pass through each other.
      • 14 variations: the inner planets, escape speed, Kepler’s laws, two suns, the figure-eight three-body orbit, three-body chaos, Trojan asteroids, a gravity assist, Jupiter’s moons, the Moon’s path, planets forming from rocks, a galaxy collision and a black hole.
      • 2D and 3D: a clear view from above for building, and a 3D view with glowing stars, lit planets and a sheet that sags under each mass.
      • See more: trails, speed arrows, names, the centre of mass, a grid bent by gravity, Kepler’s equal areas, a view that follows any body, and time from hours to decades a second.
      • Keep it: undo, a link that opens your universe as it is, a file, a picture or a video.

      How to use it

      1. It starts with the inner planets going round the Sun. Space pauses it and R starts it again; the speed slider sets how much time passes each second.
      2. Pick Throw, choose what to add and its mass, then drag from where it should start in the direction it should fly. Dragging as far as it is from the star gives a circular orbit; drag further to escape.
      3. Use Orbit to drop a body straight onto a circular orbit, and Dust ring to circle a star or planet with dust.
      4. Use Select to choose a body: read its orbit, change its mass or kind, fix it in place, follow it with the view, or turn its orbit into a circle.
      5. Switch to 3D to turn the view around and see orbits that are not flat, such as two galaxies meeting at an angle.

      How gravity makes orbits

      Every body pulls on every other with a force of G·m₁·m₂/r²: twice as much mass pulls twice as hard, and twice as far pulls a quarter as hard. A planet in orbit is falling towards its star all the time, but it is moving sideways so fast that it keeps missing. Too slow, and it falls into a narrower ellipse; just right, and it goes round in a circle; at √2 times the speed of a circle, the escape speed, it never comes back.

      With two bodies the answer is always one of these curves, the ones Kepler found in the planets’ motion: ellipses with the star at one focus, sweeping equal areas in equal times, with the square of the period growing as the cube of the size. With three or more, there is no formula, and the motion can be chaotic: a hair’s difference at the start becomes a different future. A simulator works it out step by step instead, which is what an n-body simulation does, and what astronomers do to follow the planets, spacecraft and galaxies.

      This one uses the leapfrog method, which keeps energy steady over thousands of orbits, with steps that shrink when two bodies pass close, down to minutes of simulated time. Its units are the ones astronomers use for the Solar System: the Earth is 1 AU from the Sun, takes 1 year to go round it, and moves at about 30 km/s.

      Ideas to try

      • Find the escape speed: throw probes from the same point a little faster each time and watch the ellipse open into a parabola.
      • Make a moon: put a planet on an orbit, follow it with the view, and use Orbit to give it a moon.
      • Capture a rogue planet: throw a planet past a pair of stars and see whether it stays, crashes or is flung away.
      • Double gravity in the inner planets and watch every orbit shrink and speed up.
      • Drop a black hole through the Solar System: the planets do not stand a chance.
      • Build a galaxy: lay a few dust rings around a black hole, then throw another at it.

      Frequently asked questions

      Is this gravity simulator free?

      Yes. There is nothing to sign up for or install, and it runs entirely in your browser, on a phone as well as a computer. Nothing is uploaded: a shared link carries your universe inside it.

      How accurate is it?

      The motion follows Newton’s law exactly, with no shortcuts between bodies that have mass, and when nothing merges the total energy stays the same to within about a hundredth of a percent over many orbits, often far better. Two things are not life-like on purpose: bodies are drawn and collide much bigger than they are, so that they can be seen, and dust feels gravity without pulling back, so that thousands of grains can move at once. Relativity, which matters only very close to a black hole, is left out.

      What is the three-body problem?

      It is the question of how three bodies move under each other’s gravity, and it has no general formula: Poincaré showed in the 1880s that the motion can be chaotic. A few special solutions are neat, like the figure eight found in 2000, in which three equal stars chase each other along one path; most are not, like Burrau’s problem, in which three stars let go from rest dance closely for a while until one is thrown out. Both are among the variations.

      What are Lagrange points?

      Places where a small body can keep pace with a planet, held by the pull of both the planet and the star. Two of them, L4 and L5, sit 60° ahead of and behind the planet on its orbit, and they are stable: Jupiter carries thousands of Trojan asteroids there. The Trojan asteroids variation shows the two swarms keeping their places.

      How does a gravity assist work?

      A spacecraft that passes behind a moving planet is pulled along by it and leaves faster than it came, taking a tiny share of the planet’s orbital energy. Voyager and Cassini used it to reach the outer planets. In the Gravity assist variation, a probe on its way to Jupiter passes just behind it and is flung out past the orbit of Saturn. For more physics, try the Pendulum Simulator and the Newton's Cradle Simulator.