finance-business · personal-investing · alternatives-accounts

HSA and 529 Growth with Tax Treatment Calculator

Simulate 100 market futures for yearly contributions to a 529 plan or an HSA inside a seeded, reproducible workbook, and see the range of balances when the money is withdrawn, the tax the contributions save, and how far the account comes out ahead, after tax, of an ordinary taxable account that costs you the same each year. Tax is shown at contribution, on growth and at withdrawal for both. Estimates for education, not advice.

Last updated

Calculator overview

Inputs and outputs

This summary comes from the calculator's published input and output contract.

Inputs

Volatility (standard deviation of yearly returns) (required)
About this input

How much yearly returns swing around the average, as a standard deviation. 0 makes every future identical; a larger figure spreads the futures wider.

Unit % Default 0.12 Range 0 to 0.6
State income tax rate (required)
About this input

Your state income tax rate. A 529 deduction, an HSA deduction and the tax on money used for other things are all worked at this rate. Enter 0 if your state gives no deduction. California and New Jersey do not deduct HSA contributions.

Unit % Default 0.05 Range 0 to 0.2
Largest yearly contribution your state deducts (529) Conditional
When omitted Blank
About this input

The largest yearly 529 contribution your state deducts. Leave blank if your state deducts the whole contribution. Read only for a 529 plan.

Unit $/year Default Not set Range 0 to 1000000000000
Years until the money is withdrawn (required)
About this input

How many yearly contributions are made before the whole balance is withdrawn, at the end of the last year.

Unit years Default 18 Range 1 to 50
Yearly contribution (required)
About this input

What you put in at the start of every year, the same amount each year. For an HSA, the amount you pay in, not counting your employer's share.

Unit $/year Default 6000 Range 0 to 1000000000000
What the money is used for (required)
About this input

Qualified means education costs for a 529 plan and medical care for an HSA. Use 'income tax only' for an HSA after 65 or a 529 withdrawal matched by a scholarship. Otherwise the additional tax applies: 10 percent of a 529 plan's earnings, or 20 percent of the whole HSA withdrawal.

Default Qualified expenses Allowed Qualified expenses, Other use, income tax only, Other use, income tax and additional tax
Random seed
When omitted Blank
About this input

The starting number of the workbook's random-number generator. The same seed and inputs always give the same result; change it to see how much the answer moves from sampling alone. Leave blank for 42, the seed of the published examples.

Default Not set Range 1 to 2147483646
Dividend yield of the investments (required)
About this input

The part of the yearly return paid out as dividends. In the taxable account it is taxed every year; the rest of the growth is taxed only when it is sold.

Unit % Default 0.015 Range 0 to 0.2
Tax rate on dividends and long-term gains (required)
About this input

Federal plus state rate on qualified dividends and long-term capital gains in the taxable account.

Unit % Default 0.15 Range 0 to 0.5
Account (required)
About this input

The account you are saving in. A 529 plan pays for education; an HSA pays for medical care and needs a high-deductible health plan.

Default 529 plan Allowed 529 plan, HSA
Payroll tax saved on contributions (HSA) Conditional
When omitted Blank
About this input

7.65% when you contribute through your employer's payroll plan below the Social Security wage base, 1.45% above it, and blank or 0 when you pay in directly. Read only for an HSA.

Unit % Default Not set Range 0 to 0.2
Federal marginal income tax rate (required)
About this input

The federal rate on your next dollar of income. An HSA contribution is deducted at this rate, and money taken out for other uses is taxed at it.

Unit % Default 0.22 Range 0 to 0.6
Expected yearly return (average) (required)
About this input

The average yearly return you assume, after fund fees, as an arithmetic mean. Each simulated year draws a growth whose expected value matches this figure.

Unit % Default 0.06 Range -0.2 to 0.3

Outputs

90th-percentile balance when withdrawn
About this output

The balance when the money is withdrawn that 90 percent of futures fall below; only 1 future in 10 does better.

Unit $
Share of futures where the account comes out ahead Conditional
About this output

The share of simulated futures in which the account, after tax, ends above the taxable account. Shown when the money is used for something other than qualified expenses; for qualified expenses the account cannot fall behind.

Unit %
Next seed in the same stream
About this output

A new seed from the same generator, the start of the next unused stretch of its sequence. Each press of Run simulation enters it first, so a new run draws fresh futures that do not overlap these.

No unit declared
10th-percentile balance when withdrawn
About this output

The balance when the money is withdrawn that 10 percent of futures fall below.

Unit $
Seed used
About this output

The seed this result used: your entry, or 42 when left blank. Enter it again to reproduce this result exactly.

No unit declared
Tax at each point, average over the simulated futures
About this output

Tax paid at contribution, on growth and at withdrawal, averaged over the simulated futures, for the taxable account and the tax-advantaged account, with the total. A negative figure is tax saved. The table behind the tax chart.

No unit declared
Futures simulated
About this output

The number of futures this result simulated: always 100.

Unit trials
Workbook self-check
About this output

PASS when the workbook's built-in consistency checks hold for this result: the generator's counts and range, the ordering of the percentiles, the account never ending below the taxable account, the tax totals and the wiring of the tables. FAIL means the result should not be trusted; please report it.

No unit declared
Total paid into the taxable account
About this output

Everything paid into the comparison taxable account: each year's contribution less the tax the account's contribution saves, so both cost you the same out of pocket.

Unit $
Model Status
About this output

Whether the inputs describe a plan the workbook can simulate, any result to notice, or OK. The NOT VALID and CHECK reasons are listed in the methodology.

No unit declared
Tax saved on contributions
About this output

The tax the contributions save over all the years: the federal, state and payroll tax on HSA contributions, or the state deduction on 529 contributions up to your state's limit.

Unit $
After-tax advantage at the average return
About this output

The after-tax advantage over the taxable account if every year earned exactly the average return.

Unit $
Balances by year
About this output

Account balances by year at the 10th, 25th, 50th, 75th and 90th percentiles of the simulated futures, and what was paid in to date. The table behind the balance chart.

No unit declared
Total paid into the account
About this output

Everything paid into the account: the yearly contribution times the years.

Unit $
Balance at the average return
About this output

Where the account ends if every year earned exactly the average return, with no ups and downs. It usually sits above the median, because losses in bad years compound.

Unit $
Median after-tax value of the taxable account
About this output

The middle value of the comparison taxable account after the tax on its sale.

Unit $
Median balance when the money is withdrawn
About this output

The middle balance when the money is withdrawn: half the simulated futures end above it and half below.

Unit $
Median after-tax advantage over a taxable account
About this output

The middle of the after-tax advantage over the simulated futures: the account after the tax due on withdrawal, less an ordinary taxable account that cost you the same each year, after its taxes. Negative means the taxable account comes out ahead.

Unit $
Median after-tax value of the account
About this output

The middle value of the account after the tax due when the money is withdrawn.

Unit $
This page is provided by LogicCommons for informational purposes only. Results are model outputs computed from the inputs you supply and are not financial, investment, tax, accounting, or legal advice, and no advisory relationship is created. Verify all inputs and results independently before relying on them in any decision.

LogicCommons is in beta. If a result, label, or reference looks wrong, tell us here; we read every message.

Methodology

Purpose and model boundary

This calculator compares a 529 plan or an HSA with an ordinary taxable account that costs you the same amount out of pocket each year. It simulates 100 possible sequences of yearly market returns. The main result is the median account balance when the money is withdrawn; the page also shows the tax saved on contributions, the median after-tax advantage and the taxes paid or saved at contribution, during growth and at withdrawal.

For a single steady-return projection instead, use the College Savings 529 Planner or the HSA Savings and Tax Benefit Calculator. Those calculators answer different questions and do not simulate market-return sequences.

The model is educational. It is not a prediction of returns or tax law, and it is not financial, investment, tax or legal advice.

Inputs and units

Choose one account, a level yearly contribution, the number of years until withdrawal, an expected return and its volatility, your tax rates, and whether the withdrawal is for qualified expenses. The contribution goes in at the start of each year. The whole balance comes out at the end of the last year. The state deduction cap applies only to a 529 plan; the optional payroll-tax rate applies only to an HSA. Blank cap means the full 529 contribution is eligible for the model's state deduction, and blank payroll rate means no payroll saving.

The workbook always runs 100 futures. Its optional seed defaults to 42 for the worked examples. On the page, Simulate uses the last result's next seed before a repeated run, while the first run after a worked example or Reset uses that example's seed. API and MCP callers can supply a seed to reproduce a run.

Governing relationships

One seeded generator gives each future a separate part of its stream. Each draw becomes a yearly lognormal growth factor matched to the entered expected return and volatility. The same year's return is applied to the chosen and taxable accounts within a future.

The taxable account receives the yearly contribution minus the chosen account's contribution-tax saving. Its dividends are taxed each year. Remaining gain is taxed when the account is sold at withdrawal; the model does not tax a loss as a gain. The chosen account's qualified withdrawal has no modeled withdrawal tax. For other uses, the model applies the entered income-tax rates and, when selected, the additional tax applicable to that account. A 529 plan's non-qualified withdrawal tax applies to earnings, while an HSA's applies to the whole withdrawal.

Calculation sequence

The workbook calculates 100 futures, then derives the year-by-year percentiles, medians, tax totals and after-tax comparison. A repeated Simulate action uses the last result's next seed before the new run.

Outputs and interpretation

The account-balance chart shows the 10th, 25th, median, 75th and 90th percentiles by year, plus what was contributed to date. The tax chart shows average tax across futures at each of the three points; a bar below zero means tax saved. Its table includes a total row. These averages add across points, whereas the headline account balance and advantage are medians across futures.

Validation and status logic

The workbook evaluates the conditions below from top to bottom and returns the first matching status. This is the workbook's priority order, including warnings that may accompany a computed result.

Priority Condition Returned status
1 Account is not one of the supported choices NOT VALID: choose the account, 529 plan or HSA
2 Withdrawal use is not selected NOT VALID: choose what the money is used for when it is withdrawn
3 Years are not a whole number in the supported interval NOT VALID: the years until the money is withdrawn must be a whole number from 1 to 50
4 A supplied seed is not a whole number in the supported interval; blank uses the published default 42 NOT VALID: the random seed must be a whole number from 1 to 2,147,483,646
5 Contribution is outside the supported amount interval, or the account is a 529 plan and its supplied state deduction cap is outside that interval NOT VALID: the yearly contribution and the state deduction limit must be amounts from 0 to 1 trillion dollars
6 Expected return is outside the supported interval NOT VALID: the expected return must be between -20% and 30% a year
7 Volatility is outside the supported interval NOT VALID: volatility must be between 0% and 60% a year
8 Federal marginal rate is outside the supported interval NOT VALID: the federal marginal tax rate must be between 0% and 60%
9 State income tax rate is outside the supported interval NOT VALID: the state income tax rate must be between 0% and 20%
10 The account is an HSA and its supplied payroll tax rate is outside the supported interval NOT VALID: the payroll tax rate must be between 0% and 20%
11 Dividend yield is outside the supported interval NOT VALID: the dividend yield must be between 0% and 20% a year
12 Tax rate on dividends and gains is outside the supported interval NOT VALID: the tax rate on dividends and gains must be between 0% and 50%
13 There is no yearly contribution to simulate NOT VALID: there is nothing to simulate; enter a yearly contribution above 0
14 The 100-future simulation did not complete NOT VALID: the simulation did not complete; this is a defect in the workbook, please report it
15 The workbook's self-check fails CHECK: the self-check of the workbook failed for this result, so do not rely on it; please report it
16 Volatility is zero CHECK: volatility is 0, so every simulated future is the same and every percentile is equal
17 The chosen account is an HSA and yearly contribution exceeds the dated 2026 upper-limit figure CHECK: the yearly contribution is above 9,750 dollars, the largest HSA limit for 2026 (family coverage with the catch-up from age 55), so an HSA could not hold all of it
18 None of the preceding conditions applies OK

NOT VALID is a refusal, not a numeric answer. CHECK may accompany a computable result but calls for the stated review. The self-check is separately reported as arithmetic-integrity evidence; it does not replace this ordered status chain.

Assumptions and limitations

Balances are nominal. The model uses one flat return distribution and flat tax rates, with no starting balance, changing yearly contribution, employer HSA contribution, multi-year withdrawal, fund-fee input or changing tax law. Enter an expected return after fund fees. It does not model recapture of state 529 deductions, California or New Jersey tax on HSA growth, 529 rollovers, or state credits in place of deductions. A CHECK on an HSA contribution compares it with a dated 2026 upper-limit figure; it is not a personal eligibility determination.

Restrictions and non-computing states

This calculator enforces its numeric and choice limits before it accepts a result. An irrelevant optional tax input does not turn an otherwise valid scenario into NOT VALID; a retained seed remains part of every simulation.

Errors and warnings

A request rejected by the page's input limits is not a computed result. A transport or service failure cannot establish a fresh workbook answer. Review the workbook's References and Disclaimer and current tax rules with a qualified professional before using a result for a real decision.

References

Sources and further reading

The model's amounts, rates and return assumptions come from the inputs, not market data. The workbook's References sheet identifies the calculation sources and dates its statutory constants. The links below explain those rules; they do not endorse this calculator.

  • The IRS 529 education-savings guidance explains qualified education expenses and tax treatment of distributions. The model distinguishes qualified use from other withdrawals and taxes only the earnings portion of a non-qualified 529 withdrawal.
  • IRS Publication 969 explains HSA contributions and distributions, including the additional tax on distributions not used for qualified medical expenses and its exceptions.
  • Revenue Procedure 2025-19 gives the 2026 HSA contribution limits used for the workbook's advisory CHECK. Eligibility and an individual's limit depend on circumstances not all entered here.
  • S. K. Park and K. W. Miller, “Random number generators: good ones are hard to find,” Communications of the ACM 31(10), 1988, and the Park–Miller–Stockmeyer 1993 correspondence describe the generator family. The workbook uses multiplier 48,271 and modulus 2³¹ − 1.
  • The NIST/SEMATECH e-Handbook's lognormal distribution section and Microsoft Support's NORM.S.INV and PERCENTILE.INC documentation describe the distribution and percentile functions used by the workbook.

This is an educational estimate, not financial, investment, tax or legal advice. Tax rules can change; check current rules and your circumstances with a qualified professional.

Results are informational and not professional advice. See our Terms of Use. Powered by SpreadsheetWeb · About · Privacy · Terms