Free video project · Beginner
UK take-home pay calculator 💷
Income tax bands, the personal allowance taper and National Insurance, turned into a calculator that shows what a salary actually takes home and the 62% trap above £100k.
The video is out Tuesday 27 October at 6pm.
The code from the video
# UK take-home pay calculator, 2026/27
# England, Wales and Northern Ireland
ALLOWANCE = 12570
BASIC_BAND = 37700
TOP_RATE_FROM = 125140
def allowance(salary):
if salary <= 100000:
return ALLOWANCE
return max(0, ALLOWANCE - (salary - 100000) / 2)
def income_tax(salary):
taxable = max(0, salary - allowance(salary))
tax = min(taxable, BASIC_BAND) * 0.20
if taxable > BASIC_BAND:
tax += (min(taxable, TOP_RATE_FROM) - BASIC_BAND) * 0.40
if taxable > TOP_RATE_FROM:
tax += (taxable - TOP_RATE_FROM) * 0.45
return tax
def national_insurance(salary):
ni = 0
if salary > 12570:
ni += (min(salary, 50270) - 12570) * 0.08
if salary > 50270:
ni += (salary - 50270) * 0.02
return ni
def take_home(salary):
return salary - income_tax(salary) - national_insurance(salary)
salary = 30000
print(f"Tax: £{income_tax(salary):,.2f}")
print(f"NI: £{national_insurance(salary):,.2f}")
print(f"Take home: £{take_home(salary):,.2f} a year")
print(f"That's £{take_home(salary) / 12:,.2f} a month")
print()
for salary in [25000, 35000, 50000, 60000, 100000, 150000]:
print(f"£{salary:>7,} takes home £{take_home(salary):>9,.0f} £{take_home(salary) / 12:>7,.0f} a month")
print()
extra = take_home(110000) - take_home(100000)
print(f"A £10,000 rise from £100k: you keep £{extra:,.0f}")
print(f"That's {100 - extra / 100:.0f}% gone")
Run it in your browser with nothing to install, right here on this page.
Make it your own
- Add a pension contribution taken before tax and see how much it really costs.
- Add Plan 2 student loan repayments (9% above the threshold).
- Print a table of every £5,000 from £20k to £150k.
Skills: functions, min and max, if, f-string formatting