A solo 401(k) has two parts: the owner's elective deferral and the business contribution. The second part is where most quick spreadsheets go wrong, because for a sole proprietor the contribution reduces the very earnings it is computed from. IRS Publication 560 solves that circularity with a reduced plan rate: rate / (1 + rate), so 25% becomes 20%.

Here is the calculation for one simple case (2026, no W-2 wages, under 50), written so every intermediate value is visible and every rounding is deliberate.

from decimal import Decimal as D, ROUND_HALF_UP, ROUND_FLOOR CENT = D("0.01") SE_BASE = D("0.9235") # net earnings factor for SE tax SE_RATE = D("0.153") # 12.4% SS + 2.9% Medicare (below the wage base) PLAN_RATE = D("0.25") DEFERRAL_LIMIT = D("24500") def solo_401k(net_profit: D) -> dict: se_tax = (net_profit * SE_BASE * SE_RATE).quantize(CENT, ROUND_HALF_UP) half_se = (se_tax / 2).quantize(CENT, ROUND_HALF_UP) net_earnings = net_profit - half_se reduced_rate = PLAN_RATE / (1 + PLAN_RATE) # exactly 0.2 employer = (net_earnings * reduced_rate).quantize(CENT, ROUND_FLOOR) deferral = min(DEFERRAL_LIMIT, net_earnings - employer) return { "se_tax": se_tax, "net_earnings": net_earnings, "employer": employer, "deferral": deferral, "total": employer + deferral, } print(solo_401k(D("90000"))) # se_tax 12716.60, net_earnings 83641.70, employer 16728.34, # deferral 24500, total 41228.34 

Three choices worth copying

  1. Decimal from strings, never floats. 0.9235 * 0.153 in binary floating point is not exact; constructing Decimal("0.9235") keeps the published rate exactly as written.
  2. Round once per step, in a stated direction. SE tax is rounded half-up like a normal amount; the employer contribution is a maximum, so it is floored: never one cent above what is allowed.
  3. Keep intermediate values. net_earnings is stored and reused, not recomputed. When someone asks "where did 16,728.34 come from?", the answer is three lines of output, not a re-derivation.

The wrong shortcut, quantified

90000 * 0.25 = 22500 for the business part. The correct value is 16,728.34. That is a 5,771.66 over-contribution, which has to be found and corrected later.

What this sketch leaves out

A real implementation also needs the social security wage base when there are W-2 wages, the age-based catch-up (60 to 63 get a larger one than 50 to 59), the annual additions limit, and deferrals already made to another employer's plan. Each of those is another explicit step, not a tweak to the formula above.

If you want to check a number against an implementation that includes those steps, there is a free calculator here (no sign-up): https://gettidycents.com/tools/solo-401k-contribution-calculator