Investing, Savings & Tax

Capital Gains & Tax-Loss Harvesting Calculator

Capital gains are taxed under two entirely different regimes depending on one thing: whether you held the asset for more than a year. This calculator nets gains against losses in the order the tax code actually specifies, applies the correct rates, and models a tax-loss harvesting scenario — with the wash-sale rule explained rather than glossed over.

Tax assumptions: tax year 2026 · federal only

Your details

Your results

Estimate
Important: this is an estimate, not advice

This calculator provides estimates for educational and informational purposes only. It does not constitute financial, investment, legal, accounting, or tax advice. Results are based on the assumptions and information entered and may differ materially from actual outcomes. Tax rules and financial regulations can change. Consult an appropriately qualified professional for advice specific to your situation.

Federal only. State capital gains tax is not modelled and can be substantial. Collectibles, qualified small business stock, depreciation recapture and the primary residence exclusion follow different rules not applied here.

Advertisement
Ad space
  • Multiple positions supported, netted in the statutory order rather than lumped together.
  • Long-term gains correctly stacked on top of ordinary income, which is what makes the 0% band work.
  • The $3,000 ordinary income offset and the indefinite carryforward both modelled.
  • Wash-sale rule explained in full whenever you model a harvested loss.

Short-term and long-term: the one-year line

The holding period is measured from the day after purchase to the day of sale. More than one year is long-term; one year or less is short-term. That single distinction changes the rate dramatically.

Short-term gains are ordinary income. They are added to your wages and taxed at your marginal rate, which for 2026 runs from 10% up to 37%. There is no preferential treatment whatsoever.

Long-term gains have their own schedule with three rates — 0%, 15% and 20% — and thresholds separate from the ordinary brackets. For 2026:

RateSingleMarried filing jointlyHead of household
0%up to $49,450up to $98,900up to $66,200
15%to $545,500to $613,700to $579,600
20%above $545,500above $613,700above $579,600

Selling one day too early can move a gain from 15% to 24%, or from 0% to 12%. On a $30,000 gain that is thousands of dollars for a single day of patience. It is worth checking the purchase date before selling anything with a substantial gain.

Why long-term gains are stacked on top of ordinary income

This is the part most explanations get wrong, and it is why two people with identical gains can pay very different tax.

The thresholds in the table above are levels of total taxable income, not levels of gain. Ordinary income fills the space first, and gains stack on top of it.

A single filer with $30,000 of ordinary taxable income and a $30,000 long-term gain: the ordinary income occupies the first $30,000, so the gain sits from $30,000 to $60,000. The portion up to $49,450 is taxed at 0%, and the remaining $10,550 at 15%.

The same $30,000 gain for a filer with $95,000 of ordinary income sits entirely above the 0% threshold and is taxed at 15% throughout.

gains are taxed in the band where they land,
after ordinary income has filled the space below.

  taxable ordinary income  →  fills from $0 upward
  long-term gains          →  stack on top of that

This has a real planning implication: in a low-income year, there may be room to realise gains at 0%. Deliberately selling appreciated assets to use that room — and immediately repurchasing, which is permitted because the wash-sale rule applies only to losses — resets your cost basis higher at no tax cost. The calculator's stacking is exact, so you can test how much room you have.

The netting order

Gains and losses are combined in a specific sequence, and the order matters because short-term and long-term are taxed differently.

  1. Short-term gains net against short-term losses.
  2. Long-term gains net against long-term losses.
  3. If one category is negative and the other positive, they offset each other.
  4. A remaining net loss offsets ordinary income, up to $3,000 a year ($1,500 married filing separately).
  5. Anything beyond that carries forward indefinitely, keeping its short-term or long-term character.

Because short-term gains are taxed at the higher ordinary rate, losses that offset short-term gains are worth more than losses that offset long-term gains. That is a genuine consideration when deciding which lots to realise.

Your results include a step-by-step table showing exactly how your positions moved through this sequence.

Tax-loss harvesting: what it is and what it is worth

Tax-loss harvesting means deliberately selling a position at a loss to realise the loss for tax purposes, then reinvesting in something similar so your market exposure is unchanged.

The benefit comes from three places: offsetting gains you would otherwise pay tax on, offsetting up to $3,000 of ordinary income at your marginal rate, and building a carryforward for future years.

The honest accounting. Harvesting mostly defers tax rather than eliminating it. Selling at a loss and buying a replacement lowers your cost basis, which means a larger taxable gain when you eventually sell the replacement. What you gain is the time value of the deferred tax, plus the possibility that the eventual gain is taxed at a lower rate than the deduction saved — for instance, offsetting ordinary income at 24% today and paying 15% on the gain later. That is a real benefit. It is smaller than the headline saving suggests, and this calculator says so in the results rather than only here.

Two situations where the benefit is largest: a high current marginal rate against an expected lower rate later, and a year with substantial short-term gains to offset.

One situation where it is worth nothing: if your income is low enough that your long-term gains would be taxed at 0% anyway, harvesting losses to offset them achieves nothing at all.

The wash-sale rule

This is the rule that turns tax-loss harvesting from a simple idea into something requiring care.

If you buy the same security, or one that is substantially identical, within 30 days before or after selling at a loss, the loss is disallowed. The window is 61 days in total — 30 before, the day of sale, and 30 after.

The loss is not destroyed: it is added to the cost basis of the replacement shares, so you get the benefit eventually. But you do not get it this year, which is usually the entire point of the exercise.

Where people get caught:

  • Automatic dividend reinvestment. A reinvested dividend is a purchase. If it falls inside the window, it triggers the rule on at least part of the loss — and it happens without any decision on your part.
  • Purchases in your IRA. Buying the same security in a retirement account within the window disallows the loss in your taxable account, and in that case the basis adjustment is lost entirely rather than deferred.
  • A spouse's account. Purchases by a spouse count.
  • Buying before selling. The 30 days before the sale count too, which catches people who buy more of a falling position and then sell the original lot.
  • "Substantially identical" is not fully defined. Two different S&P 500 index funds from different providers are generally treated as not substantially identical, but the standard is not bright-line and reasonable caution is warranted.

The usual practical approach is to replace the sold position with something similar but clearly different — a different index tracking a related but distinct benchmark — and to switch off automatic dividend reinvestment on positions you might harvest.

Rules this calculator does not apply

Several categories of gain follow different rules, and using this tool for them will give the wrong answer:

  • Collectibles — art, coins, precious metals and similar — are taxed at a maximum rate of 28% on long-term gains rather than the usual schedule.
  • Qualified small business stock can qualify for a substantial exclusion under specific conditions.
  • Real estate depreciation recapture is taxed at up to 25% on the portion attributable to depreciation previously claimed.
  • A primary residence benefits from an exclusion of gain if you have lived there for two of the last five years.
  • Inherited assets generally receive a step-up in basis to the value at the date of death, often eliminating the gain entirely.
  • Gifted assets generally carry over the giver's basis and holding period.

The calculator also does not model the alternative minimum tax, state capital gains tax, or credits of any kind. It does apply the 3.8% net investment income tax when adjusted gross income exceeds the statutory threshold — that threshold is set by law and is not indexed for inflation, so more people cross it every year.

Common mistakes

Selling just before the one-year mark. The most expensive avoidable error in this area. Check the purchase date.

Forgetting the wash-sale rule. Particularly through automatic dividend reinvestment, which triggers it silently.

Not tracking carryforwards. Unused losses carry forward indefinitely, but only if you know they exist. They are easy to lose track of across years and across brokerages.

Assuming the broker's cost basis is right. Brokers report basis for covered securities, but transfers between institutions, corporate actions, gifts and inheritances can all produce errors. You are responsible for the figure on your return.

Letting tax drive the investment decision. Holding a position you would otherwise sell purely to reach the one-year mark, or selling a good long-term holding to harvest a small loss, is letting the tail wag the dog. Tax considerations should refine a decision, not make it.

Ignoring which specific lot you are selling. If you bought the same security at different times and prices, you can usually specify which shares to sell rather than accepting first-in-first-out. That choice can change both the size of the gain and its character.

Frequently asked questions