DEV Community

Ümitvar
Ümitvar

Posted on

How to Calculate UK Income Tax for 2025/26 (With Free Tools for Developers)

If you're a developer living or working in the UK — or building a fintech/payroll app — understanding how HMRC calculates income tax is essential. In this post, I'll break down the 2025/26 UK tax system and show you how to implement the logic in JavaScript.

UK Income Tax Bands for 2025/26

The UK uses a progressive tax system. For the 2025/26 tax year, the rates are:

Band Taxable Income Rate
Personal Allowance Up to £12,570 0%
Basic Rate £12,571 – £50,270 20%
Higher Rate £50,271 – £125,140 40%
Additional Rate Over £125,140 45%

Note: The Personal Allowance is reduced by £1 for every £2 earned over £100,000.

National Insurance (NI) — Don't Forget This

Income tax is only part of the picture. Employees also pay National Insurance:

  • 12% on earnings between £12,570 and £50,270
  • 2% on earnings above £50,270

This significantly reduces your take-home pay, so any salary calculator must include NI.

Implementing a Basic UK Tax Calculator in JavaScript

Here's a simple function to calculate income tax:

function calculateUKTax(grossSalary) {
  let tax = 0;

  if (grossSalary <= 12570) {
    tax = 0;
  } else if (grossSalary <= 50270) {
    tax = (grossSalary - 12570) * 0.20;
  } else if (grossSalary <= 125140) {
    tax = (50270 - 12570) * 0.20 + (grossSalary - 50270) * 0.40;
  } else {
    tax = (50270 - 12570) * 0.20 + (125140 - 50270) * 0.40 + (grossSalary - 125140) * 0.45;
  }

  return tax;
}

console.log(calculateUKTax(35000)); // £4,486
console.log(calculateUKTax(60000)); // £11,432
Enter fullscreen mode Exit fullscreen mode

Adding National Insurance

function calculateNI(grossSalary) {
  let ni = 0;

  if (grossSalary <= 12570) {
    ni = 0;
  } else if (grossSalary <= 50270) {
    ni = (grossSalary - 12570) * 0.12;
  } else {
    ni = (50270 - 12570) * 0.12 + (grossSalary - 50270) * 0.02;
  }

  return ni;
}

function takeHomePay(grossSalary) {
  const tax = calculateUKTax(grossSalary);
  const ni = calculateNI(grossSalary);
  return grossSalary - tax - ni;
}

console.log(takeHomePay(40000)); // ~£30,380
Enter fullscreen mode Exit fullscreen mode

Verifying Your Results

When building or testing payroll logic, it's really helpful to cross-check your calculations against a trusted reference. I've been using UK Calculator — it covers tax, salary, NI, mortgage, stamp duty and 200+ other calculators, all updated with the latest 2025/26 HMRC rates. Free, no signup required.

It's handy for sanity-checking your code output, especially edge cases like:

  • Salaries right at the £50,270 boundary
  • High earners where the Personal Allowance tapers off
  • Employer NI calculations

Employer NI

If you're building an HR or payroll tool, don't forget employer-side NI:

function calculateEmployerNI(grossSalary) {
  const threshold = 5000; // Secondary threshold for 2025/26
  if (grossSalary <= threshold) return 0;
  return (grossSalary - threshold) * 0.138; // 13.8%
}
Enter fullscreen mode Exit fullscreen mode

The employer NI secondary threshold dropped significantly in 2025, increasing costs for businesses. Make sure your app uses the updated figure.

Key Takeaways

  • Always separate income tax and National Insurance — they're different calculations
  • The Personal Allowance taper above £100k adds complexity to your logic
  • Use tools like ukcalculator.com to verify edge cases quickly
  • Keep your rates updated — HMRC changes thresholds almost every April

What Are You Building?

Are you working on a payroll app, salary comparison tool, or just trying to understand your own tax bill? Drop a comment below — happy to help debug or review your implementation.

Top comments (0)