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 legally eliminate the tax on a gain, but you can lower the amount you owe by holding assets longer, using tax-advantaged accounts, offsetting gains with losses, or donating appreciated property to charity instead of selling it.

The strategy that works depends on your income, the type of asset, how long you have owned it, and whether you have losses to offset. A gain taxed at the long-term rate (15% or 20% for most people) costs less than the same gain taxed at short-term rates (your ordinary income tax rate, which can be 37%). Holding an asset for more than one year before selling is often the single biggest tax reduction available to you.

Key Takeaways

  • Long-term capital gains (assets held over one year) are taxed at lower rates than short-term gains, so delaying a sale by a few months can cut your tax bill significantly.
  • Tax-loss harvesting — selling investments at a loss to offset gains — can reduce your taxable gains dollar-for-dollar, though the wash-sale rule prevents you from buying the same asset back within 30 days.
  • Donating appreciated stock or property directly to a charity avoids the capital gains tax entirely and gives you a charitable deduction for the full value.
  • Holding assets until death transfers them at "stepped-up basis," meaning your heirs owe no capital gains tax on the appreciation that occurred during your lifetime.
  • Retirement accounts (401(k), IRA, Roth IRA) generate no capital gains tax on sales inside the account, though withdrawals may be taxed as ordinary income.

How holding period affects your tax rate

The length of time you own an asset before selling it determines whether the gain is taxed as short-term or long-term. Short-term capital gains (assets held one year or less) are taxed at your ordinary income tax rate, which ranges from 10% to 37% depending on your total income. Long-term capital gains (assets held more than one year) are taxed at 0%, 15%, or 20% depending on your income level.

For most people, the difference is substantial. If you are in the 24% ordinary income bracket and sell a stock after holding it 11 months, you owe 24% tax on the gain. If you wait one more month and sell it, you owe 15% tax on the same gain. That is a 9 percentage point reduction on every dollar of profit.

The one-year holding period is the threshold. The IRS counts from the day after you purchase the asset to the day you sell it. If you bought stock on March 15, 2023, and sold it on March 15, 2024, it qualifies as long-term. If you sold it on March 14, 2024, it is short-term.

Using tax-loss harvesting to offset gains

Tax-loss harvesting means selling an investment at a loss to offset gains you have realized elsewhere. If you sold a stock for a $5,000 gain and also own a mutual fund down $3,000, you can sell the mutual fund at the loss. The $3,000 loss reduces your taxable gain to $2,000, cutting your tax bill by roughly $450 to $600 depending on your tax rate.

The wash-sale rule limits this strategy. If you sell an investment at a loss, you cannot buy the same investment or a substantially identical one within 30 days before or after the sale. The 30-day window is strict: it runs from 30 days before the sale through 30 days after. If you violate it, the IRS disallows the loss and adds it to your cost basis instead, deferring the tax benefit to a later year.

You can work around the wash-sale rule by buying a similar but not identical investment. If you sell a specific stock fund at a loss, you can buy a different stock fund in the same category. If you sell a bond fund, you can buy a different bond fund. The investments do not have to be identical for the wash-sale rule to apply, but they cannot be "substantially identical," which the IRS interprets narrowly in practice.

Donating appreciated assets instead of selling

If you own stock, real estate, or other property that has increased in value, you can donate it directly to a may have access to charity and avoid the capital gains tax entirely. You also receive a charitable deduction for the full current value of the asset, not just what you paid for it.

Example: You bought stock for $10,000 and it is now worth $25,000. If you sell it, you owe capital gains tax on the $15,000 gain. If you donate it to a may have access to charity instead, you owe no capital gains tax and you can deduct $25,000 on your tax return (subject to deduction limits based on your income). This strategy works only if you itemize deductions on your tax return; if you take the standard deduction, the charitable deduction provides no tax benefit.

The charity must be a may have access to organization — typically a 501(c)(3) nonprofit, religious organization, or public charity. You cannot donate to a donor-advised fund and claim a deduction for the full value; the deduction is limited based on how much you have contributed to the fund in prior years. You will need a written appraisal for real estate and a broker statement for securities to document the value.

Stepped-up basis at death

When you die, your heirs inherit your assets at their fair market value on the date of your death. This is called stepped-up basis. If you bought stock for $10,000 and it is worth $50,000 when you die, your heirs inherit it with a basis of $50,000. If they sell it immediately, they owe no capital gains tax on the $40,000 appreciation that occurred during your lifetime.

This is one of the largest tax benefits in the tax code, but it applies only to assets you own at death. It does not apply to retirement accounts (which pass to heirs with income tax owed on withdrawals) or to assets you give away during your lifetime. If you give appreciated stock to your child while you are alive, your child inherits your cost basis, not the stepped-up basis.

Stepped-up basis is permanent federal law, though Congress has proposed eliminating it in various tax reform bills. As of now, it remains available to all taxpayers regardless of estate size.

Tax-advantaged accounts that defer or eliminate capital gains tax

Money inside a 401(k) or traditional IRA grows without triggering capital gains tax. You can buy and sell investments inside the account as many times as you want, and no tax is owed until you withdraw the money in retirement. At that point, withdrawals are taxed as ordinary income, not as capital gains.

A Roth IRA or Roth 401(k) is even more favorable: investments grow tax-free, and may have access to withdrawals in retirement owe no tax at all. You cannot deduct contributions to a Roth, but the long-term tax savings can be substantial if the account grows significantly.

A 529 college savings plan works similarly: investments grow tax-free, and withdrawals for may have access to education expenses owe no tax. Withdrawals for non-education expenses are taxed as ordinary income plus a 10% penalty on the earnings portion.

These accounts have contribution limits and withdrawal restrictions. A 401(k) contribution limit is $23,500 per year (2024). An IRA contribution limit is $7,000 per year. A 529 plan has no annual contribution limit, but contributions above $18,000 per year per donor per beneficiary may trigger gift tax reporting (though not gift tax itself in most cases). Withdrawals before age 59½ from a traditional IRA or 401(k) typically incur a 10% early withdrawal penalty plus income tax.

Timing the sale of a home

If you sell a home you have lived in for at least two of the past five years, you can exclude up to $250,000 of gain from tax (or $500,000 if you are married filing jointly). This exclusion applies once every two years and does not require you to hold the home for any particular length of time beyond the two-year occupancy test.

This is not a strategy to reduce tax — it is an automatic benefit — but it is worth understanding because it means you can sell a primary residence without worrying about capital gains tax on most or all of the gain. The exclusion does not apply to investment properties, vacation homes, or homes you have rented out for part of the ownership period (though there are partial exclusions in some cases).

Frequently Asked Questions

Can I avoid capital gains tax by not selling?

Yes. If you never sell an asset, you never owe capital gains tax on the gain. The tax is triggered only when you sell or exchange the asset. You can hold appreciated investments indefinitely and owe nothing until you sell. This is why stepped-up basis at death is valuable — your heirs can inherit the asset and sell it without owing tax on your lifetime gains.

What is the difference between short-term and long-term capital gains?

Short-term gains (assets held one year or less) are taxed at your ordinary income tax rate, which can be as high as 37%. Long-term gains (assets held more than one year) are taxed at 0%, 15%, or 20% depending on your income. For most people, waiting one year to sell an asset cuts the tax rate from roughly 24% to 15%, saving hundreds or thousands of dollars on a large gain.

Does the wash-sale rule apply to real estate?

No. The wash-sale rule applies only to stocks, bonds, mutual funds, and other securities. You can sell real estate at a loss and buy the same property back immediately without triggering the wash-sale rule. However, real estate has different rules — you can deduct a loss on investment property, but not on a primary residence.

Can I use losses from one year to offset gains from another year?

Yes. If you have a net capital loss in one year (losses exceed gains), you can carry it forward to future years. You can deduct up to $3,000 of net capital loss against ordinary income in the current year. Any loss above $3,000 carries forward indefinitely to future years, where it can offset future gains or be deducted against ordinary income at $3,000 per year.

Do I owe capital gains tax on inherited investments?

No, not on the appreciation that occurred before you inherited them. You inherit the asset at stepped-up basis, which is its fair market value on the date of death. If you sell it immediately after inheriting it, you owe no capital gains tax. If you hold it and it increases in value further, you owe tax only on the new appreciation when you eventually sell.