How to Avoid Capital Gains Tax on Stocks (7 Tricks You Need to Know)

Capital gains taxes are incurred whenever a stock sale price is higher than its purchase price. But is there a way you can be in a lower tax bracket?

How to Avoid Capital Gains Taxes on Stocks
Updated May 13, 2024
Fact checked

We receive compensation from the products and services mentioned in this story, but the opinions are the author's own. Compensation may impact where offers appear. We have not included all available products or offers. Learn more about how we make money and our editorial policies.

Capital gains are incurred when shares of a stock are sold for more than you paid for them. The exact taxes on these gains will depend upon how long the shares were held.

Understanding how capital gains taxes work can help you manage the tax bill incurred from stock sales, which is a smart money move when you’re trying to build wealth. When investing money you should always understand how it could be taxed.

Here’s how capital gains tax works with taxes, and how you might avoid a big capital gains tax bill.

In this article

What are capital gains taxes?

Capital gains as they pertain to stocks occur when an investor sells shares of an individual stock, a stock mutual fund, or a stock ETF for more than they originally paid for the investment. For example, if you buy 100 shares of a stock at $25 per share and later sell them for $40 per share you will have realized a capital gain of $15 per share or $1,500 total on the 100 shares.

ETFs and mutual funds can also incur capital gains realized from the sales of the stocks held within the mutual fund or ETF.

The Internal Revenue Service defines capital gains as either short-term or long-term:

  • Short-term capital gains: Capital gains on stocks that are held for less than one year are taxed at your ordinary income tax rate. There is no different treatment for tax purposes.
  • Long-term capital gains: If the shares are held for at least one year, the capital gain is considered to be long-term. This means the gain is taxed at the long-term capital gains tax rate, which is lower than the ordinary income tax rates for many investors.

Note: Capital gains on stocks are taxed differently than capital gains on a home sale.

How capital gains on stocks are taxed

The federal tax rates on long-term capital gains vary a bit based on your filing status and your adjusted gross income (AGI). Here are the long-term capital gains rates for both the 2023 and 2024 tax years for the various tax filing statuses.

The first column indicates the percentage of tax that will be applied to your capital gains. Columns two through five indicate your filing status and income level.

Tax year 2023

Capital gains tax rate AGI – Single filers AGI – Married filing jointly AGI – Head of household AGI – Married filing separately
0% $0 - $44,625 $0 - $89,250 $0 - $59,750 $0 - $44,625
15% $44,626 - $492,300 $89,251 - $553,850 $59,751 - $523,050 $44,626 - $276,900
20% $492,301 or more $553,851 or more $523,051 or more $276,901 or more

Tax year 2024

Capital gains tax rate AGI – Single filers AGI – Married filing jointly AGI – Head of household AGI – Married filing separately
0% $0 - $47,025 $0 - $94,050 $0 - $63,000 $0 - $47,025
15% $47,025 - $518,900 $94,050 - $583,750 $63,000 - $551,350 $47,025 - $291,850
20% $518,900 or more $583,750 or more $551,350 or more $291,850 or more

In addition to these rates, there is an additional capital gains tax for higher-income investors called the net investment income tax rate. This rule adds 3.8% to the capital gains tax for investors over certain income thresholds.

For tax year 2024, you will owe net investment income tax if your annual income (measured as modified adjusted gross income or MAGI) is above the following thresholds:

  • Single or head of household: $200,000
  • Married couple filing jointly: $250,000
  • Married couple filing separately: $125,000

7 methods to avoid capital gains taxes on stocks

Managing the tax impact when investing in stocks is always a good idea. However, tax considerations should simply be a part of the process and not the driver of your investing decisions. That said, there are many ways to minimize or avoid the capital gains taxes on stocks.

1. Work your tax bracket

While long-term capital gains are taxed at a lower rate, realizing these capital gains can push you into a higher overall tax bracket, as the capital gains will count as a part of your AGI. If you are close to the upper end of your regular federal income tax bracket, it might be smart to defer selling stocks until a later time or to consider bunching some deductions into the current year. This would keep those earnings from being taxed at a higher rate.

2. Use tax-loss harvesting

Tax-loss harvesting is an effective tool whereby an investor intentionally sells stocks, mutual funds, ETFs, or other securities held in a taxable investment account at a loss. Tax losses can be used in several ways including to offset the impact of capital gains from the sale of other stocks.

Capital losses are used to offset capital gains as follows:

  • Long-term losses offset long-term gains
  • Short-term losses offset short-term gains

Any excess losses of either type are used to offset additional capital gains first. Then, to the extent that your losses exceed your gains for the year, up to $3,000 may be used to offset other taxable income. Additional losses can be carried over to use in subsequent tax years.

A key point is to ensure that you avoid a wash sale when using tax-loss harvesting. The wash sale rule says an investor cannot purchase shares of identical or substantially identical security 30 days before or within 30 days after selling a stock or other security for a loss. Essentially this creates a 61-day window around the date of the sale.

For example, if you plan to sell shares of IBM stock at a loss, you must refrain from buying shares of IBM during that 61-day span. Similarly, if you sell shares of the Vanguard S&P 500 ETF at a loss and then buy another ETF that tracks the same index, that might be considered “substantially identical.”

Violating the wash sale rule would eliminate your ability to use the tax loss against capital gains or other income for that year. This rule also extends to purchases in accounts other than your taxable account, such as an IRA. If you have questions about what constitutes a wash sale, it's best to consult your financial advisor.

Many of the top robo-advisors like Wealthfront automate tax-loss harvesting, making it simple even for novice investors.

3. Donate stocks to charity

Donating shares of stock to a charity offers two potential tax benefits:

  1. You will not be liable for taxes on any capital gains due to the increased value of the shares.
  2. The market value of the shares on the day they are donated to the charity can be used as a tax deduction if you are eligible to itemize deductions on your tax return. Your total itemized deduction needs to exceed the amount of the standard deduction for the current tax year and your filing status to be eligible.

4. Buy and hold qualified small business stocks

Qualified small business stock refers to shares issued by a qualified small business as defined by the IRS. This tax break is meant to provide an incentive for investing in these smaller companies. If the stock qualifies under IRS section 1202, up to $10 million in capital gains may be excluded from your income. 

Depending on when the shares were acquired, between 50% and 100% of your capital gains may not be subject to taxes. It's best to consult with a tax professional knowledgeable in this area to be sure.

5. Reinvest in an Opportunity Fund

An opportunity zone is an economically distressed area that offers preferential tax treatment to investors under the Opportunity Act. This was a part of the Tax Cuts and Jobs Act passed in late 2017. 

Investors who take their capital gains and reinvest them into real estate or businesses located in an opportunity zone can defer or reduce the taxes on these reinvested capital gains. The IRS allows the deferral of these gains through December 31, 2026, unless the investment in the opportunity zone is sold before that date.

6. Hold onto it until you die

This might sound morbid, but if you hold your stocks until your death, you will never have to pay any capital gains taxes during your lifetime. In some cases, your heirs may also be exempt from capital gains taxes due to the ability to claim a step-up in the cost basis of the inherited stock. The cost basis is the cost of the investment, including any commissions or transaction fees incurred.

 A step-up in basis means adjusting the cost basis to the current value of the investment as of the owner’s date of death. For investments that have appreciated in value, this can eliminate some or all of the capital gains taxes that would have been incurred based on the investment’s original cost basis. For highly appreciated stocks, this can eliminate capital gains should your heirs decide to sell the stocks, potentially saving them a lot in taxes.

7. Use tax-advantaged retirement accounts

If stocks are held in a tax-advantaged retirement account like an IRA, any capital gains from the sale of stocks in the account will not be subject to capital gains taxes in the year the capital gains are realized.

In the case of a traditional IRA account, the gains will simply go into the overall account balance that won’t be subject to taxes until you take distributions in retirement. In the case of a Roth IRA, the capital gains will be part of the account balance that can be withdrawn tax-free as long as certain conditions are met. This tax-free growth is one reason many people opt for a Roth IRA.

You can open a retirement account using one of our picks for the best investment apps, such as Stash1 or Public.

Robinhood IRA Benefits

  • Get a 3% match on your eligible retirement contributions2
  • No traditional employer needed to get the match
  • Open a Roth IRA or a traditional IRA
  • Receive a one-time custom-recommended portfolio3
  • Build your own investment plan
  • No commission-fees (other fees may apply)


How long do you need to hold a stock to avoid capital gains tax?

If you sell shares of stock for a price greater than the amount you paid for the shares, you will be subject to capital gains no matter how long you have owned the shares. If you’ve held the shares for less than one year, the gains will be considered short-term. 

If the holding period has been at least a year, they will be considered long-term. The advantage of paying long-term capital gains taxes is that the rates are lower than short-term capital gains taxes for most taxpayers.

Do I pay taxes on stocks I don't sell?

If you don’t sell shares of stock that you own, there are no capital gains taxes due, even if the shares increase in value. If you hold the stocks until you die, they would pass to your heirs, who may or may not owe taxes on the inheritance. 

If the stock pays a dividend, these payments would be taxable to you while holding the shares, but this is not a capital gains tax.

What happens if you don't report stocks on taxes?

You typically don’t have to report that you own shares of a stock on your taxes. You do have to report any income earned from those shares whether from capital gains due to the sale of the shares or from dividends earned while holding the shares.

Failure to report this income and pay the appropriate federal or state taxes could be a crime. Brokerage firms will directly report the proceeds from the sale of stock to the IRS. The company issuing the dividend will also report this income to the IRS. If these amounts are not reflected on your tax return, this could be a red flag for the IRS.

Bottom line

Investing in the stock market can be a solid wealth-building tool for some investors. But it’s important to understand how stocks can be taxed and to take those tax implications into account in your financial planning.

Incurring capital gains means that you have sold shares of a stock for more than you paid for it, but proper tax planning can help manage your tax liability. If you have questions about your specific tax situation, you might consider speaking with a tax advisor. They can tell you how you can reduce what taxes you owe for day trading and other investments.

Get matched with fiduciary financial advisors
Advisors are vetted and certified fiduciaries
Take the mystery out of retirement planning
Their matching tool is free

Author Details

Roger Wohlner

In addition to his bylined articles on sites like TheStreet, ThinkAdvisor, and Investopedia, Roger ghostwrites extensively for financial advisors, investment managers, and financial services companies.