You cannot avoid capital gains tax entirely, but you can reduce what you owe through timing, account type, and holding period

Capital gains tax is owed when you sell an asset for more than you paid for it. The tax applies to stocks, real estate, cryptocurrency, and other investments. You cannot eliminate the tax by hiding the sale or failing to report it — the IRS receives records from brokers and title companies. What you can do is structure the sale differently, use tax-advantaged accounts, hold assets longer to may have access to for lower rates, or offset gains with losses.

The strategies that work depend on what you own, how long you have owned it, your income level, and whether you have losses to use. Some require planning before you sell. Others work only if you meet specific conditions. This guide explains the real mechanics: which moves actually reduce your bill, which ones the IRS watches closely, and which ones apply only to certain types of assets or people.

Key Takeaways

  • Assets held longer than one year may have access to for long-term capital gains rates, which are lower than short-term rates and taxed as ordinary income.
  • Tax-loss harvesting lets you offset investment gains with investment losses, reducing the total gain you report in a single year.
  • Selling assets in a year when your income is lower can reduce your tax rate, since capital gains rates depend partly on your tax bracket.
  • Certain accounts — 401(k)s, IRAs, and 529 plans — let you buy and sell investments inside them without triggering capital gains tax until you withdraw money.
  • Donating appreciated assets to charity avoids the capital gains tax and gives you a deduction for the full current value.

Hold assets for more than one year to may have access to for long-term rates

The single biggest tax difference is between short-term and long-term capital gains. If you sell an asset you have owned for one year or less, the gain is taxed as ordinary income at your regular tax rate — which can be 10%, 12%, 22%, 24%, 32%, 35%, or 37% depending on your income. If you sell an asset you have owned for more than one year, the gain is taxed at long-term rates: 0%, 15%, or 20%, depending on your income.

The holding period starts the day after you buy. If you bought a stock on March 15, you can sell it on March 16 of the following year and may have access to for long-term treatment. The difference is substantial: a $10,000 gain taxed at 24% (short-term) costs $2,400. The same gain at 15% (long-term) costs $1,500. If you are considering selling an investment that is close to the one-year mark, waiting a few weeks or months can save hundreds or thousands in tax.

This strategy works only if you can afford to wait. If you need the money now or believe the asset will drop in value, the tax savings may not outweigh the risk. It also does not work for assets you must sell — for example, if your employer requires you to sell restricted stock units on a specific date, you cannot choose to hold them longer.

Offset gains with losses from other investments

If you have investments that lost value, you can sell them to create a loss. That loss can then reduce your capital gains from other sales in the same year. This is called tax-loss harvesting. If you sold a stock for a $5,000 gain and another stock for a $3,000 loss, you report a net gain of $2,000 and pay tax only on that amount.

Losses can also offset ordinary income, but only up to $3,000 per year. If your total losses exceed your gains by more than $3,000, you can carry the extra loss forward to future years and use it then. For example, if you have $10,000 in losses and $2,000 in gains, you use $2,000 of the loss to cancel the gain, then use $3,000 to reduce ordinary income, and carry forward the remaining $5,000 to next year.

One rule to watch: the wash-sale rule. If you sell a stock at a loss and buy the same stock (or a substantially identical one) within 30 days before or after the sale, the IRS disallows the loss. You can buy a similar but not identical investment — for example, if you sell a specific tech stock at a loss, you can buy a different tech stock or a tech index fund within the 30-day window without triggering the rule. But you cannot buy the exact same stock.

Sell in a year when your income is lower

Long-term capital gains rates depend on your tax bracket, which depends on your total income for the year. The 0% rate applies to people in the 10% and 12% tax brackets. The 15% rate applies to people in the 22%, 24%, 32%, and 35% brackets. The 20% rate applies to people in the 37% bracket. If you can time a large sale to a year when your income is lower, you may fall into a lower bracket and pay a lower rate on the gain.

This works if you have control over your income timing. If you are self-employed, you might defer invoicing or delay a bonus to a later year. If you are retired and taking distributions from a 401(k) or IRA, you might take a smaller distribution in the year you sell an asset, leaving room in your bracket for the gain at a lower rate. If you are still working, you have less control — your salary is usually fixed — but you might still coordinate the sale with a year when you expect a smaller bonus or no bonus.

The math requires knowing your bracket and the exact gain. A tax professional can model this for you. It is worth doing if the gain is large — say, $50,000 or more — because the difference between a 15% and 20% rate is $2,500 on that gain alone.

Use tax-advantaged accounts to avoid capital gains tax on investment sales

Money inside a 401(k), traditional IRA, or Roth IRA can be invested in stocks, bonds, and funds. When you buy and sell investments inside these accounts, no capital gains tax is triggered. You can trade as much as you want without reporting gains. The tax is deferred (in a traditional account) or eliminated (in a Roth) until you withdraw the money.

A 529 education savings plan works the same way: investments grow tax-free, and you pay no capital gains tax on the sales inside the account. You only pay tax when you withdraw money for non-education expenses.

These accounts have contribution limits and withdrawal rules. A 401(k) contribution limit is $23,500 per year (for 2024). An IRA contribution limit is $7,000 per year. A 529 plan has no annual limit, but contributions over $18,000 per year per person per beneficiary may trigger gift tax reporting. If you withdraw from a traditional IRA or 401(k) before age 59½, you may owe a 10% penalty plus income tax. If you withdraw from a 529 for non-education purposes, you owe income tax and a 10% penalty on the earnings portion.

The benefit is real if you have money to invest long-term and can follow the withdrawal rules. If you are a frequent trader or expect to need the money soon, these accounts may not fit your situation.

Donate appreciated assets to charity instead of selling them

If you own an investment that has gained value and you want to give money to charity, you can donate the asset itself rather than selling it and donating the cash. You avoid the capital gains tax entirely, and you receive a tax deduction for the full current value of the asset.

Example: You bought a stock for $5,000. It is now worth $15,000. If you sell it, you owe capital gains tax on the $10,000 gain. If you donate it to a may have access to charity, you deduct $15,000 and owe no capital gains tax. The charity receives $15,000 worth of value, and you get a larger deduction than if you had sold and donated the cash.

The charity must be a may have access to organization — a 501(c)(3) nonprofit, religious organization, or other IRS-approved entity. You must itemize deductions on your tax return to claim the deduction; if you take the standard deduction, the donation does not reduce your taxes. You also need a written appraisal for assets worth more than $5,000, and you must file Form 8283 with your tax return.

Understand stepped-up basis for inherited assets

When you inherit an investment, its basis — the value used to calculate future gains — is reset to its value on the date of death. This is called a stepped-up basis. If someone bought a stock for $10,000 and it was worth $50,000 when they died, your basis becomes $50,000. If you sell it immediately for $50,000, you owe no capital gains tax.

This is not a strategy you can use yourself — it applies only to assets you inherit. But it is important to know because it affects how you should plan your estate. Assets that have large unrealized gains are often better left to heirs than sold during your lifetime, because the heirs will receive the stepped-up basis and avoid the tax.

This rule may change. Congress has proposed eliminating or limiting the stepped-up basis in recent years, though no change has been enacted. If you have a large estate with appreciated assets, a tax professional or estate attorney can help you plan for current law and possible future changes.

Frequently Asked Questions

Can I avoid capital gains tax by not selling?

Yes, but only temporarily. As long as you own the asset, no tax is due. The tax is triggered only when you sell. If you need the money or want to move to a different investment, you cannot avoid the tax by holding — you can only defer it. If you hold until death, your heirs receive a stepped-up basis and may owe no tax when they sell.

What if I have more losses than gains?

You can use up to $3,000 of losses to reduce ordinary income in the current year. Any losses beyond that carry forward to future years. You can use them to offset future gains or future income, $3,000 per year, until the losses are exhausted. There is no time limit on how long you can carry losses forward.

Do I have to report a capital loss if I do not have any gains?

You should report it. Losses reduce your taxable income, which lowers your tax bill. If you do not report the loss, you miss the deduction. You report losses on Schedule D of your tax return, the same form you use to report gains.

Can I use capital losses from one type of investment to offset gains from another?

Yes. A loss from a stock can offset a gain from real estate, cryptocurrency, or any other capital asset. All capital gains and losses are combined on Schedule D, and the net amount is what you report as your capital gain or loss for the year.

What happens if I sell an asset at a loss and then buy it back later?

If you buy it back within 30 days of the sale, the wash-sale rule disallows the loss. If you wait more than 30 days, the loss is allowed. The 30-day window runs from 30 days before the sale through 30 days after the sale, so you need to wait 31 days from the sale date to be safe.