Solenoid magnetic field calculator
1000 turns per metre carrying 2 A produce about 2.513 mT inside a long ideal solenoid. Enter the turn density and the current to get the interior field in tesla, from mu zero times n times I. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Turns per metre
- 1,000
- Current
- 2
- Magnetic field
- 0.0025132741 T
- Mu0
- 0.0000012566
- Precision
- 10
This solenoid magnetic field calculator returns the magnetic flux density B inside a long ideal solenoid from the winding turn density n in turns per metre and the current I in amperes. The textbook closed form is fully deterministic: B equals mu zero times n times I, where mu zero is four pi times ten to the minus seven henries per metre. With SI inputs the result is reported in tesla. Classic checks you may already know include one thousand turns per metre at two amperes giving roughly two point five one three millitesla, and any finite n at zero current giving exactly zero field. The engine uses only finite arithmetic with no network calls, no sampling, and no date-dependent shortcuts.
What the ideal solenoid formula means and what you get
A long ideal solenoid is modeled as a tightly wound helical coil whose length is much greater than its radius, so the magnetic field is approximately uniform inside the bore and negligible outside, ignoring fringing at the ends. Ampere's law applied to a rectangular Amperian loop that pierces n L turns of current I yields B times L equals mu zero times n L times I, which cancels to the compact product B equals mu zero times n times I.
Here n is the number of turns per unit length, not the total turn count: if you only know total turns N and length L in metres, form n equals N over L first, then call this calculator. Mu zero is fixed at four pi times ten to the minus seven in the same SI convention used by most introductory electromagnetism textbooks.
Where solenoid field calculations fit in study, lab, and product work
Students meet the long-solenoid formula when a textbook moves from Ampere's law to practical coil design, when a lab asks for the expected B before measuring with a Hall probe, or when a contest problem gives n and I and demands the interior field without calculus. Teachers can pre-generate answer keys for modest turn densities and currents without trusting opaque calculator apps that silently switch units from tesla to gauss.
Developers call the same contract from scripts to seed deterministic test vectors for magnetostatics demos, to normalize user-entered coil specs before UI plots, or to satisfy programming-challenge statements that demand B in tesla rather than a hand-waved sketch. Contest practice often needs a fast, offline source of ideal-solenoid values so solutions can be checked without graphing calculators under time pressure. Product and education tools use the product when a learner types turns per metre and amperes and the UI must show B and a clean formula reminder.
Pair it with capacitor-energy or power tools when you are building a small lab of free, deterministic electromagnetism helpers.
What you can do with it
Homework and lab checks
Compute B = μ₀ n I for textbook solenoids and verify Hall-probe expectations before or after lab measurements.
Coil design and tutoring software
Normalize user-entered turn density and current into interior B for design sketches, lessons, and interactive demos.
FAQ
What does the solenoid magnetic field calculator cost?
It is free in your browser on this page.
How is B defined for a long solenoid?
For an ideal long solenoid, B = μ₀ · n · I, where n is turns per metre, I is current in amperes, and μ₀ = 4π × 10⁻⁷ H/m. The result is in tesla when n and I are SI.
Is n total turns or turns per metre?
Turns per metre. If you know total turns N and length L in metres, set n = N / L first, then compute B = μ₀ n I.
Does this include finite-length end effects?
No. It uses the infinite-solenoid approximation only. Short coils and fringing fields need a different model (Biot-Savart or finite-solenoid formulas).
Does the coil's diameter change the field?
Not in this model. Inside a long ideal solenoid the field depends only on the turns per metre and the current; the radius matters only because the coil must be much longer than it is wide.
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/solenoid-field \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"turns_per_metre":1000,"current":2}'const res = await fetch("https://api.kit.forhosting.com/elec/solenoid-field", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"turns_per_metre": 1000,
"current": 2
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/elec/solenoid-field",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"turns_per_metre": 1000,
"current": 2
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/elec/solenoid-field", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"turns_per_metre":1000,"current":2}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"turns_per_metre":1000,"current":2}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/elec/solenoid-field", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"turns_per_metre": 1000,
"current": 2
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "elec.solenoid_field",
"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_n | 1000000000000000 |
max_abs_i | 1000000000000000 |
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
Negative current is rejected with invalid_input so a signed sensor reading cannot silently flip the reported magnitude under this model.
What the ideal solenoid formula means and what the response contains
This page returns the normalized turns_per_metre and current, the magnetic_field B rounded to the requested precision, the constant mu0 used, a method tag solenoid_field, the precision, a human-readable formula string, and the unit T for tesla. There is no finite-element path and no random sampling of coil geometry: the engine either multiplies the three factors inside the supported magnitude range or rejects the input with invalid_input. Rejected cases include missing n or I, non-finite values, magnitudes above the documented ceiling, negative turn density, and negative current.
How n and I are read and how B stays reproducible
Optional leading plus signs and scientific notation on numeric strings are allowed when they parse as finite decimals; embedded spaces, hex prefixes, and non-numeric tokens are rejected with a clear message so a bad cell does not become a wrong tesla value. Zero for either input is valid and simply yields zero magnetic field. Negative turns per metre is likewise rejected as non-physical for this model. The preferred fields are turns_per_metre for the linear turn density and current for the winding current, but aliases n, turns_per_meter, turn_density, and N_per_m for the density, and I, i, amperes, and amps for the current are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. Negative current is always rejected with invalid_input: this calculator treats I as a non-negative magnitude for the ideal B equals mu zero n I product; reverse the physical winding sense outside the request rather than sending a signed ampere value. An optional precision field, with aliases decimals and dp, chooses how many decimal places to expose for the numeric outputs, defaulting to ten and capped at fifteen so JSON goldens stay stable. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing the vacuum-permeability constant yourself.
Where solenoid field calculations fit in study, lab, and product work
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.
Integration use cases
Deterministic test fixtures
Generate reproducible magnetic_field values for unit tests, property checks, and CI assertions on magnetostatics code.
Technical questions
What happens if current is negative?
The input is rejected with invalid_input. This calculator requires non-negative current; use the magnitude of I and handle winding sense outside the request.