How to offset capital gains with capital losses

TrackMyShares Team

One of the most valuable tools in a US investor's tax toolkit is the ability to use capital losses to offset capital gains. When you sell an investment at a loss, that loss can directly reduce the amount of tax you owe on your profitable sales. The IRS has specific rules about how this offset works, including a netting process that determines how short-term and long-term gains and losses interact.

In this guide, we walk through the netting process step by step, explain the $3,000 deduction rule, cover loss carryforwards, and show how to put it all together for effective tax management.

Disclaimer: This article is for informational purposes only and does not constitute financial or tax advice. Consult a qualified tax professional before making investment decisions based on tax considerations.

The basic principle: losses offset gains dollar for dollar

When you sell a stock at a loss, that realized capital loss can be used to reduce your taxable capital gains. A $5,000 loss offsets $5,000 of gains, reducing your taxable gain by that full amount.

This offset is powerful because capital gains can be taxed at rates as high as 37% (for short-term gains at the highest income levels). Every dollar of gain you offset with a loss is a dollar you do not pay tax on.

However, the IRS does not let you simply subtract total losses from total gains. Instead, there is a specific netting process that determines how different types of gains and losses interact.

The netting process

The IRS requires you to net your capital gains and losses in a specific order. Understanding this process is important because the order affects how much tax you ultimately owe.

Step 1: Net short-term gains and losses against each other

First, add up all your short-term capital gains and all your short-term capital losses for the year. The result is either a net short-term gain or a net short-term loss.

Short-term gains are taxed at ordinary income rates (10% to 37%), so offsetting them with short-term losses provides the greatest tax benefit per dollar of loss.

Step 2: Net long-term gains and losses against each other

Next, do the same with your long-term capital gains and losses. Add up all long-term gains and all long-term losses to arrive at a net long-term gain or net long-term loss.

Long-term gains are taxed at preferential rates (0%, 15%, or 20%), so the tax savings from offsetting long-term gains are lower per dollar, but the offset is still valuable.

Step 3: Cross-offset if one category has a net gain and the other has a net loss

If you have a net short-term gain and a net long-term loss (or vice versa), the loss offsets the gain across categories. This is where the netting process becomes particularly interesting from a tax perspective.

A net long-term loss offsetting a net short-term gain is especially beneficial because you are using a loss that would have saved you taxes at the lower long-term rate to eliminate a gain that would have been taxed at the higher ordinary income rate.

Conversely, a net short-term loss offsetting a net long-term gain is less tax-efficient because you are using a loss from the higher-rate category to eliminate a gain from the lower-rate category. However, it still reduces your total tax bill.

Worked example: the full netting process

Let's walk through a complete example. Suppose in 2026 you have the following realized gains and losses:

  • Short-term capital gain: $8,000 (from selling Stock A, held for 6 months)
  • Short-term capital loss: $3,000 (from selling Stock B, held for 4 months)
  • Long-term capital gain: $5,000 (from selling Stock C, held for 2 years)
  • Long-term capital loss: $7,000 (from selling Stock D, held for 18 months)

Here is how the netting works:

Step 1: Net short-term

Short-term gains: $8,000 Short-term losses: ($3,000) Net short-term gain: $5,000

Step 2: Net long-term

Long-term gains: $5,000 Long-term losses: ($7,000) Net long-term loss: ($2,000)

Step 3: Cross-offset

Net short-term gain: $5,000 Net long-term loss: ($2,000) Net capital gain: $3,000 (short-term character)

The result is a net short-term capital gain of $3,000. This is taxed at your ordinary income rate.

Tax calculation

Assume you are a single filer with $90,000 in salary income. The $3,000 net short-term gain is taxed at your marginal rate of 22%.

Tax on the $3,000 gain: $3,000 x 22% = $660

Without the losses, you would have owed tax on $8,000 in short-term gains ($8,000 x 22% = $1,760) plus $5,000 in long-term gains ($5,000 x 15% = $750), for a total of $2,510. The $10,000 in total losses saved you $1,850 in tax.

The $3,000 deduction rule

What happens when your total capital losses for the year exceed your total capital gains? The IRS allows you to deduct up to $3,000 of net capital losses against ordinary income per year ($1,500 if married filing separately).

This is a powerful provision because it lets you use investment losses to reduce the tax on your salary, wages, and other earned income, not just your investment gains.

Worked example: the $3,000 deduction

Suppose in 2026 you have:

  • Total capital gains: $2,000
  • Total capital losses: $9,000
  • Net capital loss: ($7,000)

The first $2,000 of losses offsets the $2,000 in gains (no tax owed on the gains). Of the remaining $5,000 in net losses, you can deduct $3,000 against ordinary income this year.

If you are in the 24% tax bracket, the $3,000 deduction saves you $3,000 x 24% = $720 in tax on your ordinary income.

The remaining $2,000 in unused losses carries forward to the next year.

Worked example: no gains at all

If you had no capital gains during the year and $10,000 in capital losses:

  • Year 1: Deduct $3,000 against ordinary income. $7,000 carries forward.
  • Year 2: Deduct $3,000 against ordinary income (assuming no gains to offset). $4,000 carries forward.
  • Year 3: Deduct $3,000 against ordinary income. $1,000 carries forward.
  • Year 4: Deduct the remaining $1,000 against ordinary income.

It takes four years to fully use the $10,000 in losses if you have no gains to offset them. However, if you realize gains in any of those future years, the carried-forward losses offset those gains dollar for dollar before the $3,000 ordinary income deduction kicks in.

Loss carryforward rules

Excess capital losses carry forward to future tax years indefinitely. There is no time limit on how long you can carry a loss forward. This means a large loss from a bad year is never wasted. It will eventually reduce your taxes, either by offsetting future gains or through the annual $3,000 ordinary income deduction.

Tracking your carryforward

The IRS does not automatically track your loss carryforward for you. It is your responsibility to calculate the carryforward amount each year and apply it correctly on your future tax returns.

Your carryforward amount is reported on Schedule D of your tax return. The Capital Loss Carryover Worksheet in the Schedule D instructions helps you calculate the amount to carry forward. Your tax preparation software should handle this automatically if you use the same software each year, but if you switch software or prepare your return manually, you need to carry the amount over yourself.

What carries forward: character preservation

An important detail: the carried-forward loss retains its character as short-term or long-term. If you carry forward $5,000 in long-term losses, they are treated as long-term losses in the following year and first offset long-term gains before crossing over to offset short-term gains.

This character preservation matters because short-term losses are generally more valuable (they first offset gains taxed at higher ordinary income rates). When planning which losses to realize, keep in mind that short-term losses provide greater tax benefit if your realized gains are also short-term.

Tax-loss harvesting: intentionally realizing losses

Tax-loss harvesting is the practice of deliberately selling investments that have declined in value to realize capital losses. These losses then offset realized gains elsewhere in your portfolio.

The strategy works like this:

  1. Review your portfolio for holdings with unrealized losses
  2. Sell those holdings to realize the losses
  3. Use the losses to offset gains you have already realized (or expect to realize) during the same calendar year
  4. Optionally, reinvest in a similar (but not substantially identical) security to maintain your market exposure

Tax-loss harvesting is most valuable when you have significant realized short-term gains, because offsetting those gains saves you the most in taxes. A $5,000 short-term loss offsetting a $5,000 short-term gain saves you $1,200 at the 24% bracket. The same $5,000 loss offsetting a $5,000 long-term gain saves only $750 at the 15% rate.

For a complete guide to this strategy, including how to identify opportunities and avoid pitfalls, see our guide on tax-loss harvesting for US investors.

Wash sale interaction

The wash sale rule is the most important constraint on using capital losses. If you sell a security at a loss and buy the same or a "substantially identical" security within 30 days before or after the sale, the IRS disallows the loss.

The 61-day window

The wash sale window spans:

  • 30 days before the sale
  • The day of the sale
  • 30 days after the sale

Any purchase of the same security within this 61-day window triggers the wash sale rule and disallows the loss.

What happens to a disallowed loss

The loss is not permanently lost. Instead, it is added to the cost basis of the replacement shares. This means the loss is deferred rather than eliminated. You will eventually benefit from the higher cost basis when you sell the replacement shares (assuming you do not trigger another wash sale).

Worked example: wash sale

You own 100 shares of XYZ Corp purchased at $50 per share. The stock drops to $35, and you sell all 100 shares to realize a $1,500 loss ($15 per share x 100 shares). Three weeks later, the stock drops to $30 and you buy 100 shares back.

Because you repurchased within 30 days, the $1,500 loss is disallowed. Instead, the disallowed loss is added to the cost basis of your new shares:

  • New purchase price: $30 per share
  • Disallowed loss added: $15 per share
  • Adjusted cost basis: $45 per share

If you later sell the new shares at $50, your gain is $5 per share ($50 - $45) instead of $20 per share ($50 - $30). You eventually benefit from the higher cost basis, but you lost the immediate tax benefit of the $1,500 loss.

Avoiding wash sales

To avoid the wash sale rule while still maintaining market exposure, you can:

  • Wait 31 days before rebuying the same security
  • Buy a different security in the same sector or asset class (for example, selling one large-cap ETF and buying a different large-cap ETF)
  • Buy the replacement security first, wait 31 days, then sell the losing position (though this doubles your exposure temporarily)

For a detailed discussion of the wash sale rule and its interaction with tax-loss harvesting, see our tax-loss harvesting guide.

Timing considerations

Capital gains and losses are calculated on a calendar-year basis (January 1 through December 31). This creates important timing considerations.

End-of-year review

November and December are critical months for tax planning. By this point in the year, you know most of your realized gains and can estimate your total tax liability. This is the time to review your portfolio for unrealized losses that could offset those gains.

The December 31 deadline

To count against the current year's gains, a loss must be realized by December 31. This means the trade must be executed (not just settled) by the last trading day of the year. For 2026, the last trading day is December 31 (a Thursday).

Do not wait until the last day. Unusual market conditions, trading halts, or simple mistakes could prevent you from executing the trade. Aim to complete your tax-loss harvesting by mid-December to leave a buffer.

January considerations

If you realize a loss in late December and want to rebuy the same security, you need to wait until at least 31 days later (late January) to avoid the wash sale rule. This means you will be out of the position for about a month, during which the price could move against you.

Alternatively, you can buy a similar (but not substantially identical) security immediately after selling, maintaining your market exposure without triggering the wash sale rule.

Multi-year planning

Because losses carry forward indefinitely, tax planning should extend beyond a single year. If you expect to have large capital gains next year (from selling a concentrated position, for example), it may make sense to start harvesting losses this year and carry them forward.

Similarly, if you are in a low-income year and your gains would be taxed at 0% (for long-term) or 10-12% (for short-term), it may not make sense to harvest losses this year. Instead, save those losses for a future year when your income (and tax rate) is higher.

How TrackMyShares helps

TrackMyShares provides several tools to help you manage the gain/loss offset process effectively.

Tax-loss harvesting tool

The tax-loss harvesting tool automatically scans your portfolio for holdings with unrealized losses. For each opportunity, it shows:

  • The unrealized loss amount
  • Whether selling would offset short-term or long-term gains
  • The estimated tax savings based on your marginal tax rate
  • A recommended action (sell all, sell partial, or hold)

This saves you from manually reviewing each position to identify harvesting opportunities.

Wash sale detection

TrackMyShares includes wash sale detection that alerts you when a sale and repurchase pattern could trigger the wash sale rule. This helps you avoid inadvertently disallowing a loss you intended to claim.

Gain and loss summary by holding period

The US capital gains tax report provides a clear summary of your realized gains and losses, broken down by short-term and long-term. You can see the netting result and your estimated net capital gain or loss for the year at any time, not just at tax time.

Lot-level tracking

Every purchase is tracked as a separate tax lot with its own cost basis, purchase date, and holding period. When you record a sale, TrackMyShares identifies which lots were sold and calculates the gain or loss for each one. This lot-level detail is essential for accurate tax reporting and for implementing specific lot identification strategies.

Year-round monitoring

Because stock prices in TrackMyShares are updated throughout the day, you can monitor your unrealized gains and losses with current market data. This helps you identify harvesting opportunities as they arise, rather than only during an end-of-year review.


Using capital losses to offset capital gains is one of the most straightforward ways to reduce your investment tax bill. The netting process, the $3,000 ordinary income deduction, and indefinite loss carryforwards give you multiple ways to benefit from losses, whether they offset this year's gains or future years'.

Sign up for TrackMyShares to track your gains and losses, identify tax-loss harvesting opportunities, and generate tax reports that show your net capital gain position for the year.