How to Legally Avoid Capital Gains Tax on Stocks (2026 Planner’s Guide)

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 the impact of capital gains tax in Washington.

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)

2026 Federal Capital Gains Tax Estimator

Estimate the incremental federal tax from a standard investment sale, including progressive short-term rates, long-term bracket stacking, and potential net investment income tax.

Tax year matters: This version uses federal thresholds for sales occurring during calendar year 2026, generally reported on returns filed in 2027. Enter taxable income after deductions—not gross salary—and enter MAGI separately for the NIIT estimate.
Tax-return assumptions

The estimator treats the entered gain as an additional item layered on top of the income amounts entered here.

Use estimated taxable income after deductions, excluding this gain and preferably excluding qualified dividends and other long-term gains.
MAGI is used only for the 3.8% NIIT estimate and is not the same as taxable income.
Examples may include taxable interest, dividends, other capital gains, passive rents, royalties, or nonqualified annuity income.
Sale and cost-basis details

Adjusted basis generally begins with acquisition cost and may change for commissions, improvements, reinvestments, depreciation, gifts, inheritance, corporate actions, or prior adjustments.

Enter increases as positive numbers and basis reductions as negative numbers.
Enter eligible transaction costs that reduce amount realized, such as certain commissions or selling fees.
Holding period

Standard assets only: This estimator is designed primarily for ordinary taxable sales of investments such as publicly traded stocks, mutual funds, exchange-traded funds, and many digital assets.

It does not calculate the principal-residence exclusion, depreciation recapture or unrecaptured Section 1250 gain, collectibles rates, qualified small business stock treatment, installment sales, wash-sale adjustments, gifted or inherited basis rules, opportunity-zone treatment, employee stock compensation, kiddie tax, straddles, foreign assets, business-property rules, or state and local taxes.

The long-term calculation assumes the entered taxable ordinary income appropriately excludes this gain and does not separately model qualified dividends or other long-term gains that may already occupy the preferential brackets.

NIIT is estimated by comparing the tax with and without this sale using the entered MAGI and other net investment income. Form 8960 adjustments may produce a different result.

A taxable gain may create an estimated-tax or withholding requirement. This tool does not calculate underpayment penalties, safe-harbor payments, credits, deductions, AMT, or your complete federal liability.

This is general financial education from an independent publisher. It is not personalized tax, legal, investment, or financial advice.

2026 thresholds are based on IRS Revenue Procedure 2025-32. Tax law and administrative 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 .

(For those interested in building a solid financial foundation, I highly recommend the book I Will Teach You to Be Rich from Amazon for its practical approach to building an automated investment plan.)

❓ 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.


Subscription Form (#3)

Note: This content is for informational and educational purposes only and should not be considered financial, legal, or tax advice. Please consult a qualified professional for guidance specific to your situation.

und with. A bit further down, I created a tool for you to play with that will estimate your federal capital gains tax bracket.

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.