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.

⚡ Magnetic Field of a Straight Wire
Distance unit
Current and distance
Current I (A)
Distance r (in the unit above)
Current and perpendicular distance
Current I (A)
Distance d (cm)
Ends of the wire along its lengthmeasured from the foot of the perpendicular, negative one way
Lower end z1 (cm)
Upper end z2 (cm)
Current directions
Currents
Current I1 (A)
Current I2 (A)
Separation and length (optional)
Separation d (cm)
Length L (m)
Current
A
Wire radius and point of interest
Wire radius a (mm)
Distance from axis r (mm)
Result
—
Result
—
Result
—
Result
—
Result
—
Result
—
Result
—
Result
—

⚡ 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

B = μ0 I / (2π r)    B = μ0 I / (4π d) (sin θ2 − sin θ1)    F/L = μ0 I1 I2 / (2π d)
B = magnetic flux density in tesla (T). 1 T = 10,000 gauss.
I = current in amperes (A), and μ0 = 4π × 10−7 T m/A (the 2018 CODATA value differs by about 5 parts in 1010).
r, d = perpendicular distance from the wire in metres. For a finite segment tan θ = z / d, with z the position of each end along the wire from the foot of the perpendicular.
Two wires: F/L is the force per metre, attractive for currents in the same direction and repulsive for opposite directions.
Inside a round wire of radius a with uniform current: B = μ0 I r / (2π a²) for r ≤ a, and B = μ0 I / (2π r) for r ≥ a.
Example: 10 A at 5 cm gives B = 2 × 10−7 × 10 / 0.05 = 4 × 10−5 T, which is 40 µT.

📖 How to Use This Calculator

Steps

1
Choose a mode. Use Long wire for the standard 1/r field, Finite segment for a short piece, Two wires for the force between them, and Inside a wire for the field in a conductor.
2
Set the unit or direction first. In the Long wire mode choose mm, cm or m before typing the distance, and in the Two wires mode choose same or opposite directions. Selecting an option never rewrites a number you already typed.
3
Enter the current and the distances. For a finite segment give the perpendicular distance and the two end positions along the wire.
4
Read the result and the chart. The field appears in tesla, microtesla and gauss, with a chart that marks your point.

💡 Example Calculations

Example 1 — A Cable Carrying 10 A

The field 5 cm from a long straight wire carrying 10 A

1
r = 5 cm = 0.05 m.
2
B = 4π × 10−7 × 10 / (2π × 0.05) = 4.000e-5 T.
3
That is 40 µT or 0.4 gauss, 0.8 times the Earth's field of about 50 µT (rounded, illustrative).
Magnetic field = 40 µT
Try this example →

Example 2 — Under a Power Line

A conductor carrying 200 A, observed 2 m away

1
B = 2 × 10−7 × 200 / 2 = 2.000e-5 T.
2
That is 20 µT.
3
Divided by 50 µT this is 0.4 of the Earth's field, so a compass would be disturbed noticeably.
Magnetic field = 20 µT
Try this example →

Example 3 — A 20 cm Segment

10 A in a segment from −10 cm to +10 cm, observed 5 cm from its midpoint

1
θ2 = atan(10 / 5) = 63.43° and θ1 = −63.43°, so sin θ2 − sin θ1 = 1.789.
2
B = 10−7 × 10 / 0.05 × 1.789 = 35.78 µT.
3
The infinite wire would give 40 µT, so the segment gives 89.44 % of it.
Magnetic field = 35.78 µT, 89.44 % of the infinite wire
Try this example →

Example 4 — Two Parallel Cables

10 A and 20 A in the same direction, 5 cm apart, over 2.5 m

1
F/L = 4π × 10−7 × 10 × 20 / (2π × 0.05) = 8.000e-4 N/m.
2
Over 2.5 m the force is 8.000e-4 × 2.5 = 0.002 N.
3
The currents point the same way, so the wires attract. Halving the separation doubles the force to 0.0016 N/m.
Force per metre = 8.000e-4 N/m, attractive
Try this example →

Example 5 — Inside a Round Conductor

50 A in a wire of radius 2 mm, at 1 mm from the axis

1
The enclosed current is 50 × (1/2)² = 12.5 A.
2
B = μ0 I r / (2π a²) = 2 × 10−7 × 50 × 0.001 / (0.002)² = 0.0025 T, or 2.5 mT.
3
At the surface the field is 5 mT, so this point has 0.5 of the maximum. The current density is 3.979e+6 A/m².
Magnetic field = 2.5 mT
Try this example →

❓ Frequently Asked Questions

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.
Why does the 1/r formula need a very long wire?+
The formula comes from integrating over an infinite wire, or from Ampere's law with circular symmetry. For a real wire it is accurate when the distance is much smaller than the length and than the distance to the ends. Otherwise use the finite segment formula.
Can a single finite segment carry steady current?+
Not by itself. Steady current needs a closed circuit, so a real current path has other parts too. The finite segment result is the contribution of one piece, and the total field is the sum of the contributions from all the pieces.

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.