← Back to calculator
Tax Strategy · 2026

How to Avoid Capital Gains Tax (Legally) in 2026

Capital gains tax is often one of the largest avoidable taxes. Unlike payroll taxes that are automatically withheld, capital gains are often discretionary — you control when you sell, what you sell, how much you give away, and where you reinvest. The strategies on this page are all legal, IRS-compliant, and used by savvy investors every year to significantly reduce what they owe.

Before you read: Use our calculator to see your current estimated tax. Then as you read each strategy, you can estimate what each would save you. The more you understand the number, the more motivated you'll be to act.

Quick reference: all 8 strategies

#StrategyBest ForPotential Savings
1Hold over 1 year (long-term rates)Anyone within 1 year of holding7–17% of gain
20% bracket harvestingLower-income / semi-retiredUp to 15% of gain
3Tax-loss harvestingDiversified portfoliosDollar-for-dollar offset
4Primary home exclusionHomeownersUp to $75,000+ saved
5Donate appreciated stockCharitable givers15–23.8% on donated portion
6Tax-advantaged accountsLong-term savers100% of internal gains
71031 exchange (real estate)Real estate investors100% deferral
8Hold until death (step-up)Large inherited estates100% permanent elimination

1 Hold for more than one year

The single most universally applicable strategy. Hold any investment for more than 365 days and your gain qualifies for long-term capital gains rates (0%, 15%, or 20%) instead of your ordinary income rate (10%–37%). The difference is often dramatic:

This sounds obvious, but thousands of investors sell a day or week before the one-year mark without realizing the cost. Calendar your purchase dates and set a reminder 3 months ahead of the 1-year milestone.

2 Harvest gains in the 0% bracket

In 2026, taxpayers with taxable income under $49,450 (single) or $98,900 (MFJ) pay exactly 0% federal tax on long-term capital gains. These thresholds are after all deductions — including the standard deduction of $15,000 (single) or $30,000 (MFJ).

This means a single person can have up to $64,450 in total income (before the standard deduction) and owe nothing on long-term gains. A married couple can have up to $128,900.

When this applies

0% bracket gain harvesting — the "reset" strategy

If you have appreciated positions you plan to keep long-term, you can sell them in a 0% bracket year and immediately repurchase them (the wash-sale rule does not apply to gains, only losses). This resets your cost basis to the current price — permanently reducing future gains. If the stock later doubles, you will owe tax only on the appreciation above your new higher basis.

Example: You own 1,000 shares purchased at $10 (basis = $10,000), now worth $40 (current value = $40,000). In a low-income year, you sell all shares for a $30,000 long-term gain at 0% federal tax. You immediately repurchase 1,000 shares at $40 (new basis = $40,000). Future gains now start from $40, not $10 — permanently saving $4,500 in future federal tax at 15%.

3 Tax-loss harvesting

Capital losses directly offset capital gains dollar-for-dollar. By strategically selling underperforming positions to realize losses, you can reduce or eliminate the tax on gains elsewhere in your portfolio.

The mechanics

Wash-sale caution

You cannot repurchase the same or substantially identical security within 30 days before or after the sale. To stay invested in a sector, sell one fund and buy a different (but similar) fund. For example: sell your S&P 500 fund and buy a total market fund. The exposure is similar; the securities are different.

How much it saves

On a $50,000 gain offset by $50,000 in harvested losses: savings of $7,500 at 15% federal rate, or $13,000 at the combined 15% + 3.8% NIIT + 5% state rate for a typical mid-rate state resident.

4 The primary home exclusion

If you sell your primary residence and have lived in it for at least 2 of the last 5 years, you can exclude up to $250,000 of gain (single) or $500,000 (MFJ) completely from federal capital gains tax. See the full real estate guide for details, qualifications, and worked examples.

On a $500,000 gain for a married couple: $0 federal tax (with full exclusion). Without the exclusion and in the 20% bracket: $100,000 tax bill. The exclusion is one of the most valuable tax breaks in the entire tax code.

5 Donate appreciated stock to charity

Instead of selling appreciated stock and donating cash, donate the stock directly to a qualified charity or a Donor-Advised Fund (DAF). The benefits are substantial:

The math

You own Apple stock purchased at $5,000 now worth $55,000 (a $50,000 gain). You plan to donate $55,000 to charity.

Saving: $7,500 in federal tax — plus whatever state tax would have applied on the $50,000 gain. A DAF lets you take the deduction in a high-income year while distributing grants to charities over many years.

6 Use tax-advantaged accounts

Assets held inside these account types are fully sheltered from capital gains tax:

Account TypeTax Treatment of Gains2026 Contribution Limit
Roth IRATax-free growth and withdrawal$7,000 ($8,000 if 50+)
Traditional IRATax-deferred (taxed as ordinary income on withdrawal)$7,000 ($8,000 if 50+)
401(k) / 403(b)Tax-deferred (traditional) or tax-free (Roth 401k)$23,500 ($31,000 if 50+)
HSATriple tax-free (if used for medical expenses)$4,300 (self) / $8,550 (family)
529 PlanTax-free growth and withdrawal for educationNo annual federal limit

Selling a stock that doubled within a Roth IRA costs you nothing. The same sale in a taxable account costs 15–23.8% in federal tax plus state. Every dollar of net investment income that you keep in tax-advantaged accounts is permanently protected.

Roth conversions to reduce future capital gains exposure

Converting a traditional IRA to a Roth IRA in low-income years accelerates ordinary income tax now (at current lower rates) but ensures future gains and withdrawals are completely tax-free. This is especially powerful in early retirement years before Social Security begins.

7 1031 exchange for investment real estate

When selling investment real estate, a Section 1031 like-kind exchange allows you to defer 100% of capital gains tax — including depreciation recapture — by rolling proceeds into a replacement property within 180 days. See the full real estate guide for rules, timelines, and examples.

The deferral is indefinitely renewable — each new exchange continues it. If you eventually hold the replacement property until death, your heirs get a stepped-up basis and the accumulated deferred tax is permanently eliminated.

8 Hold appreciated assets until death

Under current law, assets transferred at death receive a stepped-up cost basis equal to fair market value on the date of death. All embedded capital gains accumulated during the decedent's lifetime are permanently forgiven — they are never taxed.

For very large, highly appreciated positions (founder stock, inherited real estate, long-held index funds), holding until death can save tens or hundreds of thousands in capital gains tax. Estate tax may apply separately, but for most estates below the $13.99 million (2026) federal exemption, this is a dominant strategy.

Note: This strategy requires estate planning to be executed properly. "Holding until death" is a deliberate plan, not an accident. Work with an estate attorney to ensure proper titling and beneficiary designations.

Frequently asked questions

Can I put capital gains into a 401k to avoid tax?

No — you cannot contribute capital gains directly to a 401k or IRA. These accounts only accept contributions from earned income (wages, self-employment income). However, maximizing your 401k contributions reduces your ordinary taxable income, which can indirectly move more of your capital gains income into the 0% or 15% bracket.

Does moving to a no-income-tax state avoid capital gains?

Moving to a state with no income tax (Florida, Texas, Nevada, etc.) before selling eliminates state capital gains tax. However, you must establish genuine domicile in the new state — keeping a residence, updating driver's license and voter registration, and spending the majority of your time there. Your previous state may audit the timing of your move relative to a large gain, especially California and New York which are aggressive about challenging part-year residency claims.

What is a Qualified Opportunity Zone (QOZ)?

A QOZ is a designated low-income community where investments receive special tax treatment. Reinvesting capital gains into a Qualified Opportunity Fund within 180 days of a sale can: (a) defer the original gain's tax until you exit the fund or December 31, 2026; and (b) permanently exclude any appreciation within the fund from tax if the investment is held at least 10 years. QOZ investing is complex and speculative — some funds have underperformed. The tax benefits are real, but so is the investment risk.

Is it illegal to time asset sales to minimize taxes?

No — timing the sale of assets to minimize taxes is completely legal and widely practiced. The IRS explicitly allows this. Tax avoidance (reducing your tax bill through legal means) is different from tax evasion (illegally hiding income or assets). Every strategy on this page is tax avoidance — encouraged by Congress through the tax code itself.

Get your exact number first. Before planning, use our calculator to see what you currently owe. Then revisit each strategy above with your specific numbers in mind. The savings from strategies 1–3 alone can often exceed $10,000–$50,000 for investors with meaningful portfolios.