How the United States take-home pay calculator is verified

Inputs

InputFieldType
Gross annual salary (USD)grossAnnualnumber

The formula

Each derived value below is computed by the Valem engine from the expression shown, in this order. Nothing else runs — there is no hidden code path.

Derived valueFieldFormula (JSONata)
Taxable (after standard deduction)taxable($b := grossAnnual - $const.standardDeduction; $round($b > 0 ? $b : 0, 2))
Federal income taxfederalTax($t := taxable; $round((($t < 12400 ? $t : 12400) * 0.10) + (($t > 12400 ? (($t < 50400 ? $t : 50400) - 12400) : 0) * 0.12) + (($t > 50400 ? (($t < 105700 ? $t : 105700) - 50400) : 0) * 0.22) + (($t > 105700 ? (($t < 201775 ? $t : 201775) - 105700) : 0) * 0.24) + (($t > 201775 ? (($t < 256225 ? $t : 256225) - 201775) : 0) * 0.32) + (($t > 256225 ? (($t < 640600 ? $t : 640600) - 256225) : 0) * 0.35) + (($t > 640600 ? ($t - 640600) : 0) * 0.37), 2))
Social SecuritysocialSecurity$round((grossAnnual < $const.ssWageBase ? grossAnnual : $const.ssWageBase) * $const.ssRate, 2)
Medicaremedicare$round(grossAnnual * $const.medicareRate + (grossAnnual > 200000 ? (grossAnnual - 200000) * $const.medicareSurcharge : 0), 2)
Net / yearnetAnnual$round(grossAnnual - federalTax - socialSecurity - medicare, 2)
Net / monthnetMonthly$round(netAnnual / 12, 2)

Rates and thresholds

The expressions above read these as $const. They are the figures the annual refresh replaces, so they live as data rather than being written into the formulas — which is what makes a year-on-year change a one-line diff instead of an edit to arithmetic.

ConstantValue
standardDeduction16100
ssWageBase184500
ssRate0.062
medicareRate0.0145
medicareSurcharge0.009

Test vectors (2)

Every case is executed against this model on each build, by the Java engine and independently by a JavaScript one. A mismatch of a single cent fails the build, so the page cannot ship advertising a figure the model no longer produces.

Case 1 — S1 75,000 USD single, no state tax (TX)

given grossAnnual75000
expect taxable58900
expect federalTax7670
expect socialSecurity4650
expect medicare1087.5
expect netAnnual61592.5

Case 2 — S3 250,000 USD — SS cap + Medicare surcharge

given grossAnnual250000
expect federalTax51304
expect socialSecurity11439
expect medicare4075

Sources

Check it yourself — and reuse it

The whole model as JSON — inputs, outputs, formulas, vectors and sources in one re-runnable document.

This model is published under CC BY 4.0: use it, adapt it, build on it, with attribution. The licence covers the model — the expression of each rule and the arrangement of the catalog. The rates and thresholds are law, and nobody licenses those; the sources above are where they come from.

← Back to the United States take-home pay calculator

Built with Valem — a live, verifiable calculator you can fork and embed.