Do You Pay Capital Gains on HSA Investments? Federal, State, and Age 65

You do not pay capital gains tax on HSA investments at the federal level. Interest, dividends, and realized gains stay inside the account untaxed while they grow, and they come out tax-free when you use the money for qualified medical expenses.1Office of the Law Revision Counsel. 26 USC 223 – Health Savings Accounts A handful of states don’t follow the federal rules, so your state return can look different from your federal one.

Why the Federal Tax Code Leaves HSA Gains Alone

The IRS treats a Health Savings Account as a tax-exempt trust. Earnings inside the account are not included in your federal gross income as long as they stay there.1Office of the Law Revision Counsel. 26 USC 223 – Health Savings Accounts Reinvested dividends aren’t taxed. Selling one mutual fund to buy another doesn’t create a taxable event the way it would in a regular brokerage account.2Internal Revenue Service. Publication 969 (2025), Health Savings Accounts and Other Tax-Favored Health Plans

That’s what investors mean by zero tax drag. In a taxable account, every profitable sale gives up a slice to capital gains tax before you can put the money back to work. Inside an HSA, the full amount keeps compounding. Over a working lifetime, that gap can add up.

Most custodians let you move money into a self-directed investment sleeve once your cash balance clears a minimum, often around $1,000 to $2,000. Mutual funds, ETFs, individual stocks, and bonds are the common choices. What limits you isn’t the menu, it’s how much you can put in each year: for 2026, $4,400 for self-only coverage and $8,750 for family coverage, plus a $1,000 catch-up if you’re 55 or older.3Internal Revenue Service. Revenue Procedure 2025-19

What Happens When You Withdraw

The federal shelter follows the money out of the account, but only for qualified medical expenses. Distributions used for those expenses are not included in your gross income at all.1Office of the Law Revision Counsel. 26 USC 223 – Health Savings Accounts The federal definition is broad: diagnosis, treatment, and prevention of disease, prescription medications, dental work, vision care, and long-term care services all qualify.4Office of the Law Revision Counsel. 26 USC 213 – Medical, Dental, Etc., Expenses

One timing rule matters. The medical expense has to have been incurred after you opened your HSA. Bills predating the account don’t count, even if you pay them later out of HSA funds.2Internal Revenue Service. Publication 969 (2025), Health Savings Accounts and Other Tax-Favored Health Plans

Non-medical withdrawals are a different picture. The full distribution is added to your gross income for the year, and if you’re under 65, an additional 20% tax lands on top.2Internal Revenue Service. Publication 969 (2025), Health Savings Accounts and Other Tax-Favored Health Plans There’s no basis carve-out the way there is with a Roth IRA. Because contributions went in pre-tax, the whole amount is taxable, not just the gains portion. On a $10,000 non-medical withdrawal for someone in the 24% bracket, that’s $2,400 in income tax plus $2,000 in additional tax before state taxes are even in the picture.

Hold onto your receipts and explanation-of-benefits statements. The IRS doesn’t ask for documentation with your return, but you need it if you’re audited to show each withdrawal covered a legitimate medical cost.5Internal Revenue Service. IRS Audits – Records We Might Request

Stretching the Shelter With Old Receipts

Federal law sets no deadline for reimbursing yourself. You can pay a medical bill out of pocket today, file the receipt away, and pull the money out of your HSA a decade later, tax-free.2Internal Revenue Service. Publication 969 (2025), Health Savings Accounts and Other Tax-Favored Health Plans The only condition is that the expense was incurred after you established the account.

That’s what makes the HSA unusual as an investment vehicle. You can let the balance compound for years while quietly accumulating a stack of reimbursable receipts. When you eventually withdraw, the distribution is tax-free because it matches a real medical cost from the past. The IRS has no rule forcing you to take the reimbursement in any particular year, so the whole approach is entirely within the rules.

What Changes at Age 65

The 20% additional tax on non-medical withdrawals goes away permanently once you turn 65.2Internal Revenue Service. Publication 969 (2025), Health Savings Accounts and Other Tax-Favored Health Plans Non-medical distributions still count as ordinary income, but that’s the extent of the tax. Medical withdrawals stay completely tax-free at any age.

For non-medical spending after 65, the account behaves like a traditional IRA: you pay income tax on what you take out and nothing more. The advantage the HSA keeps is on the medical side, where withdrawals remain fully tax-free. Someone who spent years banking receipts can pull decades of qualified expenses out without paying federal tax on any of it, including the capital gains that grew alongside them.

State Taxes Don’t Always Match

Most states follow the federal treatment and leave HSA investment growth alone on your state return. A small number don’t recognize the federal HSA shelter at all. Residents there may owe state income tax on contributions, on investment earnings, or on both, even while the same dollars are fully sheltered at the federal level.

If you’re in one of those states, you’ll need to track and report interest, dividends, and realized gains on your state return each year. Your custodian isn’t going to withhold state tax for you, and the mismatch catches people out. Check your state revenue department’s guidance before you assume your HSA growth is entirely tax-free. Missing these filings can bring state penalties and interest.

Moves That Can Destroy the Shelter Entirely

Certain transactions can strip the entire account of its tax-exempt status, not just the piece of it you touched. Federal law applies the same prohibited transaction rules to HSAs that govern IRAs.1Office of the Law Revision Counsel. 26 USC 223 – Health Savings Accounts

The common violations are borrowing from the account, pledging it as loan collateral, and using HSA funds to buy property for personal use.6Internal Revenue Service. Retirement Topics – Prohibited Transactions If any of that happens, the account stops being an HSA. The full fair market value is treated as a distribution and added to your gross income for the year. Under 65, the 20% additional tax applies on top.

This is the worst tax outcome an HSA can produce. Someone with $100,000 in the account who uses it as loan collateral can see the entire balance taxed as ordinary income in a single year, potentially in a bracket higher than their normal one. The line is straightforward: keep the account for investing and medical expenses, and keep personal transactions out of it.