Tax-Loss Harvesting and the Wash-Sale Rule
Tax-loss harvesting means selling an investment that has fallen below what you paid so the loss shows up on your tax return, then usually reinvesting the money so you stay in the market. The realized loss offsets capital gains and, up to a limit, ordinary income. It only works in a regular taxable account, and it comes with one big trap, the wash-sale rule, which disallows the loss if you buy the same thing back too soon.
The rules here have been stable for years. Where dollar figures depend on the tax year, this page uses 2027 amounts from the IRS's November 2026 inflation adjustments.
What a harvested loss can offset
- Capital gains first. Short-term losses offset short-term gains and long-term losses offset long-term gains, then the two results are netted against each other. (See capital gains tax rates for how each kind is taxed.)
- Then up to $3,000 of other income a year, such as wages ($1,500 if married filing separately).
- The rest carries forward to later years, with no expiration, and keeps its short-term or long-term character.
A worked example
Early in 2027 you sold a stock you'd held for eight months at a $6,000 profit, a short-term gain. You're single with about $150,000 of taxable income, so that gain would be taxed at your 24% rate (see the 2027 tax brackets): $1,440.
You also own an index fund you bought for $20,000 that's now worth $14,000. In December you sell it, realizing a $6,000 loss, and put the $14,000 into a different fund with a similar investment mix.
- The $6,000 loss wipes out the $6,000 gain, saving $1,440 in federal income tax this year.
- Your money stays invested, so if the market recovers, you still benefit.
If you'd had no gains at all, the same loss would have offset $3,000 of your wages this year (worth $720 at 24%) and carried the other $3,000 into 2028.
Deferral, not a free lunch
Harvesting usually postpones tax rather than eliminating it. Your new fund has a cost basis of $14,000, not $20,000, so if it climbs back to $20,000 and you sell, you'll have a $6,000 gain then. The strategy still tends to come out ahead because:
- The rates can differ. In the example, the loss saved tax at 24% on a short-term gain. If you hold the new fund more than a year, the later gain is long-term and taxed at 15%, or even 0% in a low-income year.
- The $3,000 offset against ordinary income is taxed at your full bracket rate.
- Money you don't pay in tax today stays invested and can compound.
- The deferred gain may never be taxed. Heirs generally receive inherited investments at their value on the date of death, and donating appreciated shares to charity can avoid the gain too.
The wash-sale rule
You can't deduct a loss on stock or securities if, within 30 days before or after the sale, you:
- buy substantially identical stock or securities,
- acquire them in a fully taxable trade,
- acquire a contract or option to buy them, or
- acquire them in your IRA or Roth IRA.
That's a 61-day window centered on the sale date: 30 days before, the day of the sale, and 30 days after. It also counts if your spouse or a corporation you control buys substantially identical stock in that window.
A wash sale doesn't make the loss disappear (with one exception, below). The disallowed loss is added to the cost basis of the replacement shares, and your holding period for the old shares carries over to the new ones. You get the deduction later, when you sell the replacement shares.
Example. You buy 100 shares for $5,000 and sell them for $4,000, a $1,000 loss. Twenty days later you buy 100 shares of the same stock for $4,200. The $1,000 loss is disallowed for now, and your basis in the new shares becomes $4,200 + $1,000 = $5,200. If you later sell them for $5,500, your gain is $300, not $1,300.
The IRA trap
If the replacement purchase happens in your IRA or Roth IRA, the IRS's rule adds no basis adjustment, so the loss is effectively gone for good. Watch for automatic contributions or rebalancing in retirement accounts that buy the same fund you just sold at a loss in a taxable account.
What counts as "substantially identical"
The IRS says it depends on all the facts and circumstances. Some guideposts from Publication 550:
- Stock of one company is ordinarily not substantially identical to stock of another company.
- A company's bonds or preferred stock are ordinarily not substantially identical to its common stock, unless they're convertible and trade in step with it.
- Options to buy the same stock do count.
For mutual funds and ETFs, the IRS hasn't drawn a bright line. Selling one S&P 500 index fund and buying another S&P 500 fund from a different company is a gray area. Many investors switch to a fund that tracks a different index (for example, from an S&P 500 fund to a total-market fund), which keeps similar exposure with less doubt.
Gains are different: "harvesting" gains at 0%
The wash-sale rule applies only to losses. If you sell at a gain and buy back immediately, the gain counts and your basis resets higher. That's useful in a low-income year. A single filer with $35,000 of taxable income in 2027, before any gains, has $16,050 of room under the $51,050 threshold for the 0% long-term capital gains rate. Selling long-term holdings with up to that much gain, then buying them back, raises the cost basis without any federal income tax on the gain.
Common mistakes
- Dividend reinvestment. An automatic dividend reinvestment in the same fund within 30 days of a loss sale is a purchase. It makes part of the loss a wash sale. Turn off reinvestment on positions you plan to harvest.
- Buying before you sell. The window looks backward too. Adding to a position and then selling the original shares at a loss within 30 days can trigger the rule.
- Relying on your broker to catch it. Form 1099-B shows wash sales the broker can see, generally identical securities in the same account. Purchases at another firm, in your IRA, or by your spouse aren't flagged, but the rule still applies.
- Missing the deadline. For stocks and funds, the trade date determines the tax year. A sale on December 31 counts for that year even though it settles in January.
- Harvesting in tax-sheltered accounts. Losses inside an IRA, 401(k) or HSA aren't deductible, so there's nothing to harvest there.
- Letting the tax tail wag the dog. Don't sell a holding you'd otherwise keep, or end up in an investment you don't want, just to book a small loss. Trading costs and the risk of being out of the market can outweigh a modest tax saving.
This is a general explanation of how harvesting and the wash-sale rule work, not tax advice. Check your own situation with the IRS or a tax professional, especially before relying on a "not substantially identical" replacement.