You cannot avoid capital gains tax entirely, but you can reduce what you owe through timing, account type, and asset choice
Capital gains tax is the tax on profit when you sell an asset for more than you paid for it. You cannot legally eliminate this tax, but the law gives you several real ways to shrink it: hold assets longer to may have access to for lower rates, use tax-advantaged accounts that defer or skip tax, harvest losses to offset gains, and donate appreciated assets to charity instead of selling them. The strategy that works depends on your income, how long you have held the asset, and whether you have losses to use.
The IRS taxes long-term capital gains (assets held over one year) at 0%, 15%, or 20% depending on your income bracket. Short-term gains (under one year) are taxed as ordinary income, which is higher. This difference alone can save thousands if you can wait.
Key Takeaways
- Long-term capital gains rates (0%, 15%, or 20%) are lower than short-term rates, so holding an asset for more than one year before selling can cut your tax bill significantly.
- Tax-advantaged accounts like 401(k)s, IRAs, and HSAs let you buy and sell investments inside them without triggering capital gains tax until you withdraw money.
- Tax-loss harvesting means selling investments at a loss to offset gains from other sales, reducing your net taxable gain dollar-for-dollar.
- Donating appreciated assets directly to a charity lets you avoid the capital gains tax and claim a charitable deduction for the full current value.
- Stepped-up basis at death means heirs inherit assets at their value on the date of death, erasing the original owner's unrealized gains from tax.
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 profit is taxed as ordinary income—the same rate as your salary. If you hold it for more than one year, it qualifies for long-term rates, which are much lower.
Long-term capital gains rates are 0%, 15%, or 20% depending on your total taxable income for the year. The 0% rate applies to single filers earning under $47,025 in 2024 (these thresholds change yearly). The 15% rate covers most middle-income earners. The 20% rate applies only to high earners. By contrast, short-term gains can be taxed at your full ordinary income rate, which can be 22%, 24%, 32%, 35%, or 37%.
The holding period starts the day after you buy and ends the day you sell. If you bought stock on March 15, 2023, and sold it on March 16, 2024, it qualifies as long-term. If you sold it on March 15, 2024, it is still short-term.
Use tax-advantaged retirement and savings accounts
Money inside a 401(k), traditional IRA, Roth IRA, or HSA (Health Savings Account) grows without triggering capital gains tax each year. You can buy and sell investments inside these accounts as often as you want, and no tax is due until you withdraw the money—or in the case of a Roth IRA, possibly never.
A traditional 401(k) or traditional IRA defers tax until withdrawal. You contribute pre-tax money, investments grow tax-free, and you pay income tax on withdrawals in retirement. A Roth IRA or Roth 401(k) works the opposite way: you contribute after-tax money, but withdrawals in retirement are tax-free, including all the gains. An HSA is triple tax-advantaged—contributions are deductible, growth is tax-free, and withdrawals for medical expenses are tax-free.
The catch is contribution limits. For 2024, you can contribute $7,000 to an IRA (or $8,000 if you are 50 or older) and up to $23,500 to a 401(k) (or $31,000 if 50 or older). An HSA limit is $4,150 for individual coverage or $8,300 for family coverage. Once you hit the limit, additional money must go into a taxable account. Still, maxing these accounts first is the most powerful tax shelter available.
Offset gains with losses through tax-loss harvesting
Tax-loss harvesting means selling an investment at a loss to offset capital gains from other sales. If you sold stock A for a $10,000 gain and stock B for a $3,000 loss in the same year, your net gain is $7,000, and you owe tax on only that amount.
You can use losses to offset gains dollar-for-dollar. If your losses exceed your gains, you can deduct up to $3,000 of the excess loss against ordinary income in that year. Any remaining loss carries forward to future years, where you can use it again.
The wash-sale rule limits this strategy: if you sell a security at a loss, you cannot buy the same security (or a substantially identical one) within 30 days before or after the sale, or the loss is disallowed. You can buy a similar but different investment instead—for example, sell one S&P 500 index fund and buy a different one—to stay within the rule.
Donate appreciated assets directly to charity
If you own stock, real estate, or other assets that have risen in value, donating them directly to a may have access to charity avoids the capital gains tax entirely. You get a charitable deduction for the full current value, and the charity receives the asset without the donor owing any tax on the gain.
This works because the charity is tax-exempt. When they sell the asset later, they owe no tax. You benefit twice: you avoid capital gains tax on the appreciation, and you deduct the full fair market value as a charitable contribution on your tax return (subject to limits based on your adjusted gross income).
You must donate to a may have access to charitable organization—the IRS website has a searchable database. You cannot donate to individuals, political campaigns, or candidates. You will need a written appraisal for donations over $5,000, and you must file Form 8283 with your tax return.
Understand stepped-up basis for inherited assets
When you inherit an asset, its tax basis is "stepped up" to its fair market value on the date of the original owner's death. This means if your parent bought stock for $10,000 and it was worth $100,000 when they died, your basis is $100,000. If you sell it when ready for $100,000, you owe no capital gains tax, even though the asset appreciated $90,000 during your parent's lifetime.
This is a major tax benefit, but it applies only to inherited assets, not gifts. If your parent gave you the stock while alive, your basis remains $10,000, and you owe tax on the $90,000 gain when you sell. The stepped-up basis rule is set to expire at the end of 2025 under current law, though Congress may extend it.
Consider your income level and tax bracket
Your capital gains rate depends on your total taxable income for the year, not just the gains themselves. If you are near the edge of a tax bracket, timing when you realize gains can matter. Realizing a gain in a year when your other income is lower might keep you in the 15% bracket instead of pushing you into the 20% bracket.
This is especially relevant if you are retired or self-employed and have control over when you take income. Spreading gains across two years, or realizing them in a year when you have a large loss or lower business income, can reduce your effective rate.
You can also bunch charitable donations or business expenses into alternate years to manage your taxable income strategically. A tax professional can model different scenarios for you.
Frequently Asked Questions
Can I avoid capital gains tax by not selling?
Yes, as long as you hold the asset. Tax is due only when you sell or exchange it. If you hold until death, your heirs inherit at stepped-up basis and owe no tax on the appreciation during your lifetime. This is legal but only works if you do not need the money.
What if I have more losses than gains?
You can deduct up to $3,000 of net losses against ordinary income in one year. Any excess carries forward to future years indefinitely. This means a bad year in the market can shelter gains for years to come.
Do I owe capital gains tax on my home sale?
No, if you meet the exclusion: you must have owned and lived in the home as your primary residence for at least two of the last five years. Single filers can exclude up to $250,000 of gain; married filing jointly can exclude $500,000. Gains above that amount are taxable.
Can I use capital losses from one year in a different year?
Yes. Unused losses carry forward indefinitely. If you have a $10,000 loss this year but no gains to offset it, you deduct $3,000 against ordinary income and carry the remaining $7,000 forward to use next year or later.
Does selling at a loss and buying back the same stock work?
No, the wash-sale rule blocks it. You must wait 30 days after selling at a loss before buying the same or substantially identical security, or the loss is disallowed. You can buy a similar investment instead—a different index fund or a competitor's stock—to harvest the loss legally.