Should I pay capital gains tax selling index funds to pay off mortgage?

Trying to decide whether to liquidate my taxable brokerage account to wipe out the remaining balance on my mortgage. The account holds index funds I've been building for about 12 years, so most of the positions are sitting on pretty significant unrealized gains. I ran some rough numbers and I know I'll owe capital gains tax on whatever I sell, but I'm not sure how to think about whether that tax hit makes the payoff worth it or just destroys the math entirely. I already pulled my cost basis from the brokerage portal and I know the funds have been held more than a year so they'd be long-term. But I haven't figured out what rate I'd actually land at once the gains get stacked on top of my salary, or whether there's a smarter way to do this in pieces over a few years. Should I pay capital gains tax selling index funds to pay off my mortgage, or is there a better structure here?

34 comments

Schedule D and Form 8949 are where the gains land, but the rate question is the one that actually drives the decision. Long-term capital gains get stacked on top of your ordinary income for purposes of determining which bracket you fall into. So if your salary already pushes you fairly high, those gains could easily land at the top rate. The IRS has a qualified dividends and capital gains tax worksheet in the Form 1040 instructions that walks through exactly how the stacking works. Worth running that before you commit to anything.

Claire L.

Author

Thanks, I'll pull that worksheet. The stacking piece is exactly what I was unclear on — I figured the gains had their own separate bracket but apparently not.

Paid off mine a couple years back using a mix of savings and some fund sales. The thing nobody warned me about was how much the gain amount bumped my AGI for that year and affected other things — IRMAA surcharges if you're near Medicare age, ACA premium credits if that applies to you, even some deduction phase-outs. The tax on the gains themselves was one number but the ripple effects were a separate headache.

Claire L.

Author

Not near Medicare age yet but the ACA piece is relevant. I'm between jobs right now which makes this whole calculation more complicated.

The holding period question is settled for you since you said these are 12-year positions, so they're all long-term. For Form 8949, you'd check box D, E or F in Part II depending on whether your brokerage reports basis to the IRS — most major brokers do for covered securities, so probably box D. The 1099-B you get next January will show it. The rate itself depends on your total taxable income for the year including the gains; Publication 550 at irs.gov walks through how long-term gains are taxed.

Before I sold a chunk of funds two years ago, I dropped my 1099-B, the prior year return and a rough projection into taxr.ai and had Taxr estimate what the total tax would look like at different sale amounts, then compare the after-tax payoff against keeping the mortgage. It laid out each scenario side by side so I could actually see the break-even. I'd been guessing at numbers and they were off. Useful before you pull the trigger on a decision this size.

Claire L.

Author

That side-by-side approach is exactly what I need. I've been doing this in a spreadsheet and I keep second-guessing the rate inputs. I'll try that.

One structural option people don't always consider: spreading the sales over two or more tax years. If you sell in December and then again in January, you've split the gain across two years and potentially kept each year's total income in a lower bracket. The math doesn't always work out better but it's worth modeling. The mortgage interest you lose by waiting another few months is usually pretty small compared to the tax difference if the brackets don't line up.

This is what we did. Sold in late December one year, then again the following February. Gave us room on both years.

Claire L.

Author

Good point on the timing. My mortgage rate is low enough that a couple months of extra interest is basically nothing, so spreading makes sense to look at.

Something worth flagging: if you have any positions in those index funds where you've reinvested dividends over the years, each reinvestment is a separate lot with its own cost basis and purchase date. Your brokerage should have the lot detail but it's worth verifying before you assume every share has the same basis. Some older lots from DRIP reinvestments can have surprisingly low basis.

Claire L.

Author

I do have dividend reinvestment turned on. I'll check the lot detail — I honestly just assumed it was one blended number.

Publication 550 covers the specific identification method if you want to choose which lots to sell and can get written confirmation from the broker. Can save meaningful tax if the lots vary a lot in basis.

Is the mortgage on your primary residence? Asking because if you have a lot of equity and ever considered a home equity line instead of selling funds, the interest comparison changes. Not saying one is better, just that the analysis should include what you're giving up on the investment side — 12-year compounding is hard to rebuild.

Claire L.

Author

Yes, primary residence. HELOC rate right now would be higher than my mortgage rate so that trade doesn't work, but the compounding point is real. That's the part that makes me hesitate.

Net investment income tax is another line to check. If your modified AGI crosses the threshold set out in the Form 8960 instructions, an additional percentage applies on top of the capital gains rate. It doesn't apply to everyone but it hits enough people that it's worth running Form 8960 as a what-if before you decide how much to sell.

Got caught by this one. Didn't think I was in the range until the gains pushed me over. The Form 8960 instructions on irs.gov show the threshold and how investment income is calculated.

Claire L.

Author

Didn't know Form 8960 existed. Adding it to the list of things to run before I do anything.

The psychological side is real too. Some people sleep better with no mortgage and that has value. But from a pure numbers standpoint, if your mortgage rate is below the long-term average return on a broad index fund — which for most people with older mortgages it is — selling appreciated shares and paying capital gains tax to pay it off is mathematically a step backward unless you're very close to the end of the loan anyway.

Had a similar situation last year — big taxable account, old index fund positions, wondering whether to liquidate. I uploaded the brokerage's lot detail report and my W-2 into Taxr and it went through each lot, figured the gain on each, and estimated the tax at different income levels. Helped me see that selling the highest-basis lots first cut the bill significantly without changing the payoff amount. Worth doing that kind of lot-by-lot pass before you decide what to sell.

Claire L.

Author

The lot-by-lot breakdown is something I hadn't tried. I'll pull the lot detail from the brokerage and run through that process.

Form 8949 Part II is where every long-term sale gets listed, one row per lot unless you qualify for the Exception 1 shortcut on Schedule D line 8a. Exception 1 only works if the 1099-B shows basis reported to the IRS and you have no adjustments — no wash sale codes, no corrected basis. If your lots are clean, you may be able to skip entering each line individually.

Worth checking your 1099-B for any adjustments in box 1f or 1g. If there are wash sale amounts from prior years those lots need individual Form 8949 entries regardless.

Have you looked at whether any of your positions are sitting at a loss? Even index funds can have specific lots underwater if you bought at a high point. Harvesting those losses in the same year you realize the gains on the appreciated lots can offset the taxable amount on Schedule D before it flows to your return.

This is worth doing even outside the mortgage decision. Most index fund holders who've been in since before 2022 have mixed lots if they kept buying through the dip.

Claire L.

Author

I do have a couple lots from early 2022 that might be underwater. I'll check those specifically.

When I was running this same analysis, I gave Taxr my brokerage statement and the draft 8949 my tax software had generated, and it compared the two and flagged three lots where the basis didn't match what the brokerage was reporting. Turned out two were DRIP lots that the software had pulled in with the wrong date. Worth cross-checking before you file, especially with a large transaction count.

Claire L.

Author

Three mismatched lots sounds like exactly the kind of thing I'd miss. Good reason to verify before filing rather than after.

The capital loss carryover situation matters here too. If you have any capital loss carryforwards from prior years — look at Schedule D from last year's return — those offset gains dollar for dollar this year before any tax is owed. Topic 409 on irs.gov explains how the carryover works and in what order short- and long-term losses are applied.

Claire L.

Author

I do have a small carryforward from 2022. Didn't think to include it in my estimate. That changes the number at least a little.

Qualified opportunity zone funds are sometimes mentioned as a deferral strategy but the complexity and illiquidity make them a poor fit for most people just trying to pay off a mortgage. Unless someone is managing a very large gain and has a long horizon, it usually isn't worth the trade-off.

Publication 550 at irs.gov covers the basic holding period rules clearly. You said these are 12-year positions so long-term is settled, but the publication is useful for anyone still counting days on newer lots.

To pull everything together: run the gain estimates lot by lot, check for any underwater lots to harvest, factor in carryforwards, run Form 8960 as a what-if, and then model the sale across this year versus splitting into two years. The mortgage payoff math only makes sense after you know the actual after-tax proceeds, not the pre-tax gain.

Claire L.

Author

This is the clearest summary of my actual next steps. Running the lot detail today and will model it out from there before I do anything.