How to Calculate US Take-Home Pay in JavaScript (2026 Tax Brackets)
If you've ever built a payroll feature or a salary calculator, you know that "take-home pay" is deceptively complex. Federal brackets, FICA taxes, state taxes — each layer has its own rules. In this post, I'll walk through the actual math and show you a clean JavaScript implementation.
Want the answer without the code? Try the free US Paycheck Calculator — no signup, 2026 rates built in.
The layers of US payroll tax
For a typical W-2 employee, gross pay is reduced by:
- Federal income tax — progressive brackets (10% to 37%)
- Social Security — 6.2% on the first $176,100 (2026 wage base)
- Medicare — 1.45% on all wages, plus 0.9% additional Medicare tax above $200,000
- State income tax — varies wildly; some states have none
Federal income tax (single filer, 2026)
const FEDERAL_BRACKETS_SINGLE_2026 = [
{ upTo: 11925, rate: 0.10 },
{ upTo: 48475, rate: 0.12 },
{ upTo: 103350, rate: 0.22 },
{ upTo: 197300, rate: 0.24 },
{ upTo: 250525, rate: 0.32 },
{ upTo: 626350, rate: 0.35 },
{ upTo: Infinity, rate: 0.37 },
];
function federalTax(income, brackets) {
let tax = 0;
let prevLimit = 0;
for (const { upTo, rate } of brackets) {
if (income <= prevLimit) break;
const taxableInBracket = Math.min(income, upTo) - prevLimit;
tax += taxableInBracket * rate;
prevLimit = upTo;
}
return tax;
}
FICA taxes
function ficaTax(grossPay) {
const socialSecurity = Math.min(grossPay, 176100) * 0.062;
let medicare = grossPay * 0.0145;
if (grossPay > 200000) {
medicare += (grossPay - 200000) * 0.009;
}
return socialSecurity + medicare;
}
Putting it together
function takeHomePay(grossPay, stateTax = 0) {
const federal = federalTax(grossPay, FEDERAL_BRACKETS_SINGLE_2026);
const fica = ficaTax(grossPay);
return grossPay - federal - fica - stateTax;
}
Try it live
The US Paycheck Calculator handles all 50 states with current 2026 rates — free, private, no signup.
Top comments (1)
Nice clean walkthrough. A few of the numbers look like the 2025 figures rather than 2026, which is easy to miss since the 2026 tables came out late:
takeHomePayruns the brackets on gross pay. Federal income tax applies to taxable income, so the standard deduction ($16,100 single for 2026) and pre-tax 401(k) deferrals come off first. FICA still uses gross, since 401(k) deferrals are subject to Social Security and Medicare. Skipping the deduction overstates federal tax by $16,100 times the top rate, so about $1,900 at 12% and $3,500 at 22%.Something like:
If anyone adapts this for 1099 income: the employee FICA piece becomes self-employment tax, 15.3% on 92.35% of net profit (the Social Security part is capped at the same $184,500), and half of it is deducted before income tax. Nothing is withheld either, so that's the part freelancers usually miss when they reuse a paycheck calculator.