Table of Contents
Table of Contents

Tax-Loss Harvesting: How It Works, Example, and Pitfalls to Avoid

What Is Tax-Loss Harvesting?

Tax-loss harvesting is the timely selling of securities at a loss in order to offset the amount of capital gains tax due on the sale of other securities at a profit. 

This strategy is most often used to limit the amount of taxes due on short-term capital gains, which are generally taxed at a higher rate than long-term capital gains. However, the method may also offset long-term capital gains.

This strategy can help preserve the value of the investor’s portfolio while reducing the cost of capital gains taxes.

If your capital losses for the year exceed your capital gains, you can deduct up to $3,000 in net losses from your total annual income. However, you cannot deduct more than your total capital losses for the year. if your net losses exceed $3,000, Internal Revenue Service (IRS) rules allow the additional losses to be carried forward into the following tax years.

Key Takeaways

  • Tax-loss harvesting is a strategy investors can use to reduce the total amount of capital gains taxes due from the sale of profitable investments.
  • The strategy involves selling an asset or security at a net loss.
  • The investor can then use the proceeds to purchase a similar asset or security, maintaining the portfolio's overall balance.
  • The investor must be careful not to violate the IRS rule against buying a "substantially identical" investment within 30 days.

Understanding Tax-Loss Harvesting

Tax-loss harvesting is also known as tax-loss selling. It can be done at any time of the year, but most investors wait until the end of the year when they assess the annual performance of their portfolios and its impact on their taxes.

Using tax-loss harvesting, an investment that shows a loss in value can be sold to claim a credit against the profits that were realized in other investments.

For many investors, tax-loss harvesting is a critical tool for reducing their overall taxes. Although tax-loss harvesting cannot restore an investor to their previous position, it can lessen the severity of the loss. For example, a loss in the value of Security A could be sold to offset the increase in the price of Security B, thus eliminating the capital gains tax liability of Security B. Using the tax-loss harvesting strategy, investors can realize significant tax savings.

Maintaining Your Portfolio

Dumping a loser in a portfolio obviously has advantages. However, it inevitably disrupts the balance of the portfolio.

After tax-loss harvesting, investors who have carefully constructed portfolios replace the asset they just sold with a similar asset in order to maintain the portfolio's asset mix and expected risk and return levels.

Beware, though, of buying the same asset that you just sold at a loss. IRS rules require that an investor waits for at least 30 days before purchasing an asset that is “substantially identical” to the asset that was sold at a loss. If you do so, you lose the ability to write off the loss. This is the dreaded "wash-sale rule."

Short-term losses can only be used to offset short-term capital gains tax. Long-term losses can only be used to offset long-term capital gains tax.

The Wash-Sale Rule

The wash-sale rule is straightforward for the average investor, who merely has to avoid buying the same stock he or she just sold at a loss for tax purposes.

The rule, however, is designed to address more esoteric strategies involving tax-loss harvesting.

A wash sale is a transaction involving the sale of one security and, within 30 days (either before or after the sale), purchasing a "substantially identical" stock or security, either directly or indirectly via a derivatives contract such as a call option. If a transaction is considered a wash-sale, it cannot be used to offset capital gains. Moreover, if wash sale rules are abused, regulators can impose fines or restrict the individual's trading.

The Wash-Sale Rule and ETFs

One way to avoid the wash sale rule is by using ETFs in a tax-loss harvesting strategy. Because there are now several ETFs that track the same or similar indexes, they can be used to replace one another while avoiding violating the wash sale rule.

Thus, if you sell one S&P 500 index ETF at a loss, you can buy a different S&P 500 index ETF to harvest the capital loss.

Many roboadvisors offer free tax-loss harvesting in a way that is automated and will not violate the wash-sale rule.

Example of Tax-Loss Harvesting

Assume an investor earns income that puts him or her into the highest capital gains tax category. For the 2021 and 2022 tax years, that means more than $445,851 if single and $501,851 if married filing jointly.

The investor sold investments and realized long-term capital gains, which are subject to a tax rate of 20%.

Below are the investor's portfolio gains and losses and trading activity for the year:


  • Mutual Fund A: $250,000 unrealized gain, held for 450 days
  • Mutual Fund B: $130,000 unrealized loss, held for 635 days
  • Mutual Fund C: $100,000 unrealized loss, held for 125 days

Trading Activity:

  • Mutual Fund E: Sold, realized a gain of $200,000. Fund was held for 380 days
  • Mutual Fund F: Sold, realized a gain of $150,000. Fund was held for 150 days

The tax owed from these sales is:

  • Tax without harvesting = ($200,000 x 20%) + ($150,000 x 37%) = $40,000 + $55,500 = $95,500

If the investor harvested losses by selling mutual funds B and C, the sales would help to offset the gains and the tax owed would be:

  • Tax with harvesting = (($200,000 - $130,000) x 20%) + (($150,000 - $100,000) x 37%) = $14,000 + $18,500 = $32,500

How Does Tax-Loss Harvesting Work?

Tax-loss harvesting takes advantage of the fact that capital losses can be used to offset capital gains. An investor can "bank" capital losses from unprofitable investments in order to pay less capital gains tax on profitable investments sold during the year.

This strategy includes using the proceeds of selling the unprofitable investments to buy somewhat similar (but not "substantially identical") investments that preserve the portfolio's overall balance.

IRS rules prohibit an investor from buying the same investment within 30 days if the loss is used to offset capital gains taxes.

What Is a Substantially Identical Security and How Does It Affect Tax-Loss Harvesting?

In order to make use of tax-loss harvesting, the investor cannot violate the IRS' wash sale rule.

That is, the investor cannot sell an asset at a loss and buy a "substantially identical" asset within the 30-day period before or after that sale. Doing so will invalidate the tax loss write-off.

A "substantially identical security" is defined as a security issued by the same company (e.g. its class A shares vs. its class B shares or a convertible bond issued by the company), or a derivative contract issued on the same security.

How Much Tax-Loss Harvesting Can I Use in a Year?

The IRS limits the maximum amount of capital losses that can be used to offset capital gains in a year. An individual taxpayer can write off up to $3,000 in net losses each year.

When capital losses exceed $3,000, the excess can be carried forward to future years. For example, a $9,000 net capital loss can be spread over three tax years.

Correction—Dec. 3, 2022: A previous version of this article incorrectly described the IRS rules for deducting short- and long-term capital losses. For both short- and long-term losses, you can deduct up to $3,000 in net capital losses every year, not $3,000 in total losses.

Article Sources
Investopedia requires writers to use primary sources to support their work. These include white papers, government data, original reporting, and interviews with industry experts. We also reference original research from other reputable publishers where appropriate. You can learn more about the standards we follow in producing accurate, unbiased content in our editorial policy.
  1. Internal Revenue Service. "Topic No 409 Capital Gains and Losses."

  2. Internal Revenue Service. "Publication 550: Investment Income and Expenses," Pages 56-57.

  3. Internal Revenue Service. "Topic No. 409 Capital Gains and Losses."

Take the Next Step to Invest
The offers that appear in this table are from partnerships from which Investopedia receives compensation. This compensation may impact how and where listings appear. Investopedia does not include all offers available in the marketplace.