You cannot avoid capital gains tax on profits, but you can reduce what you owe through timing, account type, and loss harvesting

Capital gains tax is owed on the profit when you sell a stock for more than you paid for it. There is no legal way to eliminate this tax entirely if you have a gain. What you can do is lower the amount of gain that gets taxed, delay when you pay, or use account types that tax gains differently. The strategies that work depend on your income, how long you held the stock, and whether you have losses to offset gains.

The IRS taxes long-term gains (stocks held over one year) at lower rates than short-term gains (held one year or less). For most people, long-term rates are 0%, 15%, or 20% depending on income. Short-term gains are taxed as ordinary income, which can be much higher. The single most effective move for most people is simply holding stocks longer before selling.

Key Takeaways

  • Holding a stock for more than one year before selling qualifies it for long-term capital gains rates, which are lower than short-term rates for most taxpayers.
  • Tax-loss harvesting means selling stocks at a loss to offset gains from other sales, reducing your total taxable gain for the year.
  • Stocks held in a Roth IRA or Roth 401(k) generate no capital gains tax when you sell them inside the account, though withdrawals before age 59½ may face penalties.
  • Donating appreciated stock to charity avoids the capital gains tax on the gain and gives you a charitable deduction for the full current value.
  • Married couples filing jointly can use the step-up in basis rule when one spouse dies, which resets the cost basis and can eliminate gains entirely.

Hold stocks longer to may have access to for lower tax rates

The difference between short-term and long-term capital gains rates is substantial. If you sell a stock within one year of buying it, the gain is taxed as ordinary income—the same rate as your salary or wages. For a person in the 24% federal tax bracket, a $10,000 short-term gain costs $2,400 in federal tax. The same $10,000 long-term gain costs $1,500 (at the 15% rate) or $0 (if your income is low enough to may have access to for the 0% rate).

The holding period starts the day after you buy the stock and ends the day you sell it. If you bought on January 15, 2024, and sold on January 15, 2025, you meet the one-year threshold. If you sold on January 14, 2025, you do not. This is a hard rule with no exceptions.

This strategy requires no paperwork, no special account, and no coordination with the IRS. You simply wait. For stocks you plan to hold anyway, this is the easiest tax reduction available. For stocks you want to sell sooner, you face a choice: pay the higher short-term rate now, or hold longer and pay less later.

Use tax-loss harvesting to offset gains

Tax-loss harvesting means selling a stock at a loss to reduce your taxable gains. If you sold Stock A for a $5,000 gain and Stock B for a $3,000 loss in the same year, your net gain is $2,000, and you owe tax only on that $2,000. The loss "harvests" the gain.

You can harvest losses throughout the year as opportunities arise. Many investors review their portfolio in November and December specifically to identify losing positions they can sell before year-end. The loss counts against gains from the same year. If you have more losses than gains in a year, you can deduct up to $3,000 of the excess loss against ordinary income (like wages). Any losses beyond $3,000 carry forward to future years and can be used against future gains or ordinary income.

One restriction: the wash-sale rule. If you sell a stock at a loss, you cannot buy the same stock (or a substantially identical one) within 30 days before or after the sale. If you do, the IRS disallows the loss. You can buy a different stock in the same sector or a similar fund to stay invested while avoiding the wash-sale violation. The 30-day window is strict: 30 days before the sale, the day of sale, and 30 days after.

Hold stocks in a Roth account to avoid capital gains tax inside the account

A Roth IRA or Roth 401(k) is an account type where you pay income tax on the money going in, but then pay no tax on gains, dividends, or capital gains when you sell stocks inside the account. You can buy and sell stocks within a Roth as many times as you want without triggering any tax.

The catch is access. You cannot withdraw money from a Roth IRA before age 59½ without paying a 10% penalty on the earnings (contributions can come out penalty-free). A Roth 401(k) has the same age restriction. If you need the money before then, the tax savings disappear because the penalty often exceeds what you would have paid in capital gains tax anyway.

Roth accounts also have contribution limits. For 2024, you can contribute $7,000 to a Roth IRA if you are under 50 (or $8,000 if you are 50 or older), and your income must be below a certain threshold to contribute directly. A Roth 401(k) allows higher contributions if your employer offers one. These accounts work best for long-term retirement savings, not for active trading or money you may need soon.

Donate appreciated stock to charity instead of selling it

If you own a stock that has gained significantly and you want to give to charity, donating the stock itself (rather than selling it and donating the cash) avoids the capital gains tax entirely. You receive a charitable deduction for the full current market value of the stock, and the charity receives the stock tax-free.

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 from your taxable income, and you owe zero capital gains tax. The charity can then sell the stock without tax consequences.

This only works if you donate to a may have access to charitable organization—typically a 501(c)(3) nonprofit, religious organization, or public charity. You must itemize deductions on your tax return for the deduction to matter (if you take the standard deduction, the deduction is worthless). You also need a written appraisal for stocks worth over $5,000 and must file Form 8283 with your tax return.

Use the step-up in basis rule after death

When someone dies, their heirs receive a step-up in basis. This means the cost basis of inherited stocks is reset to the market value on the date of death, not the original purchase price. If your parent bought a stock for $10,000 and it was worth $50,000 when they died, your new cost basis is $50,000. If you sell it the next day for $50,000, you owe zero capital gains tax.

This is a significant tax benefit, but it applies only to inherited property, not to gifts made during life. If your parent gave you the stock while alive, your cost basis stays at $10,000, and you owe tax on the $40,000 gain when you sell. This is why some families hold appreciated assets until death rather than giving them away—the step-up eliminates the tax burden for heirs.

The step-up applies to all inherited property: stocks, real estate, bonds, and other assets. It is automatic; you do not need to file anything special. Your executor or the person managing the estate will report the stepped-up value on the estate tax return (if one is required) and provide that value to heirs.

Consider your income level and tax bracket

Long-term capital gains rates depend on your total income for the year. The 0% rate applies to long-term gains if your income falls below a certain threshold ($47,025 for single filers in 2024, $94,050 for married filing jointly). The 15% rate applies to most middle-income taxpayers. The 20% rate applies to high-income earners. These thresholds change each year.

If you are near a threshold, timing when you sell can matter. Selling in a year when your income is lower (perhaps a year you took unpaid leave, retired, or had a major loss) may push your gains into a lower tax bracket. Conversely, selling in a high-income year may push you into the 20% bracket. This is most relevant for people with control over their income timing—business owners, freelancers, or those planning retirement.

You can also use income-splitting strategies if you are married. A married couple filing jointly has higher income thresholds for the 0% and 15% rates than single filers. Coordinating when each spouse sells assets can sometimes keep both of you in lower brackets.

Frequently Asked Questions

Can I sell a stock at a loss and buy it back right away?

No. The wash-sale rule prevents this. You must wait 30 days after selling at a loss before buying the same stock or a substantially identical one. If you buy within that window, the IRS disallows the loss. You can buy a similar but different stock (like a different company in the same industry or a different index fund) to stay invested.

Do I owe capital gains tax if I sell stocks in a regular brokerage account and reinvest the money?

Yes. The tax is based on the gain, not on what you do with the money afterward. Selling a stock for a profit triggers capital gains tax regardless of whether you spend the money, hold it in cash, or buy other stocks. The reinvestment does not change the tax owed on the original sale.

What if I have more capital losses than gains in a year?

You can deduct up to $3,000 of net capital losses against your ordinary income (wages, salary, etc.) in a single year. Any losses beyond $3,000 carry forward to future years and can be used against future gains or ordinary income. This means a year with large losses can reduce your overall tax bill, even if you have no gains.

Does holding a stock in a taxable account for a very long time reduce the tax rate further?

No. The tax rate depends only on whether you held the stock over one year (long-term) or one year or less (short-term). Holding for five years, ten years, or fifty years does not lower the rate further. Long-term is long-term once you cross the one-year mark.

Can I avoid capital gains tax by not selling the stock?

Yes, but only temporarily. As long as you own the stock, you owe no tax on the gain. The tax is triggered only when you sell. However, if you eventually sell, you will owe the tax then. The only way to avoid it permanently is to hold until death (so your heirs get the step-up) or donate the stock to charity.