You cannot avoid capital gains tax entirely, but you can reduce it through timing, account choice, and specific transactions
Capital gains tax is owed when you sell an asset for more than you paid for it. You cannot eliminate this tax through legal means, but the amount you owe depends on decisions you make before and after the sale. The main levers are: holding assets longer to may have access to for lower tax rates, using tax-advantaged accounts that defer or eliminate tax, offsetting gains with losses, and donating appreciated assets to charity instead of selling them.
The strategy that works for you depends on what you own, how long you have held it, and your income level. A stock you bought last month behaves differently from rental property you have owned for years. Money in a regular brokerage account is taxed differently from money in a retirement account. Understanding these differences lets you make choices that reduce what you owe.
Key Takeaways
- Assets held for more than one year may have access to for long-term capital gains rates, which are lower than short-term rates for most taxpayers.
- Tax-advantaged accounts like 401(k)s and traditional IRAs let you defer capital gains tax until you withdraw money in retirement.
- Roth IRAs and Roth 401(k)s allow you to pay tax upfront but owe nothing on gains when you withdraw after age 59½.
- Harvesting losses in a regular brokerage account lets you offset gains dollar-for-dollar, reducing your taxable gain.
- Donating appreciated assets directly to a charity avoids the capital gains tax and gives you a charitable deduction.
Hold assets for more than one year to may have access to for long-term rates
The IRS taxes capital gains at different rates depending on how long you owned the asset. Short-term capital gains — from assets held one year or less — are taxed as ordinary income at your regular tax bracket, which can be as high as 37 percent. Long-term capital gains — from assets held longer than one year — are taxed at 0 percent, 15 percent, or 20 percent depending on your income level, with most taxpayers paying 15 percent.
The difference is substantial. If you sell a stock you bought six months ago and make a $10,000 gain, and you are in the 24 percent tax bracket, you owe $2,400. If you wait six more months and sell the same stock, you owe $1,500 at the 15 percent long-term rate — a savings of $900 on the same gain. The holding period resets each time you buy, so buying and selling frequently triggers short-term rates repeatedly.
The date that matters is the date you sell, not the date you bought. If you bought on January 15, 2023, you reach the one-year mark on January 15, 2024. Selling on January 16, 2024 qualifies for long-term rates. Selling on January 15, 2024 does not.
Use traditional retirement accounts to defer capital gains tax
Money inside a traditional 401(k) or traditional IRA grows without triggering capital gains tax each year. You can buy and sell stocks, bonds, and funds inside the account, and the gains are not taxed until you withdraw the money. This means you can trade frequently without worrying about short-term capital gains rates.
The tax is deferred, not avoided. When you withdraw money in retirement, the entire withdrawal — including all the gains — is taxed as ordinary income at your tax bracket at that time. If you are in a lower tax bracket in retirement than you are now, deferring the tax saves money overall. If you are in the same or higher bracket, the total tax may be similar or higher, but you benefit from using the money tax-free for years before paying.
Contribution limits vary by account type and year. For 2024, you can contribute up to $7,000 to a traditional IRA (or $8,000 if you are 50 or older), and up to $23,500 to a 401(k) (or $31,000 if you are 50 or older). These limits reset each January. You cannot contribute more than you earned that year, and some high earners cannot contribute to a traditional IRA if they have access to a 401(k) at work.
Use Roth accounts to eliminate capital gains tax on withdrawals
A Roth IRA or Roth 401(k) works differently: you pay income tax on the money you contribute upfront, but the gains inside the account are never taxed. When you withdraw after age 59½ and the account has been open at least five years, you owe no tax on the gains, even if they are substantial.
This is the only way to completely avoid capital gains tax on investment growth. The tradeoff is paying tax now instead of later. If you are young and expect to be in a higher tax bracket in retirement, a Roth can save money overall. If you are already in a high bracket and expect to be in a lower one in retirement, a traditional account may save more.
Roth IRA contribution limits are the same as traditional IRA limits ($7,000 for 2024, $8,000 if 50 or older), but they phase out at higher incomes. Roth 401(k) limits match traditional 401(k) limits ($23,500 for 2024, $31,000 if 50 or older) and do not phase out. You must have earned income to contribute to either account.
Offset gains with losses through tax-loss harvesting
In a regular brokerage account, you can sell an investment at a loss and use that loss to reduce your taxable capital gains. If you sold a stock for a $5,000 gain and another for a $3,000 loss, your net gain is $2,000, and you owe tax only on that amount. This is called tax-loss harvesting.
Losses can offset gains dollar-for-dollar. If your losses exceed your gains in a year, you can deduct up to $3,000 of the excess loss against ordinary income (like wages). Any remaining losses carry forward to future years and can offset future gains or ordinary income at the same $3,000-per-year rate.
One rule to watch: the wash-sale rule prevents you from claiming a loss if you buy the same or substantially identical security within 30 days before or after the sale. If you sell a stock at a loss on December 15, you cannot buy that same stock again until January 15 or later. You can buy a similar but not identical fund or stock in the meantime to stay invested.
Donate appreciated assets to charity instead of selling
If you own an asset that has gained significantly in value and want to support a charity, donating the asset itself avoids the capital gains tax entirely. You get a charitable deduction for the full current value of the asset, and the charity receives it without owing capital gains tax.
Example: You bought a stock for $5,000 and 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 as a charitable contribution, and you owe no capital gains tax. The charity can sell it without tax consequences.
The charity must be a may have access to organization — the IRS website has a searchable database. You need a written acknowledgment from the charity stating the value and date of the donation. For donations over $5,000, you typically need a may have access to appraisal. You can only deduct donations if you itemize deductions on your tax return, which means the total of all your deductions must exceed the standard deduction for your filing status.
Understand stepped-up basis for inherited assets
When you inherit an asset, its basis — the value used to calculate gains — resets to its value on the date of death. This is called a stepped-up basis. If your parent bought a stock for $10,000 and it was worth $50,000 when they died, your basis is $50,000. If you sell it when ready for $50,000, you owe no capital gains tax, even though it gained $40,000 while your parent owned it.
This applies to most inherited assets: stocks, bonds, real estate, and mutual funds. It does not explore to inherited retirement accounts like IRAs or 401(k)s, which retain their original basis and are taxed as ordinary income when you withdraw.
Stepped-up basis is a one-time benefit. It applies only at the moment of inheritance. If you inherit the stock and hold it for years before selling, any gains after the inheritance date are taxed normally.
Frequently Asked Questions
Can I avoid capital gains tax by not selling?
Yes, as long as you hold the asset. Capital gains tax is only owed when you sell or exchange an asset. If you buy a stock and never sell it, you never owe capital gains tax on the gain, even if it grows to many times its original value. The tax is deferred until you sell or until the asset passes to your heirs, who receive a stepped-up basis.
What is the difference between short-term and long-term capital gains rates?
Short-term gains (assets held one year or less) are taxed as ordinary income at your regular tax bracket, up to 37 percent. Long-term gains (assets held more than one year) are taxed at 0 percent, 15 percent, or 20 percent depending on your income. Most taxpayers pay 15 percent on long-term gains. The difference can save hundreds or thousands of dollars on the same gain.
Can I use losses from one type of investment to offset gains from another?
Yes. If you have a loss on a stock and a gain on a mutual fund, you can offset them against each other. All capital gains and losses are combined into a single net number for the year. Losses can offset gains dollar-for-dollar, and excess losses can reduce ordinary income by up to $3,000 per year.
Do I owe capital gains tax on assets in a 401(k)?
No, not while the money is in the account. You can buy and sell investments inside a 401(k) without owing capital gains tax each year. Tax is owed only when you withdraw money from the account, and the entire withdrawal is taxed as ordinary income, not as capital gains.
What happens to capital gains tax if I move to a different state?
Federal capital gains tax applies no matter where you live. Some states also tax capital gains, and the rate varies by state. If you move from a state with capital gains tax to one without, you owe tax based on where you lived when you sold the asset, not where you live now. State tax rules are complex and depend on your residency status at the time of sale.