Answer · Planning levers

How to avoid capital gains tax

The gain is rarely avoidable; the rate very often is. Six timing and accounting choices the tax code explicitly contemplates, with the arithmetic for each.

Tax year 2026 figures. Last updated .

What "avoid" can and cannot mean

Worth being precise, because the phrase covers two very different things. Concealing a gain you realised is evasion, it is a crime, and nothing on this page is about that. Arranging your affairs so that a gain is taxed at a lower rate, in a different year, or not at all is avoidance — and the levers below are ones the statute explicitly provides.

The useful mental model: the gain itself is rarely avoidable once you have decided to sell. The rate is very often avoidable, because the rate is set by facts you control.

1. Cross the one-year line

The largest lever, and the one requiring the least ingenuity. Holding more than one year moves a gain off the ordinary income table and onto the 0/15/20 ladder.

For a single filer at $80,000 of salary that is roughly 22-24% becoming 15%. Higher up it is 37% becoming 20%. On a $200,000 gain the saving exceeds $30,000, and the only requirement is a sale date.

2. Realise in a low-income year

Because the rate depends on total taxable income, the same gain costs different amounts in different years. A single filer whose taxable income including the gain stays at or below $49,450 pays nothing federally on a long-term gain.

A gap between jobs, a sabbatical, the years between retiring and drawing a pension, a year with business losses — these are the windows where a deliberately realised gain can be free. It also resets your basis upward at no cost, which reduces the taxable gain on a future sale.

3. Split the disposal across two tax years

Selling half in December and half in January puts each half lower in its own year’s stack. Where a single sale would push the top slice into the 20% band or over the net investment income tax threshold, two smaller ones may not.

This works best when the gain is large relative to your ordinary income, and not at all when your income already exceeds the ceilings on its own.

4. Harvest losses deliberately

Realising losses in the same year as gains offsets them dollar for dollar, and the netting rules apply short-term losses against short-term gains first — sheltering the most expensively taxed gains before anything else.

Excess losses offset up to $3,000 of ordinary income a year and carry forward indefinitely with no expiry. Mind the wash sale rule: buying a substantially identical security within thirty days before or after the sale disallows the loss.

5. Watch the net investment income tax threshold

The 3.8% surtax begins at $200,000 of modified AGI single, $250,000 joint. Because it applies to the lesser of net investment income and the excess over the threshold, keeping modified AGI just below the line can remove the tax entirely rather than reducing it.

Note this threshold is measured on modified AGI, before the deduction — so the levers that move it are different from the ones that move taxable income. Deductible retirement contributions reduce AGI; the standard deduction does not.

6. Give the asset away, or leave it

Appreciated assets donated to a qualifying charity generally avoid the gain entirely while producing a deduction based on market value, which is the rare lever that helps on both sides of the return.

Assets held until death generally receive a stepped-up basis, extinguishing the unrealised gain for the heirs. That is a real feature of the system rather than a loophole, and it is why "never sell" is sometimes the tax-optimal answer — though organising a portfolio around it is a decision with obvious non-tax costs.

What this page is not

These are levers, not advice. Which apply to you depends on facts this site cannot see, and several interact with rules — wash sales, the alternative minimum tax, state conformity — that the calculator does not model. Run the numbers here, then take them to a CPA or enrolled agent before acting.

Retirement accounts change the question entirely

Inside a 401(k), a traditional IRA or a Roth, there is no capital gains tax at all. Trades do not generate taxable events, so rebalancing is free and holding period is irrelevant.

What differs is the treatment on the way out. Traditional accounts tax withdrawals as ordinary income — so a long-term gain earned inside one is ultimately taxed at ordinary rates, not the preferential ladder. Roth accounts, funded with taxed money, generally come out free.

The practical implication is about asset location rather than avoidance: assets throwing off short-term gains or non-qualified income are better held in a tax-sheltered account, while assets you intend to hold for years and leave to heirs may be better in a taxable one, where the stepped-up basis applies and the preferential rates are available.

What does not work

Reinvesting the proceeds does not defer anything. Selling shares and immediately buying different shares is a completed disposal; the gain is taxable in that year regardless of what the money does next. The 1031 exchange, which does defer, applies to real property held for investment and not to securities.

Selling at a loss and buying back immediately does not bank the loss — that is the wash sale rule.

Neither does moving to a no-income-tax state on the eve of a sale, at least not reliably. States apply residency tests and source rules, and several audit exactly this pattern. Gains sourced to real property in a state are generally taxable by that state whatever your residency.

And gifting an appreciated asset does not erase the gain: the recipient generally takes your basis and your holding period, so the gain travels with the asset.

Charitable giving, in a little more detail

Donating an appreciated asset directly to a qualifying charity is the one lever that helps on both sides of the return at once, and it is worth understanding why.

If you sell first and donate the cash, you realise the gain and pay tax on it, then deduct the donation. If you donate the asset itself, the charity sells it free of tax and you generally deduct its market value — so the embedded gain is never taxed at all, to anyone.

The asset needs to have been held more than a year for the deduction to be based on market value rather than basis, and percentage-of-AGI limits cap how much can be deducted in a year, with the excess carried forward. Donor-advised funds are commonly used to take the deduction in a high-income year while distributing to charities over time.

This is genuinely one of the more efficient provisions in the code for someone who was going to give anyway. It is not a way of coming out ahead on a gift, and it involves rules — qualified appraisals for some assets, substantiation requirements — that sit outside anything this calculator models.

The order to consider these in

The levers are not equally powerful and they are not independent. A rough order of consideration, for someone deciding whether and when to sell.

Start with the holding period, because it is the largest single saving and the easiest to act on. Then the year: is there a lower-income year coming, or is this one unusually low? Then losses, since harvesting is available right up to year end. Then the threshold checks — the 0% ceiling and the net investment income tax line — which decide whether splitting the disposal is worth the trouble.

Charitable and estate considerations sit outside that sequence, because they answer a different question: not when to sell, but whether to sell at all.

Worked example

Computed by the same engine that powers the calculator, at the moment this page was built — not typed in by hand. Open the derivation to see every rule and citation.

The same gain realised in a low-income year

A single filer between jobs, with $20,000 of income for the year, realises a $28,000 long-term gain.

Taxable income after deduction
$31,900
Taxable gain
$28,000
Tax owed without the sale
$390
Tax the sale added
$0
Total federal tax
$390
Effective rate on the gain
0%

Taxable income after the standard deduction stays inside the $49,450 zero-rate ceiling, so the federal tax on this gain is nothing at all — and the basis resets upward for free.

Caveats on this example (1)
  • Net investment income was derived from capital gains and qualified dividends only. Interest, non-qualified dividends, rents, royalties and passive business income inside ordinaryIncome are also net investment income under IRC 1411(c) and are not counted here.
Show the working — 10 steps, each with its citation
  1. Net short-term capital gain or loss for the year$0Short-term / long-term nettingIRC 1222; IRS Pub. 550

    Assets held one year or less. Taxed at ordinary rates if a net gain.

  2. Net long-term capital gain or loss for the year$28,000Short-term / long-term nettingIRC 1222; IRS Pub. 550

    Assets held more than one year. Eligible for the 0/15/20% rates.

  3. Standard deduction-$16,100Deduction from adjusted gross incomeRev. Proc. 2025-32 4.14(1) (IRC 63(c)(2))

    Adjusted gross income of $48,000 less $16,100.

  4. Taxable income$31,900Taxable incomeIRC 63(a)

    The figure the rate tables and the capital gain ceilings are both measured against.

  5. Ordinary income taxed at 10%$390Ordinary income tax bracketsRev. Proc. 2025-32 4.01 (IRC 1(j)(2))

    $3,900 of taxable income between $0 and $3,900.

  6. Ordinary income stacked below the long-term gain$3,900LTCG bracket stackingIRC 1(h); Schedule D Tax Worksheet, Form 1040 instructions

    Long-term gain is taxed by reference to where it sits ON TOP of $3,900 of other taxable income, not from the bottom of the rate table.

  7. Long-term gain taxed at 0%$0LTCG bracket stackingRev. Proc. 2025-32 4.03 (IRC 1(h), 1(j)(5))

    Taxable income stays at or below the $49,450 maximum zero-rate amount.

  8. Net investment income tax threshold$200,000IRC 1411 thresholdIRC 1411(a)-(b); 26 C.F.R. 1.1411-2

    Modified AGI of $48,000 against the $200,000 threshold for a single filer. This threshold is statutory and is not adjusted for inflation.

  9. Net investment income tax does not apply$0IRC 1411 thresholdIRC 1411(a)-(b); 26 C.F.R. 1.1411-2

    Modified AGI is $152,000 below the threshold.

  10. Total tax$390Sum of all tax stepsRev. Proc. 2025-32 (I.R.B. 2025-45)

    $390 on $48,000 of total income, an effective rate of 0.81%.

Run your own figures

Nothing you enter leaves your browser. The calculation runs locally and no values are transmitted or stored on a server — see the privacy page.

You
The sale
State

Related questions

How to avoid capital gains tax

The gain itself is rarely avoidable, but its rate very often is, because the rate is set by facts you control. Holding past one year moves the gain onto the 0/15/20% ladder. Realising in a low-income year can drop it into the 0% band outright. Splitting a disposal across two tax years keeps each half lower in the stack. Harvesting losses offsets gains dollar for dollar. Watching the net investment income tax threshold can save 3.8% on the whole amount. Each of these is a timing or accounting choice the statute expressly contemplates — none of it is evasion, which is concealing a gain you actually realised.

Can I offset capital gains with capital losses?

Yes, and the netting order is fixed: short-term losses against short-term gains and long-term against long-term first, then any remaining loss of one character offsets the other. If losses still exceed gains, up to $3,000 a year offsets ordinary income for individuals, and anything beyond that carries forward indefinitely. The carryforward does not expire.

Do I have to pay the 3.8% net investment income tax as well?

Only if your modified adjusted gross income exceeds $200,000 filing single or $250,000 jointly, and then only on the lesser of your net investment income and the amount by which you exceed the threshold. That “lesser of” matters: a taxpayer $10,000 over the threshold with a $400,000 gain pays 3.8% on $10,000, not on $400,000. The thresholds are fixed in statute and have never been indexed for inflation, so they capture more filers each year.

The full guide index lists every answer page, and the state comparison covers the state layer on top of these federal figures.