Should I sell stock and pay capital gains to pay off my HELOC?

Trying to decide whether to sell stock and pay capital gains to pay off my HELOC. The balance on the line is not huge but the rate has been creeping up and it's annoying me. I have a taxable brokerage account with a mix of positions — some I've held for years, some I bought in the last 12 months. The long-term ones have significant gains. My income this year is higher than usual because of a bonus, so I'm not sure where I'd land on the capital gains rate. I already ran the basic math on the interest I'd save but I didn't account for what I'd actually net after tax on the sale. Is this usually worth doing, or does the tax hit eat up most of the benefit? And does it matter which shares I sell first?

35 comments

The holding period question you raised is the most important variable here. Long-term gains (held more than one year) are taxed at a lower rate than short-term gains, which are taxed as ordinary income. With a higher-income year you mentioned, short-term gains on the positions you bought in the last 12 months could be taxed at a rate that makes this a bad trade. I'd separate the two buckets before deciding anything.

Sofia L.

Author

That framing helps. Most of the gain is in the long-term positions so I'd probably pull from those. Still need to know where my income lands this year before I can figure out the actual rate.

Don't forget your state. Federal long-term rates get most of the attention but several states tax capital gains as ordinary income with no special rate. That can add a meaningful number on top of the federal bill and change the math on whether selling is cheaper than just paying down the HELOC over time.

Sofia L.

Author

Good point, I keep forgetting to factor state in. I'm in a state that does tax gains as ordinary income so that changes the picture a bit.

State taxes on gains are genuinely the thing people skip. Run the combined rate, not just federal.

Before I made this call last year I uploaded my brokerage 1099-B and my draft return to taxr.ai and had it walk through each position — it flagged which lots were short-term vs. long-term and estimated what the net proceeds would look like after the federal tax on each one. That made it easy to see which shares to sell first. Worth doing before you commit to a specific lot.

Sofia L.

Author

Did it handle the lot-level detail from the 1099-B or did you have to enter things manually?

The 1099-B had the per-lot breakdown and it read right off that. I didn't enter anything manually.

One angle people miss: if you have any positions currently sitting at a loss, you can harvest those in the same year to offset the gains from the positions you're selling to fund the payoff. That reduces the net taxable gain and can make the math work better. You'd report both on Form 8949 — gains and losses net on Schedule D.

Sofia L.

Author

I do have one position that's down. I hadn't thought about pairing them. That could actually make a real difference.

Watch the wash sale rule though — if you sell at a loss and buy the same or substantially identical security within 30 days before or after, the loss is disallowed. Code W on Form 8949 column (f), and the disallowed amount gets added to your cost basis in the new shares instead of being deductible now.

The break-even question is basically: what is my after-tax rate on the HELOC versus the after-tax cost of selling? HELOC interest is generally not deductible unless the funds were used to buy, build or substantially improve the home securing the line. So if you've been treating it as deductible and it isn't, the effective rate on the debt is higher than you think.

Also worth thinking about what the stock would do if you held it. If you believe the positions will keep compounding, selling now locks in the gain and forfeits future growth. If you think they're fully valued or you'd rebalance anyway, selling to pay off high-rate debt is a reasonable call.

This is the part that's really personal. The tax math has a right answer once you have the numbers. The "what will the stock do" question doesn't.

Practically speaking: tell your broker which specific lots you want to sell before you place the trade. If you don't specify, most brokers default to FIFO (first in, first out), which may not give you the most favorable tax outcome. Lot selection is a one-time choice per trade — you can't go back and reassign it after settlement.

Sofia L.

Author

I didn't know I had to specify before the trade. I'll check my broker's process for that. I've always just hit sell without thinking about it.

For the reporting side: when you sell, the broker sends a Form 1099-B. Each lot goes on Form 8949 — Part I for short-term (held one year or less), Part II for long-term. The totals flow to Schedule D. If your broker reports cost basis to the IRS (box A or D on 8949), and there are no adjustments needed, those lots can go straight to Schedule D line 1a or 8a under Exception 1 without itemizing each one on 8949.

Sofia L.

Author

So if I have a mix of adjusted and unadjusted lots, some go on 8949 and some go straight to Schedule D?

Exactly. The ones with adjustments — like a corrected basis or a wash sale — have to go on 8949 with the adjustment in column (g). Clean lots with basis reported can skip to Schedule D directly.

I ran this same analysis last spring before selling to pay off a home equity line. Had Taxr read through my 1099-B alongside my Schedule D draft — it compared the cost basis I had recorded against what the broker reported and caught a lot where I'd reinvested dividends and my records were off. Saved me from understating my basis and overpaying on that lot.

Sofia L.

Author

Dividend reinvestments are exactly the kind of thing I'd miss. I've had positions for years with DRIP turned on.

Each reinvestment is its own lot with its own purchase date and basis. It adds up fast on a long-held position.

If your income puts you in the 0% long-term capital gains bracket federally, selling to pay off the HELOC is basically free from a federal tax standpoint. But check the instructions for Schedule D — the rate that applies depends on your taxable income after deductions, not your gross income, so a rough estimate can be off.

For the actual thresholds by filing status and year, the Form 1040 instructions have the Qualified Dividends and Capital Gain Tax Worksheet (the Schedule D instructions send you there, or to their own Schedule D Tax Worksheet if you need that one). That's the clearest place to work through what rate actually applies to your specific situation.

Had Taxr go through my entire brokerage statement and return when I was deciding something similar — it listed every lot, flagged which ones had holding periods that would flip from short to long-term in the next 60 days, and drafted a summary I could hand to my CPA. That waiting list of lots flipping long-term changed which ones I sold and saved a noticeable amount on the tax side.

Sofia L.

Author

The "flip date" idea is something I hadn't considered. Some of my recent buys might be close to that one-year mark.

Worth checking. If a position crosses the one-year mark you get the preferential long-term rate. A few weeks of patience can make a material difference.

The AMT angle: if you're exercising ISOs or have other AMT exposure in the same year, adding capital gains can interact with the calculation. Something to flag with a CPA if ISO exercises are part of your situation, since Form 6251 pulls in a lot of moving parts.

Don't sell the short-term lots to fund this unless the HELOC rate is genuinely punishing. Short-term gains taxed as ordinary income plus state can easily leave you netting 60 cents on the dollar or less in a high-tax situation. The long-term lots are almost always the right lever.

Sofia L.

Author

Agreed, the short-term ones are off the table for me at this income level. Sticking to the long-term positions.

If you do end up with net capital losses after all the selling — say the loss harvesting produces more than the gains — you can deduct losses against ordinary income up to the annual limit on line 7a of Form 1040, with the rest carrying forward. The carryover amount is figured on the Capital Loss Carryover Worksheet in the Schedule D instructions.

Something to confirm with your broker: whether the lots you want to sell are covered or noncovered securities. Covered securities have basis reported to the IRS on 1099-B box 1e. Noncovered ones show basis in a separate section not sent to the IRS. This affects which box you check on Form 8949 and whether you can use Exception 1 to skip 8949 entirely for those lots.

Noncovered lots go in box B (short-term) or E (long-term) on Form 8949, and you enter the correct basis yourself — there's no IRS-reported basis to match against.

The IRS pages worth reading before you finalize anything: Topic 409 on capital gains and losses covers holding periods and the basic rate structure, and Publication 550 covers wash sales and cost basis adjustments in detail. Both are on irs.gov.

Sofia L.

Author

Bookmarked both. Pub 550 looks like it has everything on wash sales which is the piece I'm least sure about.