To avoid long-term capital gains tax on shares, you can time sales to fit inside the federal 0% bracket, offset gains with harvested losses, keep the investments inside tax-advantaged accounts, donate appreciated shares to charity, or hold them until death so heirs inherit a stepped-up basis. Narrower rules also erase gains on qualified small business stock and long-held opportunity zone investments. For the 2026 tax year, the 0% federal rate on long-term gains covers taxable income up to $49,450 for single filers and $98,900 for married couples filing jointly.
Sell Inside the 0% Long-Term Capital Gains Bracket
Under 26 U.S.C. ยง 1(h), long-term gains that fall inside the lowest ordinary income bracket are taxed at 0% instead of 15% or 20%.1Office of the Law Revision Counsel. 26 U.S. Code 1 – Tax Imposed For 2026, the 0% rate applies to taxable income up to:
- $49,450 for single filers
- $98,900 for married couples filing jointly
- $66,200 for head of household
Taxable income is what remains after the standard deduction. For 2026 that deduction is $16,100 (single), $32,200 (married filing jointly), and $24,150 (head of household).2Internal Revenue Service. IRS Releases Tax Inflation Adjustments for Tax Year 2026 A single filer with no other income above the standard deduction could realize up to $49,450 in long-term gains and owe nothing federally. Even someone with wages can use the bracket if total taxable income stays under the threshold.
The practical move is to time sales for low-income years. A gap between jobs, a sabbatical, or early retirement before Social Security kicks in all open a window. Pre-tax contributions to a traditional 401(k) or IRA pull taxable income down and create more room under the ceiling. Retirees drawing from Roth balances rather than traditional accounts can keep taxable income artificially low and sell shares tax-free alongside those withdrawals.
Pick Which Shares You Sell
When you own shares of the same stock bought at different times and prices, the IRS lets you choose which specific lots to sell. If you don’t specify, your broker sells the shares you bought first, which are often the lowest-basis lots and therefore the largest taxable gain.3Internal Revenue Service. Publication 550 – Investment Income and Expenses
Say you bought 100 shares at $20 five years ago and 100 more at $80 last year, and the stock now trades at $90. Selling the older lot triggers a $70 gain per share. Selling the newer lot triggers $10 per share, assuming the holding period qualifies as long-term. To use this method you have to identify the lot to your broker at the time of the trade and get written confirmation.4Internal Revenue Service. Publication 551 – Basis of Assets Most online brokers let you pick lots directly in the order screen.
Harvest Losses to Offset Gains
Selling shares that have dropped in value lets you use those losses against gains elsewhere in your portfolio. If losses exceed gains for the year, you can deduct up to $3,000 of the remainder against ordinary income; anything beyond that carries forward indefinitely.5Office of the Law Revision Counsel. 26 U.S.C. 1211 – Limitation on Capital Losses A large loss in one year can neutralize gains for several years afterward.
The catch is the wash sale rule. Sell a stock at a loss and buy the same stock, or a substantially identical one, within 30 days before or after the sale, and the IRS disallows the loss.6Office of the Law Revision Counsel. 26 U.S. Code 1091 – Loss From Wash Sales of Stock or Securities The disallowed loss is added to the basis of the replacement shares, so it isn’t lost forever, but you can’t use it now. Investors who want to stay invested through the 30-day window often buy a similar but not identical fund, such as selling one S&P 500 index fund and buying a total market fund.
Watch the retirement account trap. The IRS ruled that repurchasing the same security in an IRA or Roth IRA within the 30-day window still triggers the wash sale rule, and the disallowed loss does not increase your IRA basis.7Internal Revenue Service. Revenue Ruling 2008-5 The loss effectively disappears. When you harvest losses in a taxable account, check that your automatic retirement contributions aren’t buying the same security.
Hold Shares Inside Tax-Advantaged Accounts
Buying and selling inside a retirement or health savings account avoids capital gains tax entirely. Gains compound without an annual tax drag, and depending on the account type you may never owe capital gains tax on the growth.
Traditional 401(k) and IRA
Contributions to a traditional 401(k) or traditional IRA reduce your taxable income for the year, and the account grows tax-deferred. You can sell shares and reinvest inside the account without triggering tax. The trade-off is that every dollar withdrawn in retirement is taxed as ordinary income rather than at the lower capital gains rates.8Internal Revenue Service. Topic No. 409 – Capital Gains and Losses For 2026, the 401(k) limit is $24,500, with an $8,000 catch-up at 50 and $11,250 for ages 60 to 63. IRA contributions max out at $7,500, or $8,600 for those 50 and over.9Internal Revenue Service. 401(k) Limit Increases to $24,500 for 2026, IRA Limit Increases to $7,500
Roth IRA and Roth 401(k)
Roth accounts flip the equation. You contribute after-tax dollars with no upfront deduction, but qualified withdrawals of contributions and all gains come out completely tax-free.10Internal Revenue Service. Roth IRAs Shares that grow ten-fold inside a Roth never generate a dollar of capital gains tax. For investors decades from retirement, the long tax-free compounding window makes the Roth one of the strongest tools available.
Health Savings Account
An HSA offers a deduction on contributions, tax-free growth, and tax-free withdrawals for qualified medical expenses. Many HSA providers let you invest the balance in mutual funds or stocks once it clears a minimum. For 2026, contribution limits are $4,400 for individual coverage and $8,750 for family coverage, plus a $1,000 catch-up at 55. You need a high-deductible health plan to qualify.
Donate Appreciated Shares to Charity
Transferring shares directly to a qualifying charity lets you skip capital gains tax on the appreciation and claim a deduction for the full market value of the gift. The key is donating the shares themselves rather than selling first and giving cash. A sale triggers the gain on your return; a direct transfer means neither you nor the tax-exempt charity ever pays capital gains tax on the growth.11Internal Revenue Service. Publication 526 – Charitable Contributions
To claim the fair market value deduction, the shares must be long-term capital gain property, meaning held for more than one year. The deduction for appreciated stock donated to a public charity is capped at 30% of adjusted gross income, with a five-year carryforward for any excess. Donations of $250 or more need a written acknowledgment from the charity, and anything worth more than $5,000 requires a qualified appraisal.12Internal Revenue Service. Charitable Contributions Written Acknowledgments
The strategy works best with highly appreciated, low-basis shares. Bought at $5, now worth $50: donating eliminates $45 per share of gain and produces a $50 deduction. Selling and donating cash instead leaves you paying tax on the $45 gain.
Hold Until Death for the Step-Up in Basis
When someone inherits shares, the cost basis resets to the fair market value on the date of the prior owner’s death. All the appreciation that accumulated during the original owner’s lifetime is wiped out for tax purposes.13Office of the Law Revision Counsel. 26 U.S. Code 1014 – Basis of Property Acquired From a Decedent If a parent bought shares at $10 and they were worth $200 at death, the heir’s basis becomes $200. Sold the next day at $200, the tax is zero.
This isn’t a strategy you deploy on demand, but it shapes how families plan around appreciated stock. Holding large unrealized gains through the owner’s lifetime can save a generation of taxes, which is why estate planners often favor buy-and-hold for the most appreciated positions.
Note a boundary: shares given as a gift during the donor’s lifetime do not receive a step-up. The recipient inherits the donor’s original basis.14Office of the Law Revision Counsel. 26 U.S. Code 1015 – Basis of Property Acquired by Gifts and Transfers in Trust A parent who gifts stock with a $10 basis passes on that $10 basis; the same stock left through the estate resets to market value. The tax difference between the two paths can be large.
Qualified Small Business Stock
Section 1202 lets investors exclude up to 100% of the capital gains on qualified small business stock. The stock must be issued by a domestic C corporation whose gross assets did not exceed $75 million when the stock was issued.15Office of the Law Revision Counsel. 26 U.S.C. 1202 – Partial Exclusion for Gain From Certain Small Business Stock You must have acquired the stock at original issuance rather than on the secondary market and held it for at least five years.
Excludable gain is capped per issuer at the greater of $10 million or ten times your adjusted basis in the stock. Invest $500,000 in a qualifying startup and you could exclude up to $5 million in gains from that company. The corporation must also meet an active business requirement, using at least 80% of its assets in a qualifying trade or business. Finance, law, and hospitality are among the excluded industries.
This exclusion is one of the most generous provisions in the code, but it’s narrow. Publicly traded stock generally doesn’t qualify. It mainly helps founders, early employees, and angel investors in small C corporations who can hold five years or longer.
Qualified Opportunity Zone Investments
Section 1400Z-2 lets you defer capital gains by reinvesting them in a Qualified Opportunity Fund within 180 days of a sale. The larger benefit is permanent: hold the QOF investment for at least ten years and any appreciation on that QOF investment is completely tax-free when sold.16Office of the Law Revision Counsel. 26 U.S.C. 1400Z-2 – Special Rules for Capital Gains Invested in Opportunity Zones
A 2026 deadline matters for anyone already in a fund. All deferred gains previously rolled into a QOF must be recognized as income no later than December 31, 2026, whether or not you still hold the investment. A $100,000 gain deferred years ago hits the 2026 return. Existing QOF investors should be planning for that tax bill now rather than waiting for year-end.
For new investments in 2026, the deferral benefit is effectively gone, because a newly deferred gain would be recognized almost immediately on December 31, 2026. The ten-year exclusion on future appreciation still exists for QOF investments held long enough, which remains a meaningful incentive for investors willing to commit capital to designated opportunity zones for a decade.17Internal Revenue Service. Opportunity Zones Frequently Asked Questions
The 3.8% Net Investment Income Tax Sits on Top
Even after cutting the capital gains rate, higher earners face an extra 3.8% surtax on investment income. The Net Investment Income Tax applies to individuals with modified adjusted gross income above $200,000 (single) or $250,000 (married filing jointly), on the lesser of net investment income or the amount MAGI exceeds the threshold.18Office of the Law Revision Counsel. 26 U.S.C. 1411 – Imposition of Tax
These thresholds are not indexed for inflation. They have not changed since the tax was created in 2013 and will not adjust automatically, so more taxpayers cross the line each year as wages and portfolio values rise.19Internal Revenue Service. Questions and Answers on the Net Investment Income Tax Capital gains, dividends, rental income, and interest all count toward net investment income.
The NIIT stacks on top of whatever capital gains rate applies. An investor in the 15% long-term bracket who also exceeds the MAGI threshold effectively pays 18.8%; someone in the 20% bracket pays 23.8%. Retirement contributions, HSA contributions, and charitable deductions all reduce MAGI and can pull you back below the threshold. Most states also tax capital gains on their own, with rates from 0% to over 13% depending on where you live, so the total effective rate on share profits is often higher than the federal figure alone.