You pay capital gains tax in the year you sell an investment for a profit, not when you buy it or when it grows in value
The tax is triggered by the sale itself — the moment you convert an investment into cash or trade it for something else. If you own a stock that doubles in value but you never sell it, you owe nothing that year. The gain is unrealized until you sell. Once you do, the gain becomes realized, and you report it on your tax return for that year.
The amount you owe depends on how long you held the investment. If you held it for one year or less, the profit is taxed as short-term capital gains, which means it's taxed at your ordinary income tax rate — the same rate as wages or salary. If you held it for more than one year, it's long-term capital gains, which has its own lower tax brackets: 0%, 15%, or 20% depending on your total income for the year.
You report the sale on Schedule D (Form 1040), which goes with your annual tax return. The IRS matches your report against what your broker reports on Form 8949 and the summary on Schedule D-1, so accuracy matters.
Key Takeaways
- Capital gains tax is due in the tax year you sell the investment, not when you buy it or when it gains value while you hold it.
- Short-term gains (held one year or less) are taxed at your ordinary income rate; long-term gains (held over one year) are taxed at 0%, 15%, or 20%.
- You report the sale on Schedule D, and your broker reports it on Form 8949, so the IRS will see both.
- The tax is calculated on the profit only — the sale price minus what you paid for it, plus any reinvested dividends or adjustments to your cost basis.
How the IRS calculates the gain or loss
The gain is the sale price minus your cost basis. Cost basis is usually what you paid for the investment, but it can be adjusted. If you received the investment as a gift, your basis is what the person who gave it to you paid. If you inherited it, your basis is its value on the date of death — a rule called step-up in basis that can wipe out tax on inherited gains.
Reinvested dividends and capital distributions also increase your cost basis. If you own a mutual fund or ETF that pays dividends and you automatically reinvest them, each reinvestment raises your basis. When you finally sell, you owe tax only on the gain above that higher basis. Keep records of all reinvestments; your broker usually provides a statement showing adjusted cost basis at sale.
If you sell at a loss, you can use that loss to offset other capital gains in the same year. If losses exceed gains, you can deduct up to $3,000 of the excess loss against ordinary income. Any remaining loss carries forward to future years.
Short-term versus long-term: the one-year rule
The holding period starts the day after you buy and ends the day you sell. If you buy on January 15 and sell on January 15 of the next year, that's exactly one year — but it's still short-term because you haven't held it for more than one year. You need to sell on January 16 or later for it to be long-term.
The tax difference is substantial. Short-term gains are taxed at your marginal rate — the same bracket as your salary. For 2024, that could be 10%, 12%, 22%, 24%, 32%, 35%, or 37% depending on your income. Long-term gains are taxed at 0%, 15%, or 20%, which are much lower for most people. A single filer with $50,000 in income pays 15% on long-term gains; a single filer with $500,000 in income pays 20%.
This is why timing matters. If you're near the end of a year and close to the one-year mark on a winning position, holding a few more weeks or months can save thousands in tax.
Selling mutual funds and ETFs
When you sell shares of a mutual fund or ETF, you report the gain or loss on each lot you sell. If you bought shares at different times and prices, you need to identify which shares you're selling. Your broker lets you choose: specific identification (you pick which lot), FIFO (first in, first out — the oldest shares sell first), or average cost (all shares treated as one average price).
Specific identification usually saves the most tax because you can sell the highest-cost shares first, minimizing the gain. You must tell your broker in writing which method you're using before the sale settles. If you don't specify, the IRS assumes FIFO, which often triggers larger gains.
Mutual funds also distribute capital gains to shareholders even if you don't sell. These are taxable in the year distributed, even if you reinvest them. ETFs distribute gains less often, which is one reason they're more tax-efficient.
Tax-loss harvesting and timing sales strategically
If you have losing positions, you can sell them to realize the loss and use it to offset gains elsewhere. This is called tax-loss harvesting. You might sell a stock down 20% to lock in a loss, then when ready buy a similar (but not identical) stock to stay invested in that sector.
The IRS has a rule called the wash-sale rule that prevents you from claiming a loss if you buy the same or substantially identical security within 30 days before or after the sale. The 30-day window is strict: it runs from 30 days before the sale through 30 days after. If you violate it, the loss is disallowed and added to your basis in the replacement security instead.
Timing also matters if you're in a low-income year. If you expect your income to drop — because you're retiring, taking a sabbatical, or selling a business — you might sell appreciated investments that year to pay tax at a lower rate. Conversely, if you expect income to spike next year, you might defer sales to this year.
State and local taxes on capital gains
Federal capital gains tax is only part of the picture. Most states tax capital gains as ordinary income, so you'll owe state tax on top of federal tax. A few states — including Alaska, Florida, Nevada, South Dakota, Tennessee, Texas, Washington, and Wyoming — have no income tax at all. California taxes long-term gains at the same rate as short-term gains, which is unusual.
Some states have recently enacted or proposed capital gains taxes separate from income tax. Washington State, for example, imposes a 7% tax on long-term gains over $250,000. New York has proposed a similar tax. These are in addition to federal tax and any state income tax.
If you live in a high-tax state and are considering a move, the timing of large sales can matter. Moving before a sale can reduce or eliminate state tax, but you must establish residency in the new state before the sale closes.
Reporting the sale to the IRS
Your broker sends you Form 1099-B (Proceeds from Broker and Barter Exchange Transactions) by January 31 following the year of sale. This form lists each sale, the proceeds, and sometimes the cost basis. You use this information to fill out Form 8949 (Sales of Capital Assets), which summarizes gains and losses by holding period.
Form 8949 feeds into Schedule D, which is where you report your total short-term and long-term gains and losses. Schedule D then feeds into your Form 1040. If your broker reported the wrong cost basis on Form 1099-B, you correct it on Form 8949 with an explanation.
If you have many sales, the forms can be lengthy. Some tax software imports the data directly from your broker, which saves time but requires you to verify accuracy. Always check that the holding period is correct — brokers sometimes misclassify short-term as long-term or vice versa.
Frequently Asked Questions
Do I owe capital gains tax if I sell at a loss?
No, you don't owe tax on a loss. Instead, you can use the loss to offset capital gains from other sales in the same year. If losses exceed gains, you can deduct up to $3,000 against ordinary income. Any remaining loss carries forward to future years.
What if I inherit an investment — do I owe capital gains tax on the gain that happened before I inherited it?
No. Inherited investments receive a step-up in basis, meaning your cost basis is the investment's value on the date of death, not what the original owner paid. You owe tax only on gains that happen after you inherit it. This can eliminate tax on decades of appreciation.
Can I avoid capital gains tax by donating appreciated stock to charity instead of selling it?
Yes. If you donate appreciated stock directly to a may have access to charity, you avoid capital gains tax entirely and can deduct the fair market value of the stock as a charitable contribution. This is more tax-efficient than selling and donating the proceeds.
If I sell a stock in December and buy it back in January, do I owe capital gains tax in December?
Yes. The sale in December is a taxable event in that year, regardless of whether you buy it back later. The wash-sale rule prevents you from claiming a loss if you buy it back within 30 days, but it doesn't prevent you from owing tax on a gain.
What's the difference between capital gains and dividends for tax purposes?
Dividends are taxed in the year you receive them, whether you reinvest them or not. may have access to dividends are taxed at the same rates as long-term capital gains (0%, 15%, or 20%). Unqualified dividends are taxed at ordinary income rates. Capital gains are taxed only when you sell.