Skip to content

Magnetic Field Calculator: Straight Wire, Current Loop, Solenoid, Helmholtz Coil and Toroid

Compute the magnetic flux density B produced by steady currents in the six most common conductor shapes, using the Biot–Savart law and Ampère's law. The calculator gives B in tesla, millitesla, microtesla and gauss, plots the field along the axis, maps the exact off-axis field of a loop, compares finite and ideal solenoids, and shows the substituted formula for every result.

6 configurationsExact off-axis loop fieldField plots + mapCODATA 2022 μ₀Step-by-step
By Bimal Ghimire · Published October 30, 2026 · Formulas verified against numerical Biot–Savart integration.

Key facts

  • A long straight wire produces B = μ₀I/(2πr): 10 A gives 40 μT at 5 cm.
  • A circular loop produces B = μ₀NI/(2R) at its centre and B = μ₀NIR²/[2(R² + z²)^(3/2)] on its axis.
  • An ideal solenoid has a uniform interior field B = μ₀nI (n = turns per metre); at the end of a long solenoid B drops to about half.
  • A Helmholtz coil (spacing = radius) gives B = (4/5)^(3/2) μ₀NI/R ≈ 0.7155 μ₀NI/R with a very uniform central region.
  • A toroid confines the field inside: B = μ₀NI/(2πr) for a < r < b and zero outside (ideal winding).
  • μ₀ = 1.25663706127 × 10⁻⁶ N/A² (CODATA 2022), measured since the 2019 SI revision; 1 T = 10⁴ G.

Magnetic Field Calculator

Hover over the map to read the exact field.

Meridional plane of a single loop (axis vertical, loop cross-section shown as two dots). Colour is |B| on a log scale; arrows show field direction. Computed with complete elliptic integrals.

    Magnetic Field Formulas for Each Configuration

    Infinite straight wire (Ampère's law)
    $$B=\frac{\mu_0 I}{2\pi r}$$
    Finite straight segment from z₁ to z₂ (Biot–Savart)
    $$B=\frac{\mu_0 I}{4\pi r}\left[\frac{z_2-z}{\sqrt{(z_2-z)^2+r^2}}-\frac{z_1-z}{\sqrt{(z_1-z)^2+r^2}}\right]=\frac{\mu_0 I}{4\pi r}\,(\sin\theta_2-\sin\theta_1)$$
    Circular loop, on the axis
    $$B_z(z)=\frac{\mu_0 N I R^2}{2\,(R^2+z^2)^{3/2}},\qquad B_{centre}=\frac{\mu_0 N I}{2R}$$
    Circular loop, anywhere (cylindrical ρ, z)
    $$B_z=\frac{\mu_0 N I}{2\pi\sqrt{(R+\rho)^2+z^2}}\left[K(m)+\frac{R^2-\rho^2-z^2}{(R-\rho)^2+z^2}E(m)\right]$$ $$B_\rho=\frac{\mu_0 N I\,z}{2\pi\rho\sqrt{(R+\rho)^2+z^2}}\left[-K(m)+\frac{R^2+\rho^2+z^2}{(R-\rho)^2+z^2}E(m)\right],\quad m=\frac{4R\rho}{(R+\rho)^2+z^2}$$
    K and E are complete elliptic integrals of the first and second kind with parameter m = k². They are evaluated with the arithmetic–geometric mean, accurate to machine precision.
    Finite solenoid, on the axis (current-sheet model)
    $$B_z(z)=\frac{\mu_0 n I}{2}\left[\frac{z+L/2}{\sqrt{(z+L/2)^2+R^2}}-\frac{z-L/2}{\sqrt{(z-L/2)^2+R^2}}\right],\qquad n=\frac{N}{L}$$
    As L/R → ∞ the bracket → 2 inside, giving the ideal result \(B=\mu_0 n I\).
    Helmholtz coil (two N-turn loops, spacing d, centre at z = 0)
    $$B_z(z)=\frac{\mu_0 N I R^2}{2}\left[\frac{1}{(R^2+(z-d/2)^2)^{3/2}}+\frac{1}{(R^2+(z+d/2)^2)^{3/2}}\right],\quad d=R\Rightarrow B_0=\left(\tfrac45\right)^{3/2}\frac{\mu_0NI}{R}$$
    Toroid (Ampère's law)
    $$B=\frac{\mu_0\mu_r N I}{2\pi r}\quad(a<r<b),\qquad B=0\ \text{outside}$$
    μr applies to a linear core material below saturation.

    The Biot–Savart Law

    The Biot–Savart law gives the magnetic field produced by a steady current as a sum over infinitesimal current elements:

    $$d\mathbf B=\frac{\mu_0}{4\pi}\,\frac{I\,d\boldsymbol\ell\times\hat{\mathbf r}}{r^2}\qquad\Rightarrow\qquad \mathbf B(\mathbf x)=\frac{\mu_0 I}{4\pi}\oint\frac{d\boldsymbol\ell\times(\mathbf x-\mathbf x')}{|\mathbf x-\mathbf x'|^3}$$

    It is the magnetostatic counterpart of Coulomb's law: the field falls as 1/r² from each element and is perpendicular to both the current element and the line joining it to the field point. Every formula in the table above is an exact integral of this law for a particular shape. To check them, we integrated the Biot–Savart law numerically (hundreds of thousands of segments, including a 200-turn helix for the solenoid) and found agreement to better than one part in a million.

    Direction follows the right-hand rule: point the thumb along the current and the fingers curl in the direction of B. For a loop, curl the fingers with the current and the thumb points along B through the centre.

    Ampère's Circuital Law

    $$\oint_C\mathbf B\cdot d\boldsymbol\ell=\mu_0 I_{enc}\qquad(\text{magnetostatics})$$

    When symmetry makes |B| constant along a chosen loop, Ampère's law gives the field in one line. For a long wire, a circle of radius r gives \(B\cdot 2\pi r=\mu_0 I\). For a toroid, a circle inside the core encloses N turns, so \(B\cdot2\pi r=\mu_0NI\). For an ideal solenoid, a rectangular loop gives \(BL=\mu_0NI\). Loops and finite solenoids lack this symmetry, which is why they need Biot–Savart. Maxwell later added the displacement current term, see Maxwell's equations explained.

    Worked Examples

    1. Long wire: 10 A at 5 cm

    \(B=\mu_0I/(2\pi r)=1.2566\times10^{-6}\times10/(2\pi\times0.05)=4.00\times10^{-5}\) T = 40.0 μT (0.400 G). This is comparable to Earth's field, which is why Ørsted's 1820 compass needle deflected near a current.

    2. Solenoid: N = 500, L = 25 cm, R = 2 cm, I = 2 A

    Ideal: \(B=\mu_0(500/0.25)(2)=5.027\) mT. Finite solenoid at the centre: 4.963 mT (1.3% lower). At the end face (z = L/2): 2.505 mT, essentially half of the centre value.

    3. Helmholtz coil: N = 100 per coil, R = 15 cm, I = 1 A

    \(B_0=0.7155\times\mu_0\times100\times1/0.15=\) 0.599 mT (5.99 G) at the centre.

    4. Toroid: N = 400, I = 3 A, mean radius 10 cm, air core

    \(B=\mu_0\times400\times3/(2\pi\times0.10)=\) 2.40 mT at r = 10 cm, and zero outside the winding.

    Each example is one click away: choose the configuration above and enter the values to see the substituted formulas.

    Units and Typical Magnetic Field Strengths

    QuantitySI unitConversions
    Magnetic flux density Btesla (T) = Wb/m² = N/(A·m)1 T = 10⁴ G; 1 μT = 0.01 G = 1000 nT
    Magnetic field strength HA/mIn vacuum/air H = B/μ₀; 1 Oe = 1000/(4π) A/m ≈ 79.58 A/m
    Magnetic flux Φweber (Wb) = T·m²1 Wb = 10⁸ maxwell
    SourceTypical B
    Earth's magnetic field at the surface≈ 25 – 65 μT
    10 A wire at 5 cm (Example 1)40 μT
    Laboratory Helmholtz coil (Example 3)≈ 0.6 mT
    Clinical MRI scanner1.5 T or 3 T

    Assumptions and Limits

    Steady (DC) currents

    Magnetostatics. For fast-changing currents, retardation and induced fields matter (see Faraday's law).

    Thin conductors

    Wires are treated as lines; inside a thick wire B grows linearly with r up to its surface.

    Vacuum or air

    μr = 1 except for the toroid option. Ferromagnetic cores in open solenoids need demagnetisation analysis, not a simple μr factor.

    Solenoid as a current sheet

    Accurate on the axis when the winding is tight; very close to the wires the discrete turns cause ripple.

    Related Tools and Guides

    Frequently Asked Questions

    What is the magnetic field around a long straight wire?

    B = μ₀I/(2πr), where I is the current and r the perpendicular distance from the wire. The field lines are circles around the wire, with direction given by the right-hand rule. For 10 A at 5 cm, B ≈ 4.0 × 10⁻⁵ T (40 μT), similar to Earth's magnetic field.

    How do you calculate the magnetic field inside a solenoid?

    For a long solenoid, B = μ₀nI, where n = N/L is the number of turns per metre. For a solenoid of finite length on its axis, B(z) = (μ₀nI/2)[cos θ₁ − cos θ₂], written in this calculator in terms of the distances to both ends. At the ends of a long solenoid the field is about half of the central value.

    What is the magnetic field at the centre of a circular loop?

    B = μ₀NI/(2R) for N turns of radius R carrying current I. On the axis at distance z from the centre, B = μ₀NIR²/[2(R² + z²)^(3/2)]. Off the axis the field requires complete elliptic integrals, which this calculator evaluates exactly.

    Why is a Helmholtz coil so uniform?

    Two identical coaxial loops separated by a distance equal to their radius make the first and second derivatives of the axial field (and, by symmetry, the third) zero at the midpoint. The field at the centre is B = (4/5)^(3/2) μ₀NI/R ≈ 0.7155 μ₀NI/R.

    Is μ₀ exactly 4π × 10⁻⁷ H/m?

    Not any more. Since the 2019 revision of the SI, μ₀ is an experimentally determined constant. The CODATA 2022 value is 1.25663706127(20) × 10⁻⁶ N/A², which differs from 4π × 10⁻⁷ by about one part in 10¹⁰. This calculator uses the CODATA value; the difference is negligible in engineering.

    How do I convert tesla to gauss?

    1 tesla = 10,000 gauss, so 1 mT = 10 G and 1 μT = 0.01 G. The tesla is the SI unit; the gauss is the CGS unit still common in magnet datasheets and geophysics (where the nanotesla is also used).

    What is the difference between B and H?

    B (magnetic flux density, tesla) is the field that exerts force on moving charges. H (magnetic field strength, A/m) is related to free currents through Ampère's law. In vacuum or air B = μ₀H; inside magnetic materials B = μ₀(H + M).

    References

    Tiesinga, E., Mohr, P. J., Newell, D. B., & Taylor, B. N. (2025). CODATA recommended values of the fundamental physical constants: 2022. Reviews of Modern Physics / NIST. physics.nist.gov/cuu/Constants

    Griffiths, D. J. (2017). Introduction to Electrodynamics (4th ed.), Chapter 5: Magnetostatics. Cambridge University Press.

    Jackson, J. D. (1999). Classical Electrodynamics (3rd ed.), Section 5.5 (field of a circular current loop). Wiley.

    Ling, S. J., Sanny, J., & Moebs, W. (2016). University Physics Volume 2, Chapter 12: Sources of Magnetic Fields. OpenStax. openstax.org

    Simpson, J. C., Lane, J. E., Immer, C. D., & Youngquist, R. C. (2001). Simple Analytic Expressions for the Magnetic Field of a Circular Current Loop. NASA Technical Memorandum, Kennedy Space Center.

    Cite this tool: Ghimire, B. (2026). Magnetic Field Calculator: Wire, Loop, Solenoid & Helmholtz Coil. Engineers Views. https://engineersviews.com/tools/magnetic-field-calculator/