How to Avoid Capital Gains Tax on Stocks Legally in 2026

You usually reduce capital gains tax by changing the timing, holding period, account type, offsetting losses, or what you sell. The best strategy depends on the gain you actually have.

How to avoid capital gains tax on stocks
How to avoid capital gains tax on stocks

“Michael, I just sold my company stock to fund a down payment… my accountant says I owe a fortune in taxes. How is that possible?”

This was the panicked call I got from a client, Marcus a few years ago. He sold about $100,000 in stock he’d held for years and was blindsided by a tax bill that felt punishingly high. The culprit wasn’t just one tax; it was a combination of long-term capital gains tax and the sneaky Net Investment Income Tax (NIIT).

Marcus’s story is incredibly common. In 2026, with many investors sitting on significant gains from the last decade, knowing how to legally maximize their returns while minimizing their tax burden became a priority. As Marcus navigated his options, he quickly realized the importance of understanding how state capital gains taxes vary.

This isn’t about shady loopholes; it’s about understanding the rules the IRS has in place and using them to your advantage.

In this guide, I’ll use my 25+ years of experience to give you the planner’s playbook on tax-efficient investing. We’ll cover the core strategies every investor should know and the advanced moves that can save you thousands.

Key Takeaways

  • Time is Your Greatest Ally: Holding a stock for more than one year is the single easiest way to cut your tax rate nearly in half.
  • Harvest Your Losses: Tax-loss harvesting is a powerful, legal strategy to use losing investments to offset the taxes on your winners.
  • Use the Right Accounts: You pay zero capital gains tax on investments held within tax-advantaged accounts like a Roth IRA or 401(k).

Myth Buster:
You don’t have to sell to access your portfolio’s value. Advanced strategies can provide liquidity without triggering a taxable event.

First, What Are the Capital Gains Tax Rules You Need to Know?

What is A Capital Gains Tax on a Stock Sale

Before you can reduce your tax bill, you need to understand how gains are taxed. The IRS separates them into two categories.

Short-Term Capital Gains

This applies to any stock you sell after holding it for one year or less. The profit is taxed at your ordinary income tax rate—the same as your salary. For many, this can be as high as 24%, 32%, or even 37%.

Long-Term Capital Gains

This applies to stock you sell after holding it for more than one year. The tax rates are much more favorable: 0%, 15%, or 20%, depending on your total taxable income.

💡 Advisor Tip

The “one year and one day” holding period is the simplest and most effective tax-saving strategy in the book. Before you sell a winner, always check the purchase date. Waiting a few more days or weeks could save you a significant amount of money.

Press pay below to watch a quick slideshow to help explain your capital gains avoidance ideas:

The Hidden 3.8% Surtax: Are You Subject to the Net Investment Income Tax (NIIT)?

This is the tax that shocked my client, Marcus. The Net Investment Income Tax (NIIT) is an additional 3.8% surtax that applies to investment income (including capital gains) for individuals with a Modified Adjusted Gross Income (MAGI) above certain thresholds.

For 2025, those thresholds are:

  • $200,000 for Single or Head of Household filers
  • $250,000 for Married Filing Jointly couples

This tax is stacked on top of your regular capital gains tax, which is how a 15% rate can suddenly feel like 18.8%. For authoritative details, you can refer to the IRS explanation of the NIIT.

The Planner’s Playbook: 4 Core Strategies Every Investor Must Know

These are the foundational, must-know strategies for managing taxes in a standard taxable brokerage account.

How To Avoid Stock Sale Capital Gains

1. Hold for the Long Term

As we covered, holding an investment for at least a year and a day is your first and best line of defense, ensuring you qualify for the lower long-term rates.

2. Harvest Your Losses to Offset Gains

This is the most powerful tool in your tax-planning arsenal. Tax-loss harvesting is the practice of selling losing investments to realize a capital loss. That loss can then be used to cancel out, or “offset,” capital gains you’ve realized from selling winners.

📘 A Planner’s War Story: The Power of a “Loser”

I had a client, “David,” who needed to sell $50,000 of appreciated Apple stock for a kitchen remodel, facing a big tax bill. We dug into his portfolio and found a mutual fund he’d bought years ago that was down $15,000. By selling the losing fund first, he “harvested” that loss, which completely offset his gain from the Apple stock. His tax bill on the sale went to zero.

According to IRS Topic No. 409, you can use losses to offset all of your gains, plus up to $3,000 of your ordinary income each year.

3. Beware the “Wash Sale Rule”

The IRS won’t let you sell a stock to claim a loss and then immediately buy it back. The Wash Sale Rule disallows a tax loss if you buy the same or a “substantially identical” security within 30 days before or after the sale.

4. Use the Right Accounts (Tax-Advantaged Investing)

The easiest way to avoid capital gains tax is to invest within accounts that are designed to be tax-free or tax-deferred. You don’t pay any capital gains tax for trades made inside:

  • Roth and Traditional IRAs
  • 401(k)s, 403(b)s, and other employer-sponsored plans
  • Health Savings Accounts (HSAs)
MICHAEL RYAN MONEY 2026 TAX YEAR

You know the sale price.
What do you keep?

Estimate the federal tax on your capital gain, see how the brackets stack, and compare short-term with long-term treatment.

Federal capital gains estimatorIncludes NIITNo account connection
For taxable investments such as stocks, funds, and many digital assets. Not for home sales, rental real estate, 1031 exchanges, depreciation-recapture situations, capital-loss netting, or other special asset rules. See full scope.
01Your income before this sale
After deductions. Exclude this sale, qualified dividends, and other long-term gains.
Modified adjusted gross income for NIIT. Different from taxable income; exclude this sale.
Other investment income · dividends & gains

Enter amounts before this sale. These figures describe income already in your tax return; they are not added to your MAGI input.

Taxable amount eligible for the standard 0% / 15% / 20% rates, after applicable netting. Exclude from ordinary income above.
Include applicable dividends and gains entered above, plus taxable interest and other NIIT income, net of eligible expenses. Do not include this sale.
02Your investment sale
Acquisition cost before the adjustments below.
Before selling expenses.
Basis adjustments & selling costs
Positive to increase basis; negative to reduce it.
Eligible transaction expenses that reduce sale proceeds.
03How long did you hold it?
EXPLORE AN EXAMPLE

Starts with illustrative values. Replace them with your own. Results update as you edit; entries are calculated in your browser.

How to enter income without double counting

Ordinary income is the taxable portion after deductions, with this sale and preferential income removed. Enter qualified dividends and other eligible long-term gains separately. Their total plus ordinary income should represent your taxable income before this sale.

MAGI and net investment income are separate inputs used for NIIT. Include applicable investment income in those totals even when you also entered it in the preferential-income field. The calculator does not add that field to MAGI automatically. It assumes deductions are already used or allocated and stay unchanged.

What this estimator covers—and where it stops

Designed for a fully taxable sale of standard investments, such as stocks, funds, and many digital assets. It models the difference in federal regular tax and NIIT with and without a positive gain. It does not calculate tax benefits from losses or perform capital-loss netting.

Not modeled: state/local tax, AMT, credits, deduction phaseouts, unused deductions, loss carryovers, wash sales, home-sale exclusions, collectibles, depreciation recapture, qualified small business stock, installment sales, gifted/inherited basis rules, employee equity compensation, foreign-income rules, business property, or kiddie tax. Enter an independently determined adjusted basis when appropriate.

The model uses rate brackets, not the IRS $50 tax-table bands. It is a planning estimate, not a tax return, a payment recommendation, or a safe-harbor calculation. Use a full return calculation for those decisions.

2026 rates, method & sources

Ordinary-income and long-term gain thresholds: IRS Revenue Procedure 2025-32, §§4.01 and 4.03. NIIT method and thresholds: IRS Topic 559.

The regular-tax model follows the preferential-income stacking and ordinary-tax ceiling described in the Form 1040 instructions, using 2026 brackets. The linked worksheet currently describes tax year 2025; its dollar thresholds are not used here. Sources checked September 22, 2026.

Independent financial education from Michael Ryan Money. Estimates depend on your inputs and the stated assumptions; this is not personalized tax advice. Tax law and guidance can change.

Advanced Moves: 3 Strategies for Specific Financial Goals

For investors with specific objectives, these advanced strategies can provide even greater tax benefits.

5. Be Strategic About Which Shares You Sell

When you sell a portion of a stock you’ve bought at different times and prices, your brokerage defaults to selling the “First-In, First-Out” (FIFO) shares.

However, you can instruct them to use “Specific Share Identification,” allowing you to sell the shares with the highest cost basis, which minimizes your taxable gain.

6. Gift Appreciated Stock

You can gift stock to a friend or family member. While this doesn’t eliminate the tax, it can shift the liability. The recipient inherits your original cost basis and holding period.

If they are in a lower tax bracket (e.g., the 0% long-term capital gains bracket), they can sell the stock and pay significantly less tax than you would have.

7. Donate Appreciated Stock to Charity

This is one of the most powerful tax-saving strategies. If you donate appreciated stock you’ve held for more than a year directly to a qualified charity or a Donor-Advised Fund, you can typically deduct the full fair market value of the stock, and you pay zero capital gains tax on the appreciation.

It’s a win-win.

Conclusion: Your Final Takeaway on Capital Gains

Capital Gains Tax Rates Through The years

After 25 years of practice, the most costly mistake I’ve seen isn’t picking the wrong stock; it’s failing to have a tax plan for the winners. An investment strategy isn’t complete until you have a tax-efficient exit strategy. The difference between a smart sale and an uninformed one can be tens of thousands of dollars in your pocket versus the IRS’s.

Your goal isn’t to never sell; it’s to sell smart. Use the strategies in this playbook to build a plan that lets you enjoy your hard-earned gains.

🚀 Next Steps

Ready to put this into practice? Start by reviewing your portfolio for any losing positions you could use for tax‑loss harvesting. For a more tailored plan, consider discussing these strategies with a qualified financial advisor or CPA. And if you’re selling a home, be sure to understand how to avoid capital gains tax on a home sale .

❓ Frequently Asked Questions

How does state capital gains tax work in 2026?

State taxes are a critical, often overlooked layer. Some states, like Florida, have no state capital gains tax, offering a significant advantage. Others, like California, tax capital gains at high ordinary income rates. Always factor in your state’s specific rules.

Can TurboTax or other software handle tax-loss harvesting?

Yes, tax software like TurboTax can handle the reporting of capital losses on IRS Form 8949 and Schedule D. However, the software does not tell you which assets to sell or when. The strategy of tax-loss harvesting must be executed by you or your advisor first.

What is the holding period for Qualified Small Business Stock (QSBS)?

The QSBS exclusion is a powerful but complex rule. To potentially exclude up to 100% of the capital gains, you must have held the stock for more than five years, among other strict requirements defined by IRS Section 1202.

Does gifting stock to my children trigger any gift tax limits?

Yes. For 2025, you can gift up to $18,000 per person per year without having to file a gift tax return. Gifting stock above this annual exclusion amount may require filing a gift tax return, though it typically won’t result in paying taxes unless you exceed your lifetime gift tax exemption.


We are audience supported - when you make a purchase through our site, we may earn an affiliate commission.

Michael Ryan
Michael Ryan, Retired Financial Planner & Founder of MichaelRyanMoney.com Michael Ryan is a retired financial planner and financial educator with nearly three decades of experience in financial planning, retirement planning, estate planning, insurance, and risk management. He is the founder of MichaelRyanMoney.com, where he explains Social Security, Medicare and IRMAA, retirement income, taxes, estate planning, insurance, investing, and personal finance in plain English. His commentary has been featured by outlets including The Wall Street Journal, U.S. News & World Report, Business Insider, Yahoo Finance, Forbes, Newsweek, and Nasdaq. Michael no longer sells financial products, manages investments, or provides individualized investment, tax, legal, or insurance advice through the site.