How to legally pay less or no capital gains tax on stocks

Been investing for about three years now and sitting on some gains I want to take this year. I know there are legal ways to reduce or eliminate capital gains tax on stocks but I can't figure out which ones actually apply to me. I've read about holding periods, income thresholds, something called tax-loss harvesting, and accounts like Roth IRAs but every article just scratches the surface. I already tried reading Topic 409 on the IRS site but it doesn't tell me which strategies to use, just how gains are classified. My situation: I have a mix of short-term and long-term positions, some losers I haven't sold yet, and I'm in the middle of my career so not low income but not top bracket either. What are the actual levers I can pull to legally pay less or no capital gains tax on stocks this year?

41 comments

What's your rough holding period on the positions you want to sell? That's the first fork in the road. Short-term gains get taxed as ordinary income, long-term gets preferential rates. If you're close to the one-year mark on anything, waiting past that trade date anniversary moves it to long-term. The holding period starts the day after you buy and ends on the trade date you sell, not settlement.

Isaac G.

Author

Most of my winners I've held between 8 and 14 months, so it's a mix. The ones under a year I was planning to sell soon but maybe I should wait.

Yes, worth checking each trade date carefully. Even a few extra days can flip a position from short-term to long-term and change the entire tax treatment on that lot.

I'll share what actually helped me sort this out. I uploaded my 1099-B and a list of open positions to taxr.ai and had Taxr map out which lots were short-term vs long-term, flag the ones where harvesting a loss would offset a planned gain, and show me the net after the wash sale rule applied. Took me reading the output twice but it laid out the levers in order. Worth doing before you sell anything.

Isaac G.

Author

Did it also flag whether any of the harvested losses would get disallowed? That's the part I keep getting confused on with the wash sale rule.

Yes, it flagged positions where I'd be buying back within the 30-day window on either side of the sale. The wash sale rule covers 30 days before and after, and the disallowed loss gets added to the cost basis of the replacement shares rather than disappearing entirely.

Are you contributing to a tax-advantaged account at all? Gains inside a Roth IRA aren't taxed when distributed, and gains inside a traditional IRA aren't taxed until you take distributions. If you're buying and selling within those accounts the capital gains question doesn't come up the same way. The constraint is you can only hold what the account allows and contribution limits apply.

Isaac G.

Author

I have a Roth but I mostly hold index funds in it. I do my individual stock picking in my taxable brokerage. Maybe I should rethink which account holds what.

That's exactly the reallocation question. High-turnover or high-gain positions belong in tax-advantaged accounts if you can get them there. It doesn't help the gains you already have in taxable though.

Tax-loss harvesting is the most direct lever in a taxable account. You sell positions that are underwater, realize the loss, and use it to offset capital gains dollar for dollar. If losses exceed gains, you can deduct up to the limit against ordinary income and carry the rest forward. The carryover worksheet is in Publication 550 or the Schedule D instructions. The catch everyone forgets: the wash sale rule. If you buy substantially identical stock within 30 days before or after the sale, the loss is disallowed.

Does the wash sale apply if I sell in my taxable account and buy the same stock in my Roth IRA within that 30-day window?

Yes it does. The wash sale rule explicitly covers purchases in your IRA or Roth IRA. And the difference from a normal wash sale is that the disallowed loss doesn't get added to the new shares' basis in the IRA — it's just gone. That's worse than a regular wash sale so be careful there.

How long have you been holding the losers you mentioned? If you've held them more than a year they're long-term losses and those offset long-term gains first, then short-term. If they're short-term losses, they offset short-term gains first. The ordering matters when you're trying to minimize tax because short-term gains cost more. Publication 550 chapter 4 walks through the netting order.

Isaac G.

Author

Some losers are long-term, a couple are short-term. So I should probably use the short-term losses against short-term gains first if I can control the timing?

Yes, though you don't fully control the netting — the IRS netting rules apply in a set order. But you do control which positions you sell and when, so timing matters.

Nobody really talks about gifting appreciated stock. If you give shares to a qualifying charity directly, you generally avoid recognizing the gain yourself and the charity pays no tax on it either. The recipient's basis and the rules around that depend on who you give to. For a charity it sidesteps the gain entirely. For a family member who might be in a lower bracket, the gift basis rules in Publication 551 apply and the gain doesn't disappear, it just shifts.

Isaac G.

Author

I hadn't thought about the charitable angle. I do donate annually so this might actually be useful.

Are you self-employed or do you have a business? Opportunity Zone investments and certain retirement account structures can defer or reduce gains but those are more complex. For a straightforward stock investor the main levers are: holding period, loss harvesting, account type, and income management. Income management meaning if you can keep your taxable income below the threshold where the zero long-term rate applies, qualified long-term gains can be taxed at zero. The IRS instructions for Schedule D show the qualified dividend and capital gain tax worksheet.

Ran into this same situation last year with a chunk of long-term positions I wanted to trim. I had Taxr read through my Schedule D draft and my list of open lots, and it built out a scenario showing which lots to sell, which losers to pair them with, and what the net taxable gain would be after harvesting. I checked the numbers myself before doing anything but it saved me from a wash sale I almost triggered by accident. Really useful when you have more than a handful of positions.

Isaac G.

Author

That pairing of gains and losses into scenarios is exactly what I need. Right now I'm trying to do it in a spreadsheet and it keeps getting messy.

The spreadsheet gets complicated fast once you factor in the 30-day windows on both sides of each sale. Having it laid out per lot with the wash sale dates flagged made it much easier to see.

One thing that tripped me up early: the zero percent long-term rate isn't automatic just because you're not in a high bracket. Your ordinary income and your capital gains stack, so if your wages push your total taxable income above the threshold, the gains that fall above that line get taxed at the next rate. The tax worksheet that comes with Schedule D does the stacking calculation. Worth running the numbers before you sell.

So it's possible to have part of your long-term gains taxed at zero and part at the higher rate in the same year?

Yes, exactly. It depends on where your ordinary income sits relative to the threshold. The Schedule D qualified dividend and capital gain tax worksheet stacks them and applies the rates in order.

Has anyone here dealt with ISOs in addition to regular stock? Because the ISO rules are a whole separate lane. No regular income at exercise, but the spread at exercise is an AMT adjustment on Form 6251 line 2i. I exercised ISOs and thought I had no tax problem until AMT hit me. If you have stock options in the mix, capital gains planning and AMT planning have to happen together.

Isaac G.

Author

I don't have ISOs right now, just shares I bought in the open market. But good to know if I ever get equity comp.

Yeah the equity comp side adds a lot of moving pieces. For plain market purchases you just need to track your cost basis and holding period carefully and the 1099-B should have most of it, though covered vs noncovered matters.

Had Taxr go through my 1099-B last filing season — I had about 30 transactions and wasn't sure which ones had incorrect basis reported. It read each row, flagged the ones where the broker marked basis as not reported to IRS, and listed which box to check in Part I or Part II of Form 8949 and whether I needed a column (g) adjustment. Then I went through Form 8949 line by line using that list. Cut the time I spent on that form in half.

Does the box you check in Form 8949 actually change the tax math or is it just for IRS matching?

It's mainly for IRS matching but it also determines how you enter basis. Box A or D means basis was reported to the IRS, so if the basis is wrong you still enter what the 1099-B shows in column (e) and put the correction in column (g). Box B or E means basis wasn't reported, so you enter correct basis in column (e) directly. Getting the boxes wrong can cause matching issues.

If you're planning to harvest losses, make sure you track the disallowed wash sale loss on your 1099-B box 1g. But that box only shows the disallowed amount if the securities sold were covered and the replacement shares had the same CUSIP and were bought in the same account. If you bought through a different broker the wash sale might not appear on the form at all, and you still can't deduct it. You have to self-report with code W in column (f) of Form 8949 and the disallowed amount as a positive number in column (g).

Isaac G.

Author

Wait so if I sell at a loss at broker A and rebuy at broker B within 30 days, the wash sale still applies but won't show on either 1099-B?

Correct. Neither broker can see the other's transactions so neither will flag it. The obligation to report it and disallow the loss falls on you. Same thing if you buy substantially identical shares in your Roth IRA within that window.

Don't overlook the carryover from prior years. If you had net capital losses in a previous year that exceeded the deduction limit against ordinary income, that unused amount carries forward and can offset gains this year. Check your prior year Schedule D or the capital loss carryover worksheet. Sometimes people sit on a carryover and don't realize it's available to absorb new gains.

Isaac G.

Author

I actually did have losses last year. I didn't realize they carry forward automatically — I need to check my prior return.

Yes, it carries forward. The carryover worksheet in Publication 550 or the Schedule D instructions tells you how to calculate it and which line to bring it onto this year's Schedule D.

Realizing I should ask: are any of these positions in a margin account or do you hold them straight? Margin doesn't change the capital gains rules but short sales have completely different holding period rules and can create short-term gains even on positions you've had open a long time. If everything is a standard long position you're fine, just flagging it.

Isaac G.

Author

All standard long positions, no short sales. Good flag though.

To pull the main points together from this thread: hold past the one-year trade date to get long-term treatment, harvest losses to offset gains but watch the 30-day wash sale window on both sides, avoid rebuying substantially identical shares in any account including IRAs within that window, check for carryover losses from prior years, and run the Schedule D tax worksheet to see where the zero rate threshold cuts off. The IRS topic at irs.gov/taxtopics/tc409 is a decent starting point for the loss deduction limit and carryover rules.

No, that's a good summary. I'd add that if the positions are large enough that a mistake costs real money, running scenarios before selling — not after — is where the planning actually happens.

Worth repeating on the 83(b) election point that came up in another thread I saw: for people who receive restricted stock (not open-market purchases), you can elect to include the value at transfer and start the holding period then, rather than waiting for vesting. Has to be filed no later than 30 days after the transfer date. Can't be made for stock options. Doesn't apply to the original poster's situation but comes up a lot alongside capital gains planning for equity comp.