Quick answer: If your employer matches 401(k) contributions, take the full match first, that is free money. After the match, fund an HSA up to the annual limit ($4,400 self-only or $8,750 family in 2026) if you have a qualifying HDHP, because the HSA is the only account with a triple tax advantage: pre-tax in, tax-free growth, tax-free out for medical costs. Then fill a Roth IRA, then go back and finish off the 401(k). If you do not have an HDHP, skip the HSA and go match, then Roth IRA, then 401(k).

Why This Order Is Not Obvious

Most retirement calculators only compare a 401(k) to a Roth IRA and never mention the HSA, because plenty of people cannot use one (you need a qualifying HDHP). That leaves a lot of HSA-eligible people funding accounts in the wrong order and leaving real tax savings on the table every year. The three accounts solve different problems, and stacking them correctly can mean a difference of several hundred dollars a year in tax savings for the exact same amount of money set aside.

HSA vs Roth IRA vs 401(k): The Core Tradeoffs

Each account trades something for something else. Here is the honest comparison, not the marketing version.

Feature HSA Roth IRA 401(k) (traditional)
2026 contribution limit $4,400 self-only / $8,750 family $7,000 ($8,000 age 50+) $23,500 ($31,000 age 50+)
Tax on the way in Pre-tax or deductible After-tax, no deduction Pre-tax
Growth Tax-free Tax-free Tax-deferred
Tax on the way out Tax-free for qualified medical expenses Tax-free after age 59.5 Taxed as ordinary income
FICA (payroll tax) savings Yes, if contributed via payroll No No, FICA still applies
Employer match available Sometimes (employer seed money) Never Common, varies by plan
Eligibility requirement Enrolled in a qualifying HDHP Income limits apply Employer must offer one

Notice the HSA is the only one of the three that skips payroll taxes when your employer runs the contribution through payroll, on top of the income tax break. That is the detail most comparison articles leave out.

Why the HSA Wins on Pure Tax Math

Dollar for dollar, the HSA beats both retirement accounts because it is triple tax-advantaged: the money goes in pre-tax, grows tax-free, and comes out tax-free for medical expenses, with no phase at which the IRS takes a cut if you use it correctly. A Roth IRA gives you two of the three (tax-free growth and tax-free withdrawal), but you already paid income tax on the contribution. A traditional 401(k) gives you two of the three as well (pre-tax in, tax-deferred growth), but every withdrawal in retirement is taxed as ordinary income. We break down the exact math in why the HSA tax break beats both, but the short version: contribute $4,400 to an HSA at a 24% marginal federal rate through payroll, and you save roughly $1,056 in federal income tax plus about $336 in Social Security and Medicare tax (7.65% combined), for a total of close to $1,392 in tax savings on that single contribution. Neither the Roth IRA nor the 401(k) gets you that FICA piece.

What an Employer 401(k) Match Changes About the Order

An employer match overrides every other consideration because it is an immediate, guaranteed return that no investment can match. If your plan matches 50% up to 6% of your salary, that first 6% you contribute is an instant 50% return before the money even touches the market. Skip that and you are turning down free money to optimize for a tax break instead. So the real order is: match first, then HSA, then Roth IRA, then the rest of the 401(k) up to the full annual limit if you have money left to save. If your employer does not match, the HSA moves to the front of the line ahead of any 401(k) contribution, assuming you are HDHP-eligible.

Should You Fund the HSA Before the Roth IRA?

Yes, if you are eligible for both and can only fund one fully this year. The HSA has a smaller contribution limit than the Roth IRA phase-out allows for most earners, so maxing it out first is cheaper and it is the only account of the two that never gets taxed coming out for its intended purpose. A Roth IRA is still excellent (tax-free growth, tax-free withdrawals, no required minimum distributions), but you funded it with money that already paid income tax. The HSA funded the same goal with money that avoided income tax and payroll tax. Once the HSA is maxed, move to the Roth IRA, because at that point you are choosing between “more HSA room” (which does not exist once you hit the IRS cap) and building a second tax-free bucket for non-medical retirement spending.

What If Your Income Is Too High for a Roth IRA, or You Are Not HSA-Eligible?

The Roth IRA has an income phase-out that the HSA and 401(k) do not share, and that changes the order for higher earners. Once your modified adjusted gross income crosses the Roth IRA limit, direct contributions shrink or disappear, while the HSA and 401(k) stay fully available regardless of income (the 401(k) has no income cap at all, and the HSA is only gated by HDHP enrollment, not earnings). If you are phased out of a Roth IRA, the practical order becomes: employer match, HSA to the max, then the 401(k) for the rest, with a backdoor Roth IRA conversion as an optional extra step if your tax situation allows it and you are willing to handle the paperwork. This is one more reason the HSA deserves priority over “just max the Roth IRA,” since it is the one tax-advantaged account almost nobody gets locked out of because they earn too much.

The reverse problem also comes up: not everyone can open an HSA. You need to be enrolled in a qualifying HDHP, have no other disqualifying coverage (a spouse’s non-HDHP family plan, for example, can disqualify you), and not be enrolled in Medicare. If any of that applies to you, drop the HSA step entirely and the order simplifies to employer match first, then Roth IRA up to the limit if your income allows it, then the rest of the 401(k). Do not switch to an HDHP purely to chase the HSA tax break if the higher deductible would strain your monthly budget or if you have a chronic condition that makes frequent medical spending predictable. The HSA is a phenomenal tax tool, but only when the underlying health plan is already the right fit for your medical needs.

HSA vs 401(k): Which Absorbs Extra Savings Better?

Once the match is captured and the HSA is maxed, the 401(k) is usually the next stop simply because of its size. The 2026 limit is $23,500 ($31,000 if you are 50 or older), far larger than what a Roth IRA or HSA can hold. If you are trying to save aggressively (say, more than $15,000 a year across accounts), you will run out of HSA and Roth IRA room quickly and the 401(k) becomes the workhorse. The tradeoff is that 401(k) withdrawals in retirement are taxed as ordinary income, while HSA withdrawals for medical costs are not. That asymmetry is exactly why the order matters: fill the tax-free buckets first, then use the big pre-tax bucket to absorb whatever is left.

Using Your HSA as a Retirement Account, Not Just a Health Wallet

Most people treat their HSA like a debit card for copays and never realize it can function as a second, better IRA. Once you turn 65, non-medical HSA withdrawals are taxed as ordinary income with no 20% penalty, which is functionally identical to a traditional IRA or 401(k) at that point, except every dollar you spend on medical expenses (which is almost guaranteed in retirement) still comes out completely tax-free. We go deeper on the mechanics in using an HSA for retirement. The strategy that makes this work: pay small medical expenses out of pocket now, save the receipts, and let the HSA balance sit and compound for decades. There is no deadline on reimbursing yourself, so a $200 doctor visit today can be “reimbursed” from the HSA 20 years from now, tax-free, after that $200 (invested) has potentially grown many times over.

How to Invest the Money Once It Is In the Account

Cash sitting in an HSA earning close to nothing wastes most of the account’s power. Once you have enough cash cushion to cover your annual deductible ($1,700 self-only or $3,400 family minimum for 2026 HDHPs), invest the rest the same way you would a Roth IRA, in low-cost index funds, and let it compound tax-free for decades. Lively, for example, offers investing through a self-directed Charles Schwab Health Savings Brokerage Account or a hands-off guided portfolio option, so you are not stuck holding cash. We cover the exact steps in investing HSA funds. If your current provider only offers a cash account with no investment option, or charges a monthly fee just to hold your own money, that alone is a reason to look at a no-fee provider. See our full Lively HSA review for how that comparison plays out in practice.

A Worked Example: Splitting $10,000 Across All Three

Say you have $10,000 a year to save, you are 35, single, HDHP-eligible, in the 24% federal bracket, and your employer matches 50% up to 6% of a $70,000 salary ($2,100 in match if you contribute $4,200).

  1. First $4,200 goes to the 401(k) to capture the full $2,100 match. Instant 50% return.
  2. Next $4,400 goes to the HSA (the full 2026 self-only limit). Saves about $1,056 in income tax and $336 in FICA if run through payroll, total tax savings near $1,392.
  3. Remaining $1,400 goes to a Roth IRA. No deduction now, but it grows and comes out tax-free later, and unlike the 401(k) or HSA there is no required minimum distribution to worry about.

Total out-of-pocket cost to you after the match and tax savings is meaningfully less than $10,000, because $2,100 came from the employer and roughly $1,392 came back as reduced taxes. That is the practical payoff of stacking the accounts in this order instead of picking one and ignoring the rest.

Second Example: A Family With a Higher Income

Now say a married couple, both 40, files jointly at a 32% marginal federal rate, has a family HDHP, and can put away $20,000 this year. The wife’s employer matches 100% up to 4% of her $90,000 salary ($3,600 in match if she contributes $3,600).

  1. First $3,600 goes to her 401(k) to capture the full $3,600 match, a 100% instant return.
  2. Next $8,750 goes to the family HSA (the full 2026 family limit). At a 32% marginal rate, that is roughly $2,800 in income tax saved, plus about $669 in FICA if contributed through payroll, for close to $3,469 in combined tax savings.
  3. Next $14,000 fills two Roth IRAs at $7,000 each, assuming their income is under the phase-out threshold.
  4. Any remaining amount goes back into the 401(k) up to the $23,500 individual limit.

Even before counting investment growth, this couple converts a chunk of their $20,000 into free employer money and roughly $3,469 in avoided taxes, simply by funding the accounts in this order instead of dumping everything into whichever account their payroll system defaults to.

What Happens If You Need the Money Before Retirement

Liquidity rules are different for each account, and that should factor into how much you put where. HSA funds spent on qualified medical expenses are always tax-free and penalty-free, at any age, no waiting period. Roth IRA contributions (not earnings) can be withdrawn at any time, for any reason, tax-free and penalty-free, which makes it the most flexible of the three for a true emergency. A 401(k) is the least flexible: early withdrawals before 59.5 generally trigger income tax plus a 10% penalty, with narrow exceptions. If you expect to need access to some of this money before retirement age for something other than medical care, weight your contributions slightly more toward the Roth IRA and slightly less toward the 401(k), while still keeping the HSA maxed for the medical-expense safety net it provides.

Common Mistakes People Make Ranking These Accounts

  • Skipping the HSA because it “feels like” a health expense account. It is also a retirement account once you look at the post-65 rules.
  • Leaving HSA cash uninvested for years. A few thousand dollars sitting at close to 0% for a decade is a real opportunity cost.
  • Maxing a 401(k) before capturing the match structure correctly. Check whether your plan matches per-paycheck or true-up at year-end; front-loading contributions early in the year can accidentally forfeit match dollars on some plans.
  • Paying monthly HSA fees without checking alternatives. Many older, bank-run HSA providers charge $2.50 to $5 a month in maintenance or investment fees. Over 20 years that is real money that a no-fee provider would have let you keep invested.
  • Withdrawing HSA funds for non-medical expenses before 65. That triggers income tax plus a 20% penalty, by far the harshest early-withdrawal treatment of the three accounts.

FAQ

Is an HSA better than a Roth IRA for retirement?

For medical expenses in retirement, yes, the HSA is strictly better because withdrawals stay tax-free forever when used for qualified care. For non-medical retirement spending, the two behave similarly after age 65, so most people benefit from funding both rather than picking one.

Should I max my HSA before contributing to a 401(k)?

Contribute enough to your 401(k) first to get the full employer match, since that is an immediate guaranteed return. After the match, fund the HSA up to its annual limit before adding more to the 401(k).

Can I contribute to both an HSA and a Roth IRA in the same year?

Yes. They have separate contribution limits and separate eligibility rules, so funding both in the same year is common and generally the right move once you are past capturing any employer match.

What is the HSA triple tax advantage?

Contributions are pre-tax or deductible, growth inside the account is tax-free, and withdrawals for qualified medical expenses are also tax-free. No other retirement or savings account gets all three breaks at once.

Does an HSA reduce my taxable income more than a 401(k)?

Both reduce taxable income by the contribution amount, but only HSA contributions made through payroll also avoid the 7.65% FICA tax, which a 401(k) contribution does not.

What happens to my HSA if I never get sick?

Nothing is lost. HSA funds roll over every year with no use-it-or-lose-it deadline, unlike an FSA, and after 65 you can withdraw for any reason and simply pay ordinary income tax, exactly like a traditional 401(k) or IRA.

Can self-employed people use this same HSA, Roth IRA, 401(k) order?

Yes, with one adjustment: self-employed contributions to an HSA are deducted on your tax return instead of run through payroll, so you still save income tax but not FICA. There is no employer match to chase, so the order simplifies to HSA, then Roth IRA, then a solo 401(k).

Is it worth opening an HSA just for the retirement benefit if I rarely have medical expenses?

Usually yes, because the tax treatment on the way in and the flexibility after 65 make it competitive with a Roth IRA even for a healthy person, and it still functions as a safety net if a large medical expense shows up unexpectedly.

Which provider should I use if my current HSA charges monthly fees?

If your provider charges a monthly maintenance or investment fee just to hold your own money, moving to a no-fee provider like Lively is usually a 15-minute fix through a standard trustee-to-trustee transfer. See our full Lively HSA review for the details on fees and investing.

Do required minimum distributions apply to HSAs like they do 401(k)s?

No. HSAs have no required minimum distributions at any age, which is another advantage over a traditional 401(k), where the IRS forces withdrawals starting at age 73.

What if I earn too much to contribute to a Roth IRA?

The HSA and 401(k) have no income-based phase-out, so if you are locked out of a Roth IRA, prioritize the employer match, then the HSA to the max, then the 401(k), and look into a backdoor Roth IRA conversion if you still want a third tax-free bucket.

Can I still open an HSA if I do not have an HDHP?

No. HSA eligibility requires enrollment in a qualifying high-deductible health plan and no other disqualifying coverage. Without an HDHP, focus on the employer match, then a Roth IRA, then the rest of your 401(k).