What you can actually do to lower capital gains tax on stocks
You cannot avoid capital gains tax entirely if you sell stocks at a profit — the tax is owed when you realize the gain. But you can reduce the amount you owe through timing, account type, and loss strategies that are legal and commonly used. The IRS allows these moves; they are not loopholes.
The core methods are: holding stocks longer to may have access to for lower long-term rates instead of short-term rates, selling losing positions to offset winning ones, using tax-advantaged accounts like 401(k)s and IRAs, donating appreciated stock to charity instead of selling it, and spacing out large sales across multiple tax years. Each has specific rules about timing and documentation.
Key Takeaways
- Long-term capital gains (stocks held over one year) are taxed at 0%, 15%, or 20% depending on income; short-term gains are taxed as ordinary income, which is higher for most people.
- Tax-loss harvesting — selling stocks at a loss to offset gains — can reduce your taxable gain dollar-for-dollar, though the wash-sale rule prevents you from buying the same stock back within 30 days.
- Stocks held in a 401(k), traditional IRA, or Roth IRA generate no capital gains tax when sold inside the account; you only pay tax when you withdraw money (or never, in a Roth).
- Donating appreciated stock directly to a charity lets you avoid the capital gains tax entirely and claim a charitable deduction for the full current value.
- Spreading large sales across two or more tax years can keep you in a lower tax bracket and preserve tax credits that phase out at higher incomes.
Hold stocks for more than one year to get long-term rates
The single largest 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 — the same rate as your salary. Long-term gains are taxed at 0%, 15%, or 20% depending on your total income for the year.
For most people, long-term rates are substantially lower. If you are in the 24% tax bracket on salary, a short-term gain is taxed at 24%. The same gain held long-term is taxed at 15%. That is a 9 percentage point difference on every dollar of profit. The holding period is measured from the purchase date to the sale date; buying on January 15 and selling on January 16 of the next year counts as long-term.
This is the reason many investors wait before selling a stock that has risen sharply. If you bought a stock at $50 and it is now $80, waiting a few months to cross the one-year mark can save thousands in tax on a large position. The trade-off is that the stock price could fall during that waiting period, but the tax savings are often worth the risk for positions you already planned to hold.
Use tax-loss harvesting to offset gains
Tax-loss harvesting means selling a stock or fund at a loss and using that loss to reduce your taxable capital gains. 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. You pay tax only on the $2,000, not the $5,000.
Losses can also offset ordinary income, up to $3,000 per year. If you have $5,000 in losses and only $2,000 in gains, you can deduct $3,000 of the loss against your salary or other income. Any remaining loss carries forward to future years and can be used then.
The wash-sale rule is the main restriction. 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 loss is disallowed and added back to your cost basis instead. This rule exists to prevent people from claiming a loss and immediately repurchasing the same position. You can buy a similar but not identical fund or stock in the same sector — for example, selling a specific tech stock and buying a tech index fund — and the wash-sale rule does not apply.
Sell stocks inside retirement accounts to avoid tax entirely
Capital gains inside a 401(k), traditional IRA, or Roth IRA are not taxed when you sell. You can buy and sell stocks within these accounts as often as you want, and no capital gains tax is owed on the profit. This is one of the largest tax advantages these accounts offer.
In a traditional 401(k) or IRA, you pay tax when you withdraw the money in retirement, not when you sell the stock. In a Roth IRA or Roth 401(k), you pay no tax on withdrawals at all — the gains are never taxed. This makes Roth accounts especially valuable if you expect your stocks to grow significantly.
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,500 if 50 or older). These limits reset each year. If you have more money to invest than these limits allow, the excess must go into a taxable brokerage account, where capital gains tax applies.
Donate appreciated stock to charity instead of selling
If you own a stock that has risen significantly and you want to give to charity, donate the stock itself rather than selling it and donating the cash. You avoid the capital gains tax entirely, and you get a tax deduction for the full current market value of the stock.
Example: You bought a stock for $10,000 and it is now worth $40,000. If you sell it, you owe capital gains tax on the $30,000 gain. If you donate it to a may have access to charity, you owe zero capital gains tax and can deduct $40,000 on your tax return (subject to income limits on charitable deductions). The charity receives $40,000 in value, and you save both the capital gains tax and get a larger deduction than if you had sold and donated cash.
This strategy works only with donations to may have access to charities — 501(c)(3) organizations and similar entities. You cannot use it for donations to individuals, political campaigns, or non-may have access to organizations. You will need a written appraisal of the stock's value and documentation from the charity confirming receipt.
Spread large sales across multiple years to stay in lower tax brackets
Capital gains are added to your ordinary income to determine your tax bracket. If you sell a large position in one year, it might push you into a higher tax bracket, increasing the rate on both the gains and your other income. Selling the same position across two or three years can keep you in a lower bracket.
Example: You have $100,000 in gains to realize. Selling all of it in one year might push your income from $80,000 to $180,000, moving you from the 22% bracket to the 24% bracket. Selling $50,000 in year one and $50,000 in year two keeps you in the 22% bracket both years. The tax savings depend on your specific income and filing status, but the difference can be substantial.
This strategy also protects tax credits that phase out at higher incomes, such as the Earned Income Tax Credit or education credits. Staying below the phase-out threshold preserves the full credit value.
Understand the zero percent long-term capital gains rate
If your income is low enough, you may owe zero percent tax on long-term capital gains. For 2024, the 0% rate applies to single filers with taxable income up to $47,025 and married filers filing jointly up to $94,050. This rate is available only for long-term gains (stocks held over one year).
This is particularly useful for people in early retirement, those with irregular income, or those taking a year off work. If your income is below the threshold, you can realize long-term gains with no federal tax. Some states also have no capital gains tax, which further increases the benefit.
The 0% bracket fills up before the 15% bracket. If you are single and earn $40,000 in salary, you have roughly $7,000 of room in the 0% bracket before gains are taxed at 15%. Planning your income and gains around this threshold can result in significant tax savings.
Frequently Asked Questions
Can I buy the stock back right after selling it at a loss?
Not within 30 days. The wash-sale rule prevents you from claiming the loss if you buy the same or substantially identical stock within 30 days before or after the sale. You can buy a different stock or fund in the same sector immediately, but not the same one. After 30 days, you can repurchase without triggering the rule.
What if I inherit stock — do I pay capital gains tax on it?
No. Inherited stock receives a "step-up in basis," meaning your cost basis is reset to the stock's value on the date of death. If the stock was worth $100,000 when you inherited it and you sell it for $100,000 the next day, you owe no capital gains tax. You only pay tax on gains that occur after you inherit it.
Does selling at a loss help if I have no gains to offset?
Yes. You can deduct up to $3,000 of net capital losses against your ordinary income each year. Any losses beyond $3,000 carry forward to future years. This is useful if you have a bad year in the market and want to reduce your taxable income from salary or other sources.
Can I avoid capital gains tax by not selling?
You avoid the tax as long as you hold the stock, but the tax is not forgiven — it is deferred. When you eventually sell or pass the stock to heirs, the tax becomes due (unless you die, in which case heirs get the step-up in basis). The only way to truly avoid it is to donate to charity or hold until death.