Magnetic Field of a Straight Current-Carrying Wire Calculator
Calculate the magnetic field around a straight wire, the force between parallel wires and the field inside a conductor.
⚡ What is the Magnetic Field of a Straight Wire?
A wire that carries an electric current is surrounded by a magnetic field. This was the discovery that Hans Christian Oersted made in 1820 when a compass needle twitched near a wire, and it began the science of electromagnetism. For a long straight wire the field has a very simple shape: it forms circles around the wire, is the same strength all the way round a circle, and weakens in proportion to the distance. The size is B = μ0 I / (2π r), where I is the current, r the distance from the wire and μ0 the permeability of free space. The direction follows the right-hand rule: with the thumb of your right hand along the current, your fingers curl the way the field circulates.
Diagram: the current comes out of the page, shown by the dot in the centre. The blue circles are field lines and the arrows show that the field runs counterclockwise. Their spacing shows that the field weakens with distance.
The result matters in engineering and in the lab. It sets how strongly two cables interact, which is why heavy conductors in a switchboard are braced against each other during a fault. It decides how much interference a power line puts into a nearby sensor, how a Hall-effect current probe sees a busbar, and how a compass reacts near a cable. The same formula gave the original definition of the ampere, from the force between two long wires. This page covers four cases: the long wire, a finite segment with its end angles, the force between two parallel wires, and the field inside a conductor, where the formula changes because only part of the current is enclosed.
Three limits are worth remembering. The 1/r result assumes a wire much longer than the distance to it; near the end of a real wire or at a distance comparable to its length, use the finite segment mode. A single segment is not a complete circuit, so its field is only a contribution to the total from the whole current path. And inside a thick wire the field is not 1/r but grows linearly from zero on the axis. For the moment of a loop of wire see the magnetic dipole moment calculator, for how materials change the field see the magnetic permeability calculator, and for the force on a moving charge see the Lorentz force calculator.
📐 Formula
📖 How to Use This Calculator
Steps
💡 Example Calculations
Example 1 — A Cable Carrying 10 A
The field 5 cm from a long straight wire carrying 10 A
Example 2 — Under a Power Line
A conductor carrying 200 A, observed 2 m away
Example 3 — A 20 cm Segment
10 A in a segment from −10 cm to +10 cm, observed 5 cm from its midpoint
Example 4 — Two Parallel Cables
10 A and 20 A in the same direction, 5 cm apart, over 2.5 m
Example 5 — Inside a Round Conductor
50 A in a wire of radius 2 mm, at 1 mm from the axis
❓ Frequently Asked Questions
🔗 Related Calculators
What is the formula for the magnetic field of a straight wire?
For a very long straight wire, B = mu0 I / (2 pi r), where I is the current, r is the perpendicular distance from the wire and mu0 = 4 pi x 10^-7 T m/A. The field forms circles around the wire. 10 A at 5 cm gives 40 microtesla.
What is the right-hand rule for a current-carrying wire?
Point the thumb of your right hand along the conventional current and curl the fingers. The fingers show the direction of the magnetic field lines, which circle the wire. Seen with the current coming toward you, the field runs counterclockwise.
How do you find the field of a finite wire segment?
Use B = mu0 I / (4 pi d) (sin theta2 - sin theta1), where d is the perpendicular distance and the angles are measured from the perpendicular to the line from the field point to each end. For a symmetric segment of length L the field is mu0 I L / (4 pi d sqrt(d^2 + L^2/4)).
What is the force between two parallel current-carrying wires?
The force per metre is F/L = mu0 I1 I2 / (2 pi d). Wires with currents in the same direction attract and wires with currents in opposite directions repel. Two wires with 10 A and 20 A, 5 cm apart, pull on each other with 0.8 mN per metre.
How is the ampere related to the force between wires?
The old definition of the ampere used this force: one ampere in each of two long parallel wires 1 m apart gives 2 x 10^-7 N per metre. Since 2019 the ampere is defined from the elementary charge, but the result is still very nearly the same.
What is the magnetic field inside a current-carrying wire?
For a round wire with uniform current, Ampere's law gives B = mu0 I r / (2 pi a^2) for r less than the wire radius a. The field is zero on the axis, rises in a straight line, and peaks at the surface, where it equals mu0 I / (2 pi a).
Does the magnetic field depend on the wire thickness?
Outside the wire it does not: the field depends only on the current and the distance from the axis. Inside the wire the thickness matters because only the current within radius r contributes.
How strong is the field of a power line compared with the Earth's field?
A conductor carrying 200 A produces about 20 microtesla at 2 m, which is about 0.4 of the Earth's field of roughly 50 microtesla at the surface. The field falls off as 1/r, so it is much smaller at tens of metres.
What is the direction of the field of a wire?
It is tangent to circles centred on the wire and perpendicular to the current. The magnitude is the same all round a given circle, and the direction follows the right-hand rule.
How does the field change if the distance doubles?
It halves. B is proportional to 1/r for a long wire, so doubling the distance gives half the field and halving the distance gives twice the field.