Home▸Physics & Mechanics▸Magnetic Field Lines Simulator (2D)

Magnetic Field Lines Simulator (2D)

Interactive 2D bar-magnet dipole simulator: drag the magnet, flip its poles, and watch field lines and iron filings trace the true dipole field with a drop-in compass probe.

Physics & Mechanics2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-3d-magnetic-field-lines ↗ Open standalone

This 2D simulator draws a bar magnet's dipole field from directly above: field lines leave the red N pole, sweep outward, and loop back into the blue S pole, exactly as the physics of a magnetic dipole predicts. Drag the magnet to relocate it, flip its polarity, and dial up the strength, line count, or iron-filing density to see the field recompute live — every filing tilts to match the local field direction, and dropping a compass probe anywhere on the canvas reads out the exact field magnitude at that point. Add a second magnet to explore attraction and repulsion between two dipoles.

⚙ Under the hood

Interactive 2D bar-magnet dipole simulator: drag the magnet, flip its poles, and watch field lines and iron filings trace the true dipole field, with a drop-in compass probe and an optional second magnet.

magnetic fieldbar magnetdipolefield linesiron filingscompass2d

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)