ukmoneycalc 0.1.0
A small, dependency-free D library for UK take-home-pay math (2025/26): income tax with the personal-allowance taper, Class 1 National Insurance, student-loan repayments, and a full gross-to-net breakdown.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
ukmoneycalc
A small, dependency-free D library for UK take-home-pay math — the deductions that turn a gross salary into the net figure that lands in your bank account, for the 2025/26 tax year (England / Northern Ireland).
It computes each PAYE deduction from first principles: income tax with the personal-allowance taper, Class 1 employee National Insurance, and student-loan repayments — then sums them into a full gross → net breakdown.
The thresholds and worked examples mirror the model used at ukmoneycalc.com.
Why
Take-home pay is not just "salary minus a tax rate". Three independent charges stack on top of each other, each with its own thresholds:
net = gross − income tax − National Insurance − student loan
The awkward parts are the personal-allowance taper (you lose £1 of the £12,570 allowance for every £2 earned over £100,000, so the marginal rate spikes to 60% in that band) and the two-rate NI structure. This library handles both exactly.
Install
Add it to your dub.json:
"dependencies": {
"ukmoneycalc": "~>0.1.0"
}
Usage
import ukmoneycalc;
import std.stdio;
void main()
{
auto t = takeHome(60_000, StudentLoanPlan.plan2);
writeln("gross: ", t.gross); // 60000
writeln("income tax: ", t.incomeTax); // ~11,432
writeln("NI: ", t.nationalInsurance); // ~3,210.60
writeln("student loan: ", t.studentLoan); // ~2,837.70
writeln("net / year: ", t.net);
writeln("net / month: ", t.netMonthly);
writeln("deducted: ", t.effectiveRate); // fraction of gross
}
API
| Symbol | Description |
|---|---|
personalAllowance(gross) | Tax-free allowance (£12,570), tapered £1 per £2 over £100k, gone by £125,140. |
incomeTax(gross) | 2025/26 income tax: 20% / 40% / 45% on taxable income. |
nationalInsurance(gross) | Class 1 employee NI: 8% to £50,270, 2% above. |
studentLoan(gross, plan) | Plan 1 / 2 / 4 / 5 (9%) or Postgraduate (6%) repayment above threshold. |
takeHome(gross, plan = none) | Full TakeHome breakdown: tax, NI, loan and net. |
TakeHome.netMonthly | Net annual pay ÷ 12. |
TakeHome.effectiveRate | (gross − net) / gross as a fraction. |
2025/26 thresholds
| Item | Value |
|---|---|
| Personal allowance | £12,570 (tapers over £100,000) |
| Basic rate (20%) | first £37,700 of taxable income |
| Higher rate (40%) | up to £125,140 |
| Additional rate (45%) | above £125,140 |
| NI primary threshold | £12,570 |
| NI upper earnings limit | £50,270 |
| NI rates | 8% then 2% |
Worked example: a £30,000 salary pays £3,486 income tax and £1,394.40 NI, leaving £25,119.60 net (~£2,093/month), an effective deduction of ~16.3%.
Build & test
dub build
dub test
Requires a D compiler (DMD or LDC) and DUB. Every public
function is @safe pure and the package has no dependencies.
License
MIT — see LICENSE.
- 0.1.0 released 8 hours ago
- theluckystrike/ukmoneycalc-d
- ukmoneycalc.com
- MIT
- Copyright © 2026, ukmoneycalc
- Authors:
- Dependencies:
- none
- Versions:
-
Show all 2 versions0.1.0 2026-Jul-16 ~main 2026-Jul-16 - Download Stats:
-
-
1 downloads today
-
1 downloads this week
-
1 downloads this month
-
1 downloads total
-
- Score:
- 0.0
- Short URL:
- ukmoneycalc.dub.pm