Magnetic field lines are the invisible topography around magnets. This simulation draws them in real time for any arrangement of magnetic poles you place, revealing flux density and the characteristic patterns of dipoles, monopoles and quadrupoles.
Each field line traces the direction of the net magnetic force using the Biot-Savart law. Positive poles (red) radiate outward, negative poles (blue) converge inward, and the line density indicates field strength. Equipotential contours can be toggled on.
Left-click to add a north pole, right-click for a south pole. Drag poles to rearrange them. The field redraws live. Delete a pole by right-clicking an existing one or using the Reset button.
Earth's magnetic field resembles a dipole tilted ≈11° from the rotation axis. Every 200 000–300 000 years the poles flip — during reversal the field weakens and becomes complex, briefly resembling the chaotic patterns you can create here.
This simulation visualises the invisible magnetic field around magnetic poles. You can place north and south poles anywhere on the canvas, and the field lines and streaming test particles update in real time, tracing the direction a compass needle would point at every location. The lines are computed by summing the field contributions of each pole, building on the Biot-Savart law and the principle of superposition, so they always emerge from north poles and curve back into south poles.
Magnetic field lines are a powerful way to picture how magnets, electric currents and charged particles interact. The same patterns describe everything from a simple bar magnet to Earth's protective magnetosphere, the deflection of cosmic rays, the operation of electric motors and the confinement of plasma in fusion reactors. Field-line density indicates field strength: where lines crowd together the field is strong, and where they spread apart it is weak.
What are magnetic field lines?
Magnetic field lines are imaginary curves that show the direction of the magnetic field at every point. A small compass placed on a line would align along it, pointing from north toward south outside the magnet.
Why do field lines go from north to south?
By convention, field lines emerge from the north pole and enter the south pole outside the magnet, then continue from south to north inside it. This direction matches the way a compass needle's north end is pushed.
What does the spacing of field lines tell you?
The density of field lines represents field strength. Where lines are packed closely, near the poles, the magnetic field is strong; where they fan out and spread apart, the field is weaker.
What is the Biot-Savart law?
The Biot-Savart law gives the magnetic field produced by an electric current or magnetic source, describing how the field strength falls off with distance and depends on direction. Summing these contributions builds the full field pattern.
No isolated magnetic monopole has ever been observed. Magnetic poles always come in north-south pairs, so cutting a magnet in half simply produces two smaller magnets, each with its own pair of poles.
Earth behaves like a giant bar magnet, with field lines that loop from one pole to the other. This magnetosphere shields the planet by deflecting charged particles from the solar wind, and is what makes compasses work.
When several poles are present, the total magnetic field at any point is the vector sum of the fields from each pole individually. The simulation adds these contributions together to trace the resulting field lines.
Between opposite poles the field lines connect directly, pulling the magnets together, while between like poles the lines push apart and crowd, creating a region the magnets are forced away from.
The streaming test particles follow the field lines to make the field's direction and flow easy to see. They illustrate the path a freely moving compass or charged tracer would tend to follow.
Magnetic fields drive electric motors and generators, store data on hard drives, image the body in MRI scanners, and confine superheated plasma in fusion experiments, among many other applications.