How To Avoid the Capital Gains Tax on Stocks (2024)

To be clear at the outset, we will discuss only legal ways to avoid or defer the capital gains taxes that can be due upon selling stocks and related investments at a gain. Capital gains occur when stocks are sold for more than your cost basis in the stock. Capital gains are taxed at different rates depending upon the investor’s holding period for the investment or other asset.If your taxes are very complicated (including gains on the sale of capital investments like stocks or real estate), you may want to enlist a professional at a firm like H&R Block or use robust software like Cash App.

Read more: The Best Tax Software of 2023

What is the capital gains tax?

Capital gains on individual stocks, mutual funds, ETFs and other types of investments happen when they are sold and the sale proceeds exceed an investor’s cost basis. Cost basis is generally the amount originally paid for the investment, reduced by costs such as any commissions or transaction fees. Reinvested dividends can add to the cost basis of the investment over time, if applicable.

Capital gains can be either long-term or short-term and they are taxed differently. Capital gains in retirement accounts like an IRA or 401(k) are not taxed while in the account, rather they become part of the account balance that will be taxed upon distribution, or may remain tax-free in the case of a Roth account.

Sometimes capital gains distributions, subject to capital gains taxes, are incurred by holders of mutual funds and ETFs when investments are sold by the managers of these funds.

Besides investments like stocks, bonds, ETFs and mutual funds, capital gains can be incurred by selling other types of assets like real estate, art, private investments, collectibles, gold and precious metals among others.

How capital gains on stocks are taxed and capital gains tax rates

In the case of stocks, mutual funds and ETFs and a number of other types of investments, there are both long-term and short-term capital gains. Each type has a different tax treatment.

In order for a capital gain to be classified as long-term, the investment must have been held for at least a full year. Long-term capital gains are taxed at preferential rates that are often lower than an investor’s ordinary income tax rate.

Your long-term capital gains tax rate depends on your income. For 2023 the rates and income levels are:

Filing status0% rate15% rate20% rate


Up to $41,675

$41,676 – $459,750

Over $459,750

Married filing jointly

Up to $83,350

$83,351 – $517,200

Over $517,200

Married filing separately

Up to $41,675

$41,676 – $258,600

Over $258,600

Head of household

Up to $55,800

$55,801 – $488,500

Over $488,500

In addition, there may be an additional tax of 3.8% over and above the 20% level called the net investment income tax (NIIT) for taxpayers whose income exceeds certain amounts, depending upon their filing status.For capital gains realized in 2024 these rates will go up.

Short-term capital gains are those where the stock or other investment was sold at a gain and was held for less than one year. Short-term capital gains are taxed at the investor’s ordinary income tax rate. In many cases this rate might be higher than the long-term capital gains tax rate. Hence the reason long-term capital gains tax rates are often referred to as being “preferential.”

How to defer or avoid capital gains taxes

There are many strategies to defer or reduce the amount of capital gains on an investment and hence reduce or eliminate the capital gains taxes.

Donating shares of appreciated stock

If you own shares of a stock, mutual fund, or ETF one strategy to eliminate capital gains taxes on the disposition of these holdings is to donate shares to a qualified charity. First you will want to be sure that the charitable or nonprofit organization accepts these types of gifts. You will also want to ensure this is a qualified charitable or nonprofit organization in the eyes of the IRS and your state taxing authority.

The value of your donation is the price of the stock or other securities on the date of the donation. This will generally be the closing share price on the date the donation transaction occurs.

For those who are able to itemize tax deductions, the value of the shares donated can count as a charitable deduction, offering a reduction in the amount of income tax owed. As far as capital gains taxes are concerned, there is no capital gain on this transaction as the shares were never sold and there was no capital gain that was ever realized. It is essentially a double tax benefit with the tax deductible gift to charity and the elimination of any capital gains taxes on these shares.

One mistake to avoid here is selling the shares first and then making a donation with the cash from the sale of the shares. Under this scenario, you would realize a capital gain on the sale of the shares and be liable for any taxes on those gains.

Tax loss harvesting

One strategy to avoid or reduce the amount of capital gains that you may be liable for in a given tax year is to offset any realized capital gains by selling stocks or other securities for which you are in a loss position. These realized capital losses can be used to offset realized capital gains and other income for the year as applicable.

There are ordering rules for netting capital gains and losses against each other for tax purposes:

  • Short-term gains and losses are used to offset each other to the extent possible. This includes any loss carryovers from prior tax years.
  • Long-term gains and losses are used to offset each other.
  • Any remaining losses can be used to offset capital gains of either type.
  • Any remaining net capital losses can be used to offset other income you may have up to $3,000 for the year.
  • Any unused net capital losses can be carried over for use in a subsequent tax year.

This netting of gains and losses is not limited to stocks, it can be used with gains and losses on mutual funds, ETFs, bonds and a host of other types of investments.

Watch out for the wash sale rule

It is important to avoid a wash sale if you realize tax losses on an investment. The wash sale rule says that the same or a substantially equal investment cannot be purchased within a 61 day window surrounding the sale. This includes the period 30 days after the sale, 30 days prior and the date of the sale. This applies to all accounts an investor might own including tax-advantaged accounts like an IRA. Violating the wash sale rule negates your ability to use the tax loss in offsetting your capital gains. Be sure to consult with a financial advisor or tax expert on this.

Reinvesting in an opportunity fund

The Tax Cuts and Jobs Act of 2017 created opportunity zones in economically distressed areas. Investing the capital gains realized on stock or other investments in real estate or a business located in one of these opportunity zones allows investors to defer capital gains taxes on these gains until 2026. There are a number of funds available to facilitate this type of reinvestment.

Holding stocks until death

Not to be morbid, but if you never sell your stocks you will not owe any capital gains taxes. This is also the case with ETFs and mutual funds that invest in stocks, with the exception of any capital gains distributions received over time.

By holding the stocks until death you can help your heirs avoid capital gains taxes because they will receive a step-up in cost basis upon inheriting the shares. This means that if you bought a stock for $10,000 and it is worth $50,000 the day you die, your heirs’ new cost basis will be $50,000. This will be the cost against which the sales proceeds will be compared to calculate any gains or losses they might incur.

There has been talk of legislation to adjust these rules and it may work a bit differently in some cases with certain types of assets. Be sure to consult with a legal or tax advisor if this is part of your estate planning strategy.

Frequently asked questions (FAQs)

When do you pay capital gains tax on stocks?

Capital gains taxes are due for the tax year in which the capital gains are realized. If you sell shares of a given stock in 2022 and realize a capital gain on this sale, then any capital gains taxes will be due as part of your 2022 tax return.

Do I have to pay capital gains tax on stocks if I sell and reinvest?

If you sell a stock and reinvest the proceeds back into the same stock, you will owe capital gains on the sale, and your cost basis is now higher than before. It’s questionable as to whether there is an economic benefit to doing this.

As discussed above, you can’t sell a stock or another security at a loss and reinvest the money in that same stock or security for a period 30 days prior, 30 days after or the day of the transaction. This is called the wash sale rule and violating this rule negates your ability to use the tax loss to offset taxes elsewhere.

What happens if you don't pay capital gains tax?

This would be considered tax avoidance just like not paying any other type of tax you might owe. You could be subject to penalties or prosecution by the IRS and/or your state’s taxing authority.

As a financial expert deeply versed in tax strategies, especially concerning capital gains, let's delve into the concepts covered in the provided article.

Capital Gains Tax: Capital gains tax is levied on the profit realized from the sale of investments like stocks, mutual funds, ETFs, and other assets. The tax is applicable when the selling price exceeds the initial purchase price, known as the cost basis.

Long-Term vs. Short-Term Capital Gains: The duration for which an investment is held determines whether the resulting gain is classified as long-term or short-term. Long-term gains are from assets held for over a year, while short-term gains stem from assets held for a year or less. These two categories have different tax treatments, with long-term gains usually taxed at lower rates.

Capital Gains Tax Rates: The tax rates for capital gains vary based on the investor's income and filing status. There are different tax brackets with corresponding rates, and these rates can change from year to year. Additionally, there might be an additional net investment income tax for certain taxpayers.

Strategies to Avoid or Defer Capital Gains Taxes:

  1. Donating Shares: Donating appreciated securities to qualified charities allows investors to eliminate capital gains taxes while also potentially qualifying for a tax deduction.

  2. Tax Loss Harvesting: Offsetting realized capital gains by selling assets at a loss helps reduce or eliminate capital gains taxes. There are specific rules governing the offsetting process, including the wash sale rule, which prevents immediate repurchase of the same or substantially similar assets.

  3. Investing in Opportunity Zones: The Tax Cuts and Jobs Act introduced opportunity zones, providing tax incentives for investments in economically distressed areas. Investors can defer capital gains taxes by reinvesting in qualified opportunity funds.

  4. Holding Assets Until Death: Holding onto investments until death can help heirs receive a step-up in cost basis, potentially minimizing or eliminating capital gains taxes upon inheritance.


  • Timing of Capital Gains Tax Payment: Taxes on capital gains are due in the tax year when the gains are realized, typically upon the sale of assets.

  • Capital Gains Tax on Reinvestments: Reinvesting proceeds from asset sales back into the same asset may trigger capital gains tax liabilities, depending on various factors such as the timing and nature of the transactions.

  • Consequences of Not Paying Capital Gains Tax: Failure to pay capital gains tax can lead to penalties or legal consequences, similar to other types of tax evasion.

Navigating capital gains tax implications requires careful planning and adherence to tax regulations, making it advisable to seek guidance from financial advisors or tax experts to optimize tax strategies while remaining compliant with the law.

How To Avoid the Capital Gains Tax on Stocks (2024)


Top Articles
Latest Posts
Article information

Author: Terrell Hackett

Last Updated:

Views: 6030

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Terrell Hackett

Birthday: 1992-03-17

Address: Suite 453 459 Gibson Squares, East Adriane, AK 71925-5692

Phone: +21811810803470

Job: Chief Representative

Hobby: Board games, Rock climbing, Ghost hunting, Origami, Kabaddi, Mushroom hunting, Gaming

Introduction: My name is Terrell Hackett, I am a gleaming, brainy, courageous, helpful, healthy, cooperative, graceful person who loves writing and wants to share my knowledge and understanding with you.