DEV Community

Tanzeel abbas
Tanzeel abbas

Posted on

How to Calculate US Take-Home Pay in JavaScript (2026 Tax Brackets)

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:

  1. Federal income tax — progressive brackets (10% to 37%)
  2. Social Security — 6.2% on the first $176,100 (2026 wage base)
  3. Medicare — 1.45% on all wages, plus 0.9% additional Medicare tax above $200,000
  4. 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;
}
Enter fullscreen mode Exit fullscreen mode

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;
}
Enter fullscreen mode Exit fullscreen mode

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;
}
Enter fullscreen mode Exit fullscreen mode

Try it live

The US Paycheck Calculator handles all 50 states with current 2026 rates — free, private, no signup.

Top comments (1)

Collapse
 
keelsheet profile image
Keelsheet •

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:

  • 2026 single brackets are 10% up to $12,400, 12% to $50,400, 22% to $105,700, 24% to $201,775, 32% to $256,225, 35% to $640,600, then 37%. The ones in the snippet (11,925 / 48,475 / 103,350 ...) are 2025's.
  • The 2026 Social Security wage base is $184,500 ($176,100 was 2025).
  • takeHomePay runs 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:

const STANDARD_DEDUCTION_SINGLE_2026 = 16100;

function takeHomePay(grossPay, { preTax401k = 0, stateTax = 0 } = {}) {
  const taxable = Math.max(0, grossPay - preTax401k - STANDARD_DEDUCTION_SINGLE_2026);
  const federal = federalTax(taxable, FEDERAL_BRACKETS_SINGLE_2026);
  const fica = ficaTax(grossPay);
  return grossPay - preTax401k - federal - fica - stateTax;
}
Enter fullscreen mode Exit fullscreen mode

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.