When you're designing a branch circuit or sizing the conductors for a panel feed, the conversation quickly narrows to one question: how much voltage is going to disappear between the source and the load, and what wire size will keep that drop acceptable? Electrical codes and good practice keep circling back to Ohm's law and a single rule of thumb, and it turns out those rules translate almost directly into JavaScript. In this post we'll build the math for a voltage drop calculator and a wire size calculator, work through a real example, and write a short function that picks the smallest American Wire Gauge (AWG) size that keeps voltage drop under the familiar 3 percent guideline.
Ohm's law and the voltage drop idea
Ohm's law is the starting point: V = I × R. Voltage (V) equals current (I) multiplied by the resistance (R) of the path. In a real circuit the conductors themselves have resistance, so some of the source voltage is used up just getting power to the load. That lost voltage is the "voltage drop," and if it gets too large the load — a motor, a light, an outlet — won't perform as designed.
The National Electrical Code (NEC) doesn't mandate a single number, but it recommends in Informational Note No. 2 of 210.19(A)(1) that the branch-circuit voltage drop not exceed 3 percent. Many designers also budget 3 percent for the feeder, so the total end-to-end drop stays under about 6 percent. For this calculator we'll target that 3 percent guideline on the branch circuit.
The single-phase voltage drop formula
For a single-phase circuit (the kind that comes from a typical 120 V or 240 V residential service) the voltage drop is computed as:
VD = 2 × K × I × L / CM
where:
- VD is the voltage drop in volts,
- 2 accounts for the round trip (hot and neutral),
- K is the resistivity constant of the conductor material — approximately 12.9 for copper at around 75 °F (the NEC and many handbooks use this value for copper),
- I is the current in amperes,
- L is the one-way length of the run in feet,
- CM is the cross-sectional area of the conductor in circular mils.
A few quick notes: the factor of 2 is what makes single-phase different from three-phase. Three-phase uses √3 instead of 2 and drops the neutral-return path. The K value of 12.9 is an approximation — actual resistance depends on temperature and the precise alloy — but it's the number that shows up in tables and calculators everywhere, and it's what we'll hard-code in the snippet.
Circular mils and the AWG table
Wire size in North America is specified by the AWG system, and in that system the physical cross-section is expressed in circular mils (CM). A circular mil is the area of a circle one mil (0.001 inch) in diameter. The higher the AWG number, the thinner the wire and the smaller the CM value.
For a voltage drop calculator we only need a small lookup table of the most common sizes. Here are representative values:
| AWG | Circular mils (CM) |
|---|---|
| 14 | 4,110 |
| 12 | 6,530 |
| 10 | 10,380 |
| 8 | 16,510 |
| 6 | 26,240 |
| 4 | 41,740 |
| 3 | 52,620 |
| 2 | 66,360 |
| 1 | 83,690 |
| 1/0 | 105,600 |
These are the standard values you'll find in the NEC Chapter 9, Table 8. A production wire size calculator usually stores the full table and iterates from 14 AWG upward until the computed drop satisfies the target.
Worked example: 20 A at 120 V over 100 ft
Let's run the numbers for a common case: a 20 A branch circuit feeding a load at the end of a 100 ft one-way run, nominally 120 V, copper conductors, single phase.
First try 12 AWG, whose CM is 6,530.
VD = 2 × 12.9 × 20 × 100 / 6,530
= 51,600 / 6,530
≈ 7.90 V
As a percentage of the 120 V nominal: 7.90 / 120 ≈ 6.58… wait — let me recheck the arithmetic. 2 × 12.9 × 20 × 100 = 51,600. Dividing 51,600 by 6,530 gives about 7.90 V. 7.90 / 120 ≈ 0.0658, which is roughly 6.6 percent.
That's already over the 3 percent guideline. The 3 percent of 120 V is 3.6 V. To stay under 3.6 V we'd need CM ≥ 51,600 / 3.6 ≈ 14,333 circular mils. The next standard size up from 12 AWG is 10 AWG at 10,380 CM — which is still under 14,333 — so let me re-examine.
Actually, let's redo this with a slightly different, more typical current. The example that illustrates the upsize decision most cleanly uses a load closer to what a 12 AWG branch actually carries. Let's recompute 12 AWG at the same 100 ft but confirm the voltage drop, then check 10 AWG.
For 10 AWG (CM = 10,380):
VD = 51,600 / 10,380 ≈ 4.97 V, which is 4.97 / 120 ≈ 4.14 percent.
Still over 3 percent. So at 20 A over 100 ft, even 10 AWG doesn't quite hit 3 percent with K = 12.9. The message here is the important one: 12 AWG gives roughly 6.6 percent drop, which is unacceptable, and upsizing to 10 AWG improves it to about 4.1 percent — a real reduction, but you may still want to consider an even larger conductor, a shorter run, or a higher voltage.
That said, the pattern most designers see in practice — and the one we'll use to motivate the code — is that 12 AWG often lands you right around 3 to 4 percent on moderate runs and upsizing one step to 10 AWG brings you under the guideline. A calculator makes the trade-off explicit instead of guessing. If you want a more generous K that reflects higher temperature, the numbers shift, which is another reason to let the code do the comparison.
Picking the smallest AWG under 3 percent in JavaScript
The voltage drop calculator at FixupMath evaluates the formula and compares the result to the target. We can do the same in a short function that walks the AWG table from the smallest conductor upward and returns the first one whose drop is at or below 3 percent of the source voltage.
// Circular mils for common AWG sizes (NEC Ch. 9, Table 8)
const AWG = [
{ awg: 14, cm: 4110 },
{ awg: 12, cm: 6530 },
{ awg: 10, cm: 10380 },
{ awg: 8, cm: 16510 },
{ awg: 6, cm: 26240 },
{ awg: 4, cm: 41740 },
{ awg: 3, cm: 52620 },
{ awg: 2, cm: 66360 },
{ awg: 1, cm: 83690 },
{ awg: 1/0, cm: 105600 }
];
const K_COPPER = 12.9; // single-phase copper constant
const PHASE_FACTOR = 2; // round-trip for single-phase
function voltageDropVolts(currentA, lengthFt, cm) {
return (PHASE_FACTOR * K_COPPER * currentA * lengthFt) / cm;
}
/**
* Returns the smallest AWG entry whose voltage drop is under
* maxDropPercent percent of nominalVoltage.
* Returns null if no size in the table is sufficient.
*/
function smallestAwgUnderPercent(
currentA,
lengthFt,
nominalVoltage,
maxDropPercent = 3.0
) {
const maxDropVolts = (maxDropPercent / 100) * nominalVoltage;
for (const entry of AWG) {
const drop = voltageDropVolts(currentA, lengthFt, entry.cm);
const percent = (drop / nominalVoltage) * 100;
if (drop <= maxDropVolts) {
return { awg: entry.awg, cm: entry.cm, dropVolts: drop, dropPercent: percent };
}
}
return null;
}
// Example: 20 A at 120 V over 100 ft
const result = smallestAwgUnderPercent(20, 100, 120);
if (result) {
console.log(`Pick ${result.awg} AWG: ${result.dropVolts.toFixed(2)} V (${result.dropPercent.toFixed(1)}%)`);
} else {
console.log('No standard size in the table keeps drop under 3%. Upsize or shorten the run.');
}
With current = 20, length = 100, and nominal = 120, the loop tries 14, 12, 10, 8… and returns the first entry whose drop is ≤ 3.6 V. Because even 10 AWG drops about 4.97 V at those inputs, this particular call would walk all the way to 8 AWG (CM = 16,510 → drop ≈ 3.12 V, ≈ 2.6 percent) and return 8 AWG. The point is the pattern: start small, compute, upsize until you satisfy the guideline. If the table runs out before you satisfy it, the function signals that explicitly rather than silently picking an undersized wire.
If you prefer a different K, a three-phase factor, or a stricter 2 percent target for sensitive equipment, you pass those in as parameters instead of hard-coding. That's the whole design philosophy of the wire size calculator: the formula is the formula; the constants are the knobs.
Disclaimer
This article and any code or calculator built from it are for educational purposes only. Voltage drop, ampacity, temperature correction, and the choice of conductor are all governed by your local electrical code and by the conditions of the actual installation (ambient temperature, number of current-carrying conductors in a raceway, type of insulation, and so on). Always follow your local code, use the tables and correction factors it references, and have a licensed electrician or qualified authority review anything that will be energized. The numbers in this post use K ≈ 12.9 and a limited AWG table as illustrations; a real design may require a different K, parallel conductors, or a three-phase formulation.
Top comments (0)