Skip to main content

HomeAll guides

How Capital Gains Tax Works When You Sell an Investment

Capital gains tax is the tax you owe when you sell an investment for more than you paid for it

When you buy a stock, bond, real estate, or other investment and later sell it for a profit, that profit is called a capital gain. The IRS taxes that gain as income. The amount you owe depends on how long you held the investment and your total income for the year.

The tax does not explore to the money you originally invested — only to the increase in value. If you bought 100 shares of a stock for $1,000 and sold them for $1,500, your capital gain is $500, and that $500 is what gets taxed.

You do not owe capital gains tax just by owning an investment. You owe it only when you sell and realize the gain. If your stock goes up in value but you keep holding it, there is no tax bill yet.

Key Takeaways

  • Capital gains tax applies only to the profit you make when you sell an investment, not to the full sale price.
  • Short-term capital gains (investments held one year or less) are taxed as ordinary income at your regular tax rate.
  • Long-term capital gains (investments held more than one year) are taxed at lower rates: 0%, 15%, or 20%, depending on your income.
  • You report capital gains on your tax return, and the IRS uses your filing status and total income to determine your tax rate.
  • Losses on investments can offset gains and reduce your overall tax bill.

The difference between short-term and long-term capital gains

How long you owned the investment before selling it determines which tax rate applies. Short-term capital gains come from investments you held for one year or less. These are taxed as ordinary income — at the same rate as your salary or wages. If you are in the 24% tax bracket, a short-term gain is taxed at 24%.

Long-term capital gains come from investments you held for more than one year. These are taxed at lower rates: 0%, 15%, or 20%. Which rate you pay depends on your income and filing status, not on how much the investment gained. The IRS sets these brackets each year, and they change slightly for inflation.

The holding period is measured from the day you bought the investment to the day you sold it. If you bought a stock on March 15 and sold it on March 14 the next year, it is a short-term gain. If you sold it on March 16, it is long-term.

How the IRS calculates your capital gains tax rate

Your capital gains tax rate depends on your taxable income for the year and your filing status (single, married filing jointly, head of household, and so on). The IRS publishes income brackets for each rate each year.

For example, in 2024, a single filer with taxable income up to $47,025 pays 0% on long-term gains. Income from $47,026 to $518,900 is taxed at 15%. Income above that is taxed at 20%. These numbers change each year. A married couple filing jointly has higher brackets — their 0% bracket goes up to $94,050.

Your taxable income includes wages, interest, dividends, and capital gains all added together. If you have a large capital gain in one year, it might push you into a higher bracket for that year only. This is why some people spread large sales across two tax years if they can.

What counts as an investment for capital gains purposes

Capital gains tax applies to most things you buy and sell for profit: stocks, bonds, mutual funds, real estate, cryptocurrency, collectibles, and business assets. The rules are the same whether you bought one share or a rental property.

Your primary home is an exception. If you are single and sell a house you lived in for at least two of the last five years, you can exclude up to $250,000 of gain from tax. Married couples filing jointly can exclude up to $500,000. This exclusion applies once every two years.

Retirement accounts like 401(k)s and IRAs have different rules. Gains inside these accounts are not taxed when you sell investments within the account. You pay tax only when you withdraw money from the account, and the rate depends on the account type.

How to report capital gains on your tax return

When you sell an investment, your broker sends you a Form 1099-B showing the sale price and the date. You use this form to calculate your gain or loss and report it on your tax return.

You report capital gains on Schedule D (Form 1040), which is part of your federal tax return. You list each sale separately, showing the date you bought it, the date you sold it, the sale price, and your cost basis (what you paid for it). The IRS uses this information to calculate your total gain or loss for the year.

If you have multiple sales, you add up all short-term gains and losses to get a net short-term total, and all long-term gains and losses to get a net long-term total. If your long-term losses exceed your long-term gains, you can use up to $3,000 of the excess loss to offset ordinary income in that year. Any remaining loss carries forward to future years.

Using capital losses to reduce your tax bill

If you sell an investment for less than you paid for it, that is a capital loss. You can use capital losses to offset capital gains. If you sold one stock for a $2,000 gain and another for a $1,500 loss, your net gain is $500, and you owe tax only on that $500.

If your losses exceed your gains in a year, you can deduct up to $3,000 of the net loss against your other income (wages, interest, and so on). If your loss is larger than $3,000, the excess carries forward to the next tax year, where you can use it again.

This is why some investors deliberately sell losing positions late in the year — a strategy called tax-loss harvesting. By realizing the loss, they reduce their capital gains tax bill. The loss must be real (you actually sold the investment), not just a paper loss from holding it.

State and local taxes on capital gains

Federal capital gains tax is only part of the picture. Most states also tax capital gains, usually as ordinary income at your state tax rate. A few states do not tax capital gains at all: Alaska, Florida, Nevada, South Dakota, Tennessee, Texas, Washington, and Wyoming.

Some states have special capital gains taxes separate from income tax. California, for example, taxes long-term capital gains as ordinary income. Washington State has a 7% capital gains tax on long-term gains above $250,000 per year.

Your city or county may also have a tax on capital gains or investment income, depending on where you live. When you calculate what you owe on an investment sale, add your federal rate, your state rate, and any local rate together.

Frequently Asked Questions

Do I owe capital gains tax if I sell an investment at a loss?

No. A loss means you sold for less than you paid, so there is no gain to tax. You can use the loss to offset gains from other investments or, if losses exceed gains, to reduce your ordinary income by up to $3,000 per year.

What if I inherit an investment — do I owe capital gains tax?

No tax is due when you inherit. The investment gets a "stepped-up basis," meaning its value is reset to what it was worth on the date of death. If you later sell it, you owe tax only on gains that happen after you inherited it, not on gains that happened before.

Can I avoid capital gains tax by holding an investment forever?

Yes, as long as you do not sell. Capital gains tax is triggered only by a sale. If you hold until death, your heirs inherit with a stepped-up basis and owe no tax on the gains that happened during your lifetime.

How do I know my cost basis if I lost the original purchase records?

Your broker should have records going back several years. Contact them and ask for a cost basis report. If records are truly unavailable, you may be able to reconstruct the basis using historical price data, but this is complicated and you should consult a tax professional.

Are dividends taxed the same way as capital gains?

may have access to dividends are taxed at the same long-term capital gains rates (0%, 15%, or 20%). Non-may have access to dividends are taxed as ordinary income. Your broker will tell you which type each dividend is on your 1099 form.

This guide is for general information only and is not medical, financial, legal, or other professional advice. For decisions specific to your situation, consult a qualified professional. See our Editorial Policy.