Magnetic field of a straight wire calculator
A current of 10 A produces 0.00004 T at 5 cm from a long straight wire: enter the current and the perpendicular distance and get the field strength from Ampère's law, with a distance of zero refused rather than turned into infinity. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Electric current
- 10
- Resistance (Ω)
- 0.05
- Current
- 10
- Distance
- 0.05
- B
- 0.00004
- Magnetic field
- 0.00004
A magnetic field straight wire calculator turns current and radial distance into the field magnitude around a long straight conductor. Signed current uses absolute value for magnitude; direction follows the right-hand rule outside this tool.
What B = μ₀ I / (2 π r) means for a long straight wire
In magnetostatics, a long straight wire carrying steady current I produces circular magnetic field lines concentric with the wire. Ampère’s law (or the Biot–Savart law integrated for an infinite line) gives the magnitude B equals mu-zero times absolute I divided by two pi r, where r is the perpendicular distance from the wire axis to the field point. In SI units—amperes for current and meters for distance—B is in teslas.
Vacuum permeability mu-zero is defined as four pi times ten to the minus seven tesla-meters per ampere, which simplifies the formula to the exact equivalent B equals two times ten to the minus seven times absolute I over r. The idealization assumes an infinitely long thin wire in free space, steady current, and a point not on the axis; it does not model finite-length segments, thick conductors with internal field, ferromagnetic media, or time-varying displacement current.
Teachers and automated graders care about the r-equals-zero rejection as much as the arithmetic: a student who plugs r equals zero has left the domain of the formula, and a silent infinity would hide that mistake. Magnitude is non-negative; the right-hand rule (thumb along conventional current, fingers curl with B) supplies direction separately.
The check path recomputes two times ten to the minus seven times absolute I over r with the same fixed rounding used for published fields, so a successful response always ships with steps you can assert in tests or worksheets.
Practical tips, limits, and related searches
Keep current and distance inside the published absolute range so their ratio cannot overflow into a non-finite field that the solver must reject. Convert centimeters to meters and milliamps to amperes before you call if you want B already in teslas without mental rescaling afterward. Prefer this capability when you already have scalar I and r and only need magnitude; if your source is a word problem about two parallel wires, compute each wire’s B first or use a force-between-wires tool.
Round-trip checks are easy: recompute two times ten to the minus seven times absolute I over r by hand and confirm it equals the published B within the same twelve-decimal rounding, and confirm that flipping only the sign of I leaves B unchanged while changing r inversely scales the field.
What you can do with it
Homework checks for Ampère’s law wire field
Students enter current and radial distance from textbook problems and compare hand-written B magnitude against a deterministic result before submitting.
Lab pre-flight for power-line or bus-bar estimates
Technicians estimate field magnitude at a working distance from a known DC current before placing sensors or setting exposure margins.
FAQ
What is the magnetic field of a long straight wire?
For an infinite straight wire carrying current I, the field magnitude at perpendicular distance r is B = μ₀ |I| / (2 π r). In SI units, I in amperes and r in meters give B in teslas.
What happens when distance is zero?
The classical formula is singular on the wire axis.
Does the sign of the current matter?
For magnitude, no: B uses |I|. Direction follows the right-hand rule and is not returned as a vector by this calculator.
Does this solve finite-length wires or solenoids?
No. It implements only the infinite straight-wire result. Use other tools for finite segments, loops, solenoids, or toroids.
Is the magnetic field straight wire calculator free?
The browser tool is free and runs locally.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/elec/magnetic-field-wire \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"I":10,"r":0.05}'const res = await fetch("https://api.kit.forhosting.com/elec/magnetic-field-wire", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"I": 10,
"r": 0.05
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/elec/magnetic-field-wire",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"I": 10,
"r": 0.05
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/elec/magnetic-field-wire", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"I":10,"r":0.05}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"I":10,"r":0.05}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/elec/magnetic-field-wire", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"I": 10,
"r": 0.05
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "elec.magnetic_field_wire",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_abs | 1000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Distance must be strictly positive: on the wire axis the classical result is singular, so r equals zero fails with invalid_input instead of inventing infinity.
What B = μ₀ I / (2 π r) means for a long straight wire
Prefer SI throughout: convert milliamps, centimeters, and millitesla expectations before or after the call so comparisons stay consistent.
How to call the API and what comes back
Prefer sending numbers rather than pre-formatted strings when you control the client; string numbers are accepted only when they match a strict finite numeric pattern including optional scientific notation. Send a JSON body with two required finite numbers: I (aliases current, i, and amperage) for electric current in amperes, and r (aliases distance, radius, and d) for perpendicular distance from the wire in meters. Absolute values must stay within the published limit of one trillion so intermediate products remain finite in IEEE double precision on the Worker and in the browser. Distance must be strictly greater than zero; values at or below one times ten to the minus fifteen, or any negative length, are rejected as invalid_input. On success the response echoes rounded I and current, r and distance, sets B, magnetic_field, and magnitude to the same non-negative field, formula to the string B equals mu-zero absolute I over two pi r, equation to a human-readable substitution line, mu0 to the rounded permeability, unit_B to T, unit_I to A, unit_r to m, message to a short English summary, and steps to an ordered array of given values, formula, constant, substitution, equivalent form, and summary. Failed validation—missing fields, non-numeric strings, non-finite numbers, values outside absolute limits, zero or negative distance, or a non-finite product—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.
Practical tips, limits, and related searches
When teaching, pair examples: ten amperes at five centimeters yields four times ten to the minus five tesla; the same current with reversed sign leaves magnitude unchanged; doubling distance halves B; and r equals zero demonstrates the hard invalid_input path. This landing targets people searching for a magnetic field straight wire calculator, B equals mu-zero I over two pi r, or Ampère law wire field online; it is not a finite wire-segment integrator, not a solenoid or toroid field tool, and not a Lorentz force calculator on a moving charge. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately set r to zero.
Integration use cases
Unit tests for magnetostatics solvers
Generate known-good wire-field cases plus deliberate r-equals-zero rejections for coding kata expected values.