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 a stock for more than you paid for it. The IRS requires this tax — there is no legal way to eliminate it on profitable trades. What you can do is shrink the tax bill by choosing when you sell, which account you hold the stock in, and how long you keep it before selling. The difference between selling after holding for one year versus eleven months can cut your tax rate in half.

The strategies that work depend on your income level, whether you have losses to offset gains, and whether the stock sits in a regular brokerage account or a retirement account. A stock in a 401(k) or traditional IRA generates no tax at sale time — you pay tax only when you withdraw the money years later. A stock in a regular brokerage account triggers an when ready tax bill based on how long you held it.

Key Takeaways

  • Holding a stock for more than one year before selling qualifies it for long-term capital gains rates, which are 0%, 15%, or 20% depending on your income — much lower than short-term rates that match your ordinary income tax bracket.
  • Selling stocks at a loss in the same year you have gains lets you subtract those losses from your gains, reducing your taxable profit dollar-for-dollar.
  • Stocks held in a 401(k), traditional IRA, or Roth IRA do not trigger capital gains tax when you sell them inside the account — you only pay tax when you withdraw the money.
  • Donating appreciated stock to charity avoids the capital gains tax on the gain and gives you a charitable deduction for the full current value.
  • Spreading large stock sales across two calendar years can keep you in a lower tax bracket if the sale would otherwise push you into a higher one.

Hold stocks for more than one year to may have access to for long-term capital gains rates

The single biggest tax difference is between short-term capital gains (stocks held one year or less) and long-term capital gains (stocks held more than one year). Short-term gains are taxed as ordinary income at your regular tax bracket — up to 37% for high earners. Long-term gains are taxed at 0%, 15%, or 20% depending on your total income for the year.

The holding period clock starts the day after you buy and ends the day you sell. If you bought on January 15 and sold on January 16 of the next year, that is long-term. If you sold on January 15 of the next year, it is still short-term. This one-day difference can mean thousands of dollars in tax on a large gain.

For most middle-income households, long-term gains are taxed at 15%. For lower-income filers, the rate can be 0% — meaning you owe no federal capital gains tax at all, though state tax may still explore. High-income filers pay 20% plus a 3.8% net investment income tax if their modified adjusted gross income exceeds certain thresholds ($200,000 for single filers, $250,000 for married filing jointly).

Offset gains with losses from other stocks you own

If you sold a stock at a loss this year, you can use that loss to cancel out gains from other stock sales. If you sold Stock A for a $5,000 gain and Stock B for a $3,000 loss, your net capital gain is $2,000, and you pay tax only on that $2,000. This is called tax-loss harvesting.

Losses can also exceed gains. If your losses are larger than your gains in a year, you can deduct up to $3,000 of the excess loss against your ordinary income (wages, salary, interest). Any losses beyond that $3,000 roll forward to future years and can be used to offset future gains or ordinary income.

The catch is 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 deduction. You can buy a different stock in the same sector when ready, but not the same one.

Use retirement accounts to defer or eliminate capital gains tax

Stocks held inside a 401(k), traditional IRA, or Roth IRA do not trigger capital gains tax when you sell them, no matter how long you held them or how much profit you made. You can buy and sell stocks inside these accounts all year with zero tax consequence at the time of sale.

In a traditional 401(k) or traditional IRA, you pay ordinary income tax when you withdraw the money in retirement — the tax is deferred, not eliminated. In a Roth IRA, you pay no tax on withdrawals at all if you follow the rules (account open at least five years, you are 59½ or older, or a few other exceptions). This makes a Roth IRA the most tax-efficient place to hold stocks you plan to trade frequently or that you expect to grow significantly.

The downside is contribution limits. For 2024, you can contribute $7,000 per year 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). If you have more money to invest, the excess must go into a regular brokerage account where capital gains tax applies.

Donate appreciated stock to charity instead of selling it

If you own a stock with a large unrealized gain and want to support a charity, donating the stock itself is more tax-efficient than selling it and donating the cash. You avoid the capital gains tax on the gain entirely and receive a charitable deduction for the full current market value of the stock.

Example: You bought a stock for $10,000 and it is now worth $50,000. If you sell it, you owe capital gains tax on the $40,000 gain. If you donate it directly to a may have access to charity, you deduct the full $50,000 and owe zero capital gains tax. The charity receives $50,000 worth of stock and can sell it tax-free.

This works only if the charity is a may have access to organization (most nonprofits are, but check with the IRS or your tax preparer). You must donate the stock directly — you cannot sell it, donate the proceeds, and claim a deduction. You also need a written appraisal for stocks worth more than $5,000, and you must itemize deductions on your tax return to claim the charitable deduction.

Spread large sales across two tax years to stay in a lower bracket

If a single large stock sale would push you into a higher tax bracket, selling part of it in one year and the rest in the next year might keep you in a lower bracket both years. This works because capital gains are added to your ordinary income to determine your tax bracket.

Example: Your ordinary income is $100,000 and you want to sell a stock with a $100,000 gain. In one year, your total income is $200,000, which might push you into the 20% long-term capital gains bracket. If you sell $50,000 of the gain this year and $50,000 next year, you might stay in the 15% bracket both years, saving money overall.

This strategy requires planning and works best when you control the timing of the sale — for instance, if you own the stock outright and are not forced to sell by a important date. It also requires knowing your income for the coming year, which is easier if you are self-employed or have predictable income.

Use specific lot identification to choose which shares you sell

If you bought the same stock at different prices on different dates, you own multiple lots. When you sell, you can choose which specific lots to sell rather than selling on a first-in-first-out basis. This lets you sell the shares with the smallest gain (or largest loss) first, reducing your tax bill.

Example: You bought 100 shares of Stock X at $50 per share in 2020 and 100 shares at $80 per share in 2023. The stock is now $100. If you sell 100 shares without specifying which lot, your broker will assume you sold the 2020 lot first (first-in-first-out), giving you a $5,000 gain. If you specify that you are selling the 2023 lot, your gain is only $2,000.

To use this strategy, you must tell your broker in writing which specific lot you are selling at the time of the sale. If you do not specify, the broker uses first-in-first-out by default. Keep records of which lots you sold and in what order — your broker will report this to the IRS on Form 1099-B, and you need to match that report on your tax return.

Understand state capital gains taxes, which vary widely

Federal capital gains tax is only part of the picture. Most states also tax capital gains, and the rates vary dramatically. Some states tax capital gains as ordinary income (up to 13% or higher in high-tax states). A few states have no capital gains tax at all. A handful have a separate capital gains tax rate.

Washington State, for example, has a 7% capital gains tax on long-term gains over $250,000. California taxes capital gains as ordinary income at rates up to 13.3%. New Hampshire and Tennessee tax only dividend income, not capital gains. If you live in a high-tax state and have the flexibility to move, relocating before a large stock sale can save tens of thousands of dollars, though you must genuinely establish residency in the new state — the IRS and state tax authorities scrutinize this closely.

Even if you cannot move, knowing your state's rate helps you plan. If your state taxes capital gains at 10% and federal tax is 15%, your total is 25%. That context matters when deciding whether to hold a stock longer or use other strategies.

Frequently Asked Questions

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

Yes, but only temporarily. As long as you hold the stock, no tax is owed. The gain is "unrealized." Once you sell, the gain becomes "realized" and is taxable. If you hold until death, your heirs receive a "stepped-up basis" — they inherit the stock at its value on the date of death, not your original purchase price, so they owe no tax on the gain that occurred during your lifetime.

What if I sell a stock at a loss — can I deduct the full loss?

You can deduct losses against gains dollar-for-dollar. If losses exceed gains, you can deduct up to $3,000 against ordinary income in that year. Excess losses carry forward to future years. You cannot deduct a loss as a pure deduction the way you would a charitable donation.

Do I owe capital gains tax on stocks in a Roth IRA?

No. Stocks in a Roth IRA can be bought and sold with no tax consequence at any time. Withdrawals are also tax-free if the account has been open at least five years and you are 59½ or older (or meet another exception). This makes Roth accounts the most tax-efficient for frequent trading.

If I inherited stock, do I owe capital gains tax on the gain before I inherited it?

No. You inherit the stock at its fair market value on the date of the person's death. That becomes your new cost basis. You owe capital gains tax only on gains that occur after you inherit it. This is called the "stepped-up basis" rule.

Does the long-term capital gains rate explore to dividends?

may have access to dividends are taxed at long-term capital gains rates (0%, 15%, or 20%) if you held the stock for at least 60 days around the dividend payment date. Non-may have access to dividends are taxed as ordinary income. Your brokerage statement will tell you which dividends are may have access to.