Do I pay capital gains selling HSA investments to reimburse medical expenses?

Trying to figure out if do I pay capital gains selling HSA investments to reimburse medical expenses. Here's my situation: I have a Fidelity HSA with about half the balance invested in index funds. I had a big dental bill last year and want to sell some of those funds and transfer the cash to my checking account to reimburse myself. My broker dashboard shows the funds have gains since I bought them inside the HSA. I already know HSA distributions for qualified medical expenses are tax-free, but I wasn't sure if the sale inside the account first triggers a separate capital gains event I have to report. My 1099-B from Fidelity last year didn't show anything from the HSA and I didn't get a 1099-SA for that year either since I didn't take a distribution. Does selling inside the HSA create a reportable gain on Form 8949, or does only the distribution itself matter?

35 comments

Selling investments inside an HSA does not create a taxable event. The HSA is a tax-advantaged account, so buying and selling within it generates no reportable gain or loss. You will not get a 1099-B for trades inside the HSA, and nothing goes on Form 8949 or Schedule D for those internal sales. The only tax event is the distribution itself, reported on Form 1099-SA when you take money out.

Diego H.

Author

Form 1099-SA is what I should be watching for then. That makes sense — the account itself is the wrapper and the gains stay inside it.

Correct. The IRS treats the HSA like a trust that holds your funds. Growth inside is sheltered. When you take the distribution, the custodian sends a 1099-SA with the gross amount in box 1 and a distribution code in box 3. Code 1 is normal distribution. If you used it for qualified medical expenses, you report it on Form 8853 (actually Form 8889 for HSAs specifically), and the qualified portion comes out tax-free with no penalty.

Form 8889 — that's the one that goes with the HSA, right? Not 8853?

Form 8889 is for HSAs. Form 8853 is for Archer MSAs and long-term care contracts. Easy to mix them up.

Diego H.

Author

Form 8889, got it. So I fill that out showing the distribution and the qualifying expense and that zeroes out the taxable amount?

Yes, that's basically it. Part II of Form 8889 handles distributions. You enter the total distribution from the 1099-SA and then the amount used for qualified medical expenses. The difference, if any, is the taxable amount and also subject to an additional tax if you're under 65 and the expense wasn't qualified. Keep your receipts and EOBs matching the distribution amount in case of questions later.

Diego H.

Author

Part II of Form 8889. Good to know exactly where it lands. I have all the dental receipts saved.

Form 8889 tripped me up last year because my HSA had both a rollover and a distribution in the same year and I wasn't sure how to show both on the same form. Uploaded my 1099-SA, 1099-SA from the old custodian, and my W-2 box 12 code W amount to taxr.ai and it flagged that I'd double-counted the rollover as a contribution. Would have overstated my excess contribution penalty. Saved me a real headache. To your question: gains on the sale inside the account genuinely do not show up anywhere on your federal return.

Diego H.

Author

Double-counting a rollover as a contribution sounds like exactly the kind of thing that's invisible until someone checks all the pieces together.

Form W-2 box 12 code W is the employer contribution, and if you also had a trustee-to-trustee rollover, they look similar in the records. Easy to conflate them.

One thing to keep straight: the investment gains inside the HSA are never taxed as long as the distribution is for qualified medical expenses. If you take a non-qualified distribution, the earnings don't get broken out separately — the whole taxable amount (not just the gains) is ordinary income plus the additional tax. So it's not capital gains treatment either way, qualified or not.

That's a useful point. Even if the distribution is non-qualified it's ordinary income, not capital gains. The capital gains rules simply don't apply to HSA distributions.

Diego H.

Author

Ordinary income, not capital gains, for non-qualified. Got it. Mine should be fully qualified but good to know the fallback treatment.

Form 1099-SA box 3 code matters a lot. Code 1 is normal, code 2 is excess contribution distribution, code 5 is prohibited transaction. If you get anything other than code 1 (for example code 3 for disability or code 4 for death) it changes what goes on Form 8889 and whether the additional tax applies. Worth checking that box when the form arrives, not just the gross amount in box 1.

Also worth noting: your HSA custodian tracks the account's basis internally but that is entirely separate from your personal tax return. You don't carry a cost basis for the investments into your own records the way you would in a taxable brokerage. The 1099-B you mentioned from Fidelity was for your taxable accounts — HSA transactions simply don't flow through that form.

Diego H.

Author

That confirms what I suspected. The 1099-B I saw was definitely from the taxable side. Good to have that confirmed explicitly.

Form 8889 Part I is for contributions, Part II is distributions. If you also made your own contributions this year (not through payroll), those go in Part I line 2. The deduction for HSA contributions flows from Form 8889 line 13 to Schedule 1 line 13. Worth filling the whole form correctly, not just the distribution section, especially if you contributed and withdrew in the same year.

Form 8889 Part II was where I kept second-guessing myself last year — I had reimbursed myself across multiple months and wasn't sure if each reimbursement counted separately or if only the annual total mattered. I gave Taxr my 1099-SA, my bank transfer records, and my receipts folder and it matched each withdrawal to the corresponding expense and built a summary showing the total qualified amount. Confirmed the whole distribution was qualified. The form itself only needs the annual total, but having the receipt-level match ready matters if the IRS ever asks.

Diego H.

Author

Annual total on the form, receipt-level backup in your files. That's exactly the approach I'll take.

Form 8889 line 14a is the total distributions from box 1 of your 1099-SA. Line 15 is the qualified medical expenses paid from the HSA. The difference (line 14c minus line 15) flows to line 16 as the taxable amount. Keep those three numbers reconciled.

To be clear on the investment side: when you instruct Fidelity to sell the index funds inside the HSA, they liquidate the position, the cash sits in your HSA cash account, and then you request a distribution. Each of those steps happens inside the account wrapper. The only moment your tax return sees any of it is when the distribution hits and the 1099-SA is issued. Nothing on Form 8949, nothing on Schedule D.

Schedule D confirms: I went through this last year and my Schedule D had zero entries related to any HSA activity. All the action stays inside the account.

Worth saving documentation of when each medical expense was incurred. The IRS doesn't require you to reimburse yourself in the same year the expense occurred, but you need to show the expense wasn't previously deducted or reimbursed from another source. If you're reimbursing yourself for expenses from a prior year, that's allowed, but keep the dates on the receipts.

Diego H.

Author

Prior-year expenses are fine as long as the HSA existed at the time of the expense and it wasn't deducted elsewhere. Good reminder to check that.

Exactly — the HSA has to have been established before the expense date. That's the key condition for prior-year reimbursements.

Form 1099-SA should arrive by early February. If you use software like TurboTax or similar, it'll ask you about the 1099-SA and walk you through Form 8889 automatically. The key input is confirming the distribution was for qualified expenses — the software will mark line 15 equal to line 14c and the taxable amount on line 16 comes out zero.

Does anyone know if Fidelity sends a separate 1099-SA for each account type (HSA vs. regular brokerage) or combined? Mine always looks like there are two envelopes.

Fidelity sends the 1099-SA for the HSA separately from the 1099-B for taxable accounts. They are different forms entirely and shouldn't be on the same document.

1099-SA for HSA, 1099-B for brokerage. Got it, that explains why I always have two separate tax documents from them.

If your qualified medical expenses exceed the HSA distribution you took, you don't get to deduct the excess on Schedule A automatically — you can only deduct medical expenses on Schedule A that weren't reimbursed. So make sure you're not claiming the same expense both as the qualifying use of the HSA distribution and as an itemized deduction. Those are mutually exclusive for the same dollar.

Diego H.

Author

Right — same dollar can't do both jobs. Noted, though with standard deduction being what it is I'm probably not itemizing anyway.

Form 8889 is fairly short but the instructions on irs.gov are worth reading alongside it. The section on qualified medical expenses cross-references Publication 502, which is the master list of what counts. Dental work is definitely on it, so you should be in good shape.

Plain answer to what was asked: no capital gains tax, no Form 8949, no Schedule D entry. Sell inside the HSA freely. Take the distribution. Report it on Form 8889. Keep the receipts. That's the whole process.

Diego H.

Author

That's the clearest summary of the full chain. Sell inside, distribute, Form 8889, keep receipts. Appreciate everyone walking through the details.