Taxstra Logo
Investment Tax Guide

How to Avoid Capital Gains Tax on Stocks (2026)

Legal ways to reduce, defer or eliminate capital gains tax on stocks in 2026: holding periods, the 0% bracket, loss harvesting, gifts and step-up.

★ 5.0 on Google113 reviews4.9 from 114 BiggerPockets reviews1,000+ clientsAll 50 states, fully remote

Quick answer

You cannot avoid capital gains tax on stocks by reinvesting the proceeds, and 1031 exchanges do not apply to stocks. You can legally reduce, defer or eliminate it: hold shares more than one year, sell in years when your taxable income keeps the gain in the 0 percent bracket (up to $98,900 for joint filers in 2026), harvest losses, pick high-basis lots, keep trading inside retirement accounts, give appreciated shares instead of cash, and hold the rest until death for a basis step-up.

Reduce, defer or eliminate: the three outcomes

Every legitimate strategy for stock gains does one of three things. It reduces the tax (a lower rate or a smaller gain), defers it (the gain is still there, just later), or eliminates it (the gain is never taxed to anyone). Knowing which one you are getting is the difference between planning and a surprise bill later.

This page is the menu for an ordinary stock portfolio: index funds, individual stocks, RSU shares you kept. Each strategy gets a short summary and a link to the page that covers it in full. If one holding makes up most of your net worth, start with our concentrated stock position guide instead.

This is tax education, not individualized tax advice. Taxstra does not sell investments or recommend securities.

Only a few strategies make the gain disappear

Selling inside the 0 percent bracket, trading inside a Roth account, giving shares to charity, holding until death and the QSBS exclusion are the main ways a gain is never taxed. Loss harvesting, exchange funds and most other tools defer the gain. Deferral is still valuable, because money not paid in tax keeps compounding, but it is not the same thing.

What does not work

If someone promises to make stock gains vanish without one of the strategies below, ask exactly which code section does the work. Real strategies have one.

  • Reinvesting the proceeds. Buying other stocks or funds with the money does not defer the tax on the gain you realized. The sale is taxed in the year it happens.
  • A 1031 exchange. Since 2018, section 1031 applies only to real property. Stocks, funds and other securities do not qualify.
  • An installment sale of public stock. Section 453(k)(2) bars the installment method for stock traded on an established securities market, so the whole gain is taxed in the year of sale even if you are paid later.
  • Selling at a loss and buying back within 30 days. The wash sale rule disallows the loss for now and adds it to the basis of the new shares.

Strategy 1: Hold more than one year

Shares held one year or less produce short-term gain, taxed at your ordinary income rates, up to 37 percent. Shares held more than one year produce long-term gain, taxed at 0, 15 or 20 percent depending on your taxable income. Waiting one more day can cut the federal rate on a gain nearly in half.

The 3.8 percent net investment income tax applies on top of either rate once modified AGI is above $250,000 for joint filers or $200,000 for single filers. Those thresholds are not indexed for inflation.

2026 long-term capital gain rates by taxable income
RateSingleMarried filing jointlyHead of household
0%Up to $49,450Up to $98,900Up to $66,200
15%$49,451 to $545,500$98,901 to $613,700$66,201 to $579,600
20%Over $545,500Over $613,700Over $579,600

Source: IRS Rev. Proc. 2025-32, sec. 4.03. Thresholds apply to total taxable income, with gains stacked on top of ordinary income.

How the brackets stack, with 2027 figures, is on our capital gains tax rates page.

Strategy 2: Sell in a year the 0 percent bracket covers the gain

Long-term gain is taxed at 0 percent federally to the extent your taxable income, including the gain, stays at or below $98,900 for joint filers in 2026 ($49,450 single). Years between jobs, early retirement before Social Security and required distributions start, a sabbatical or a year of large business losses can open that room.

Suppose a retired couple has $60,000 of taxable income in 2026 before any sales. They can realize up to $38,900 of long-term gain at a 0 percent federal rate. Because the wash sale rule applies only to losses, they can buy the same shares back right away and start over with a higher basis. That is often called gain harvesting.

A 0 percent gain is still income. It raises AGI, which can affect state income tax, Medicare premium surcharges, premium tax credits and the taxable share of Social Security benefits. Model those before you harvest.

Strategy 3: Harvest losses to offset gains

Selling positions that are down produces capital losses. Losses first offset capital gains without limit, then up to $3,000 of other income a year ($1,500 married filing separately), and any excess carries forward with no time limit.

The wash sale rule disallows a loss if you buy substantially identical stock or securities within 30 days before or after the sale, including in an IRA. The usual answer is to reinvest in something similar but not substantially identical. Harvesting mostly defers tax, because the replacement has a lower basis, but losses used against short-term gains or ordinary income at high rates can be a permanent saving.

See our tax loss harvesting guide, direct indexing for harvesting at the single-stock level, and how a capital loss carryover works.

Strategy 4: Choose which shares you sell

If you bought the same stock or fund at different times, each purchase is a separate lot with its own basis. Unless you identify the lots you are selling to your broker by the time of the sale, the default is first-in, first-out (mutual fund shares can also use average basis), which usually means selling the oldest, lowest-basis shares and realizing the most gain.

Specific identification lets you sell the highest-basis lots first, or long-term lots at a loss before short-term lots at a gain. Most brokers let you set a default method or pick lots on each sale.

RSU shares are a common trap: the value taxed as wages at vesting is your basis, but broker forms often show a lower or zero basis. Reporting the form as is taxes the same income twice.

See how RSU cost basis works.

Strategy 5: Let growth happen inside retirement accounts

IRAs, 401(k)s and similar plans are exempt from tax, so you can rebalance and sell inside them without any capital gain tax. Traditional account withdrawals are later taxed as ordinary income; qualified Roth distributions are tax-free, which makes a Roth the one account where gains are never taxed.

Asset location means placing the holdings you expect to trade or that throw off taxable income in tax-advantaged accounts and broad, low-turnover funds in taxable accounts. It changes how much of your future gain is ever exposed to capital gain tax.

See our asset location strategy.

Strategy 6: Give appreciated shares instead of cash

If you give to charity, giving shares you have held more than one year generally gets you a deduction at fair market value, and the built-in gain is never taxed to you or the charity. Gifts of appreciated stock to public charities and donor-advised funds are limited to 30 percent of AGI, with a five-year carryover. Starting in 2026, itemized charitable deductions are reduced by a floor of 0.5 percent of AGI, and taxpayers with income reaching the 37 percent bracket face a reduction in the value of their itemized deductions.

You can then use the cash you would have given to buy new shares at today’s price. Your portfolio is the same size, with a higher basis.

For larger gifts with an income stream back to you, a charitable remainder trust can sell contributed shares without tax at the trust level. You are taxed as payments come out, so the gain is spread over years rather than eliminated.

See the donor-advised fund tax deduction and our charitable remainder trust guide.

Strategy 7: Give shares to family in a lower bracket

A gift of shares carries your basis and holding period to the recipient. If an adult child or parent in the 0 or 15 percent bracket sells, the gain is taxed at their rate, not yours.

The kiddie tax blocks the easy version. Children under 18, and 18-year-olds and full-time students under 24 whose earned income does not exceed half their support, generally pay tax at the parents’ rate on unearned income above $2,700 in 2026. Gifts above the $19,000 annual exclusion per recipient in 2026 require a gift tax return, though tax is rarely owed. And once the shares are given, they belong to the recipient.

See how the kiddie tax works and the gift tax limit.

Strategy 8: Hold until death for a step-up in basis

Shares inherited from someone who dies generally take a basis equal to their fair market value at the date of death. The gain built up during the owner’s life is never taxed. For older investors with low-basis shares, not selling is often the most valuable decision on this list.

The cost is that you carry the investment risk until then. Selling from cash, bonds or high-basis lots first, and spending down retirement accounts in a planned order, keeps the lowest-basis shares available for the step-up.

See how the step-up in basis works.

Strategy 9: Special rules for startup stock and reinvested gains

Qualified small business stock: original-issue stock in a qualifying C corporation can have part or all of the gain excluded under section 1202. For stock acquired after July 4, 2025, the exclusion is 50 percent after three years, 75 percent after four and 100 percent after five, up to the greater of $15 million or 10 times basis per company. Founders and early employees should check this before selling anything.

Qualified opportunity funds: investing a capital gain in a qualified opportunity fund within 180 days defers it. Gain invested by December 31, 2026 is included in income in 2026 under the prior rules; gain invested after that is deferred five years with a 10 percent basis increase, and the fund investment’s own growth can be excluded after 10 years. It is a real estate or business investment with its own risk, not a tax product.

See QSBS under section 1202 and qualified opportunity funds.

Strategy 10: For one large position, the bigger tools

When one stock is a large share of your net worth, the options widen: selling in stages across tax years, contributing shares to an exchange fund that diversifies you without a sale (the low basis carries over), or a charitable remainder trust. These tools have minimums, fees and lockups that make them worth it only for large positions.

Compare them on our concentrated stock position guide and see how an exchange fund is taxed.

Capital gains tax strategies compared

This table compares the federal tax effect only. Investment risk, liquidity and family goals are separate questions.

Ways to cut capital gains tax on stocks
StrategyEffect on the gainTends to fit
Hold more than one yearReduces the rateAnyone who can wait
Sell in the 0 percent bracketEliminates, up to the thresholdLow-income years, early retirees
Harvest lossesMostly defers; can reduceTaxable accounts with losing positions
Choose high-basis lotsReduces gain now, defers the restAnyone who bought over time
Trade inside retirement accountsDefers; eliminates in a RothActive rebalancers
Give shares to charity or a DAFEliminates on the shares givenPeople who already give
Give shares to familyReduces the rateAdult family in lower brackets
Hold until deathEliminatesOlder investors with low basis
QSBSEliminates part or allFounders, early startup employees
Opportunity fundDefers; can exclude later growthLarge gains with a long horizon
Exchange fundDefersOne large, low-basis public stock

Educational summary of federal treatment. Each strategy depends on facts covered on its own page.

Worked example: the same sale, planned and unplanned

Suppose a married couple filing jointly needs $160,000 for a home purchase. They plan to sell $200,000 of an index fund bought years ago for $50,000, all long-term, and they also planned to give $40,000 in cash to charity this year. Their taxable income before the sale is $250,000 and their modified AGI is already above the $250,000 net investment income tax threshold, so the gain lands in the 15 percent bracket plus 3.8 percent.

In the planned version they harvest a $30,000 loss in another fund (reinvesting in a fund that is not substantially identical), give $40,000 of the low-basis fund shares to their donor-advised fund instead of cash, and sell $160,000 of the remaining shares, which carry $40,000 of basis. They end with the same $160,000 of cash and the same $40,000 charitable gift.

Worked example

Selling $200,000 of shares with a $50,000 basis

Unplanned: long-term gain
$150,000
Unplanned: federal tax at 15% plus 3.8%
$28,200
Planned: gain on the $160,000 sold
$120,000
Less harvested loss
($30,000)
Planned: net gain taxed
$90,000
Planned: federal tax at 15% plus 3.8%
$16,920
Federal tax this year, difference
$11,280 lower
Gain on the donated shares, never taxed
$30,000

Hypothetical round numbers. The charitable deduction is the same $40,000 either way, subject to the 2026 limits, assuming they itemize. Of the $60,000 less gain, the $30,000 on the donated shares is eliminated; the $30,000 from the harvested loss is mostly deferred, because the replacement fund has a lower basis. State tax is ignored. Educational, not individualized tax advice.

When to hire a CPA, and when you can handle it yourself

Holding past one year, setting your lot method and giving shares instead of cash are things most investors can do themselves with a broker and a calendar.

A CPA earns the fee when the strategies interact: a year-end projection that sizes gain harvesting under the 0 percent line, a large sale stacked on equity compensation and the 3.8 percent tax, a move between states, QSBS or opportunity fund elections, or a multi-year plan for a large position. Taxstra does that tax work once engaged, and coordinates with your investment adviser on what to sell.

What to check before you act

A practical review sequence for the return, books, or planning file.

Confirm the purchase date of every lot you might sell; long-term starts after one year.

Set your broker’s lot method to specific identification or a high-cost default.

Project this year’s taxable income to see how much gain fits under the 0 or 15 percent line.

List positions with unrealized losses and plan replacements that are not substantially identical.

Check the 30-day wash sale window across every account, including IRAs and a spouse’s accounts.

Use appreciated shares, not cash, for this year’s charitable gifts.

Mark the lowest-basis shares to hold for a step-up if they fit your estate plan.

Check whether any startup stock may qualify for QSBS before selling it.

“I recently had the pleasure of working with Taxstra, and I must say, the experience exceeded my expectations. From start to finish, their professionalism, expertise, and customer care were outstanding.”
Google Reviewer · Read on Google

Published client feedback. Individual experiences vary.

High income earner, business owner or landlord? Here is what this changes for you.

Book your free 30-minute tax fit call to talk through your next steps.

Common mistakes

The shortcuts most likely to produce a confident but wrong answer.

01

Thinking reinvesting defers the tax

Reinvesting does not defer anything. The sale is taxed in the year it happens, and 1031 exchanges are for real estate only.

02

Selling a day early

Shares held one year or less are short-term, taxed at ordinary rates up to 37 percent.

03

Triggering a wash sale in another account

Buying the same security within 30 days in an IRA or a spouse’s account can still disallow the loss.

04

Letting the broker pick lots

First-in, first-out usually sells the lowest-basis shares and realizes the most gain.

05

Double-counting RSU income

Using the broker’s zero or partial basis for vested RSU shares taxes the vesting income twice.

06

Giving cash while holding low-basis shares

A gift of appreciated shares held over a year generally gets the same deduction and also avoids the gain.

Frequently Asked Questions

How can I avoid capital gains tax on stocks?

You can legally reduce, defer or eliminate it: hold more than one year, sell in years when the gain fits in the 0 percent bracket, harvest losses, choose high-basis lots, trade inside retirement accounts, give appreciated shares to charity, and hold low-basis shares until death for a step-up in basis. Reinvesting the proceeds does not avoid the tax.

Do I pay capital gains tax if I reinvest the money?

Yes. Selling stock at a gain is taxable in the year of sale whether or not you reinvest. Section 1031 exchanges apply only to real property, not to stocks or funds.

How much stock can I sell without paying capital gains tax?

In 2026, long-term gains are taxed at 0 percent federally to the extent your total taxable income, including the gains, stays at or below $98,900 for joint filers, $49,450 for single filers and $66,200 for heads of household. State tax may still apply.

What is the best way to reduce capital gains tax?

It depends on your situation. For most investors, the biggest levers are holding more than one year, harvesting losses, choosing high-basis lots and giving appreciated shares instead of cash. For older investors with low-basis shares, holding until death for a step-up often saves the most.

Can capital losses offset capital gains on stocks?

Yes. Capital losses offset capital gains without limit, then up to $3,000 of other income a year ($1,500 married filing separately), with any excess carried forward indefinitely. The wash sale rule disallows a loss if you buy substantially identical shares within 30 days before or after the sale.

Does gifting stock avoid capital gains tax?

Giving shares to charity generally avoids the gain entirely. Giving shares to a family member does not erase the gain: they take your basis, but if they are in a lower bracket they pay their own rate when they sell. The kiddie tax applies to children under 18 and to many 18-year-olds and full-time students under 24.

Is the net investment income tax part of capital gains tax?

It is a separate 3.8 percent tax that applies to capital gains and other investment income once modified AGI exceeds $250,000 for joint filers or $200,000 for single filers. It stacks on top of the 15 or 20 percent rate.

Next Steps

Filing it yourself is fine. Optimizing it is where the money is.

Getting the form right keeps you out of trouble. The strategies below are what actually lower the bill.

Interested in working with Taxstra?

Book your free 30-minute tax fit call with our team. Tell us what you need, learn how Taxstra can help, and explore whether our services are a good fit. Tax advice, document reviews, and analysis require a paid engagement.

Tax planning slots are limited before year-end.