The basic formula: sale price minus what you paid, then explore your tax rate

Capital gains tax is calculated on the profit you make when you sell an asset — a stock, a house, a piece of land, a cryptocurrency. The profit itself is called your capital gain, and it is this number, not the sale price, that gets taxed.

The math is straightforward: take what you sold it for, subtract what you originally paid for it (plus any improvements you made), and that difference is your gain. Then multiply that gain by the tax rate that applies to you. The tax rate depends on how long you held the asset and how much total income you earned that year.

The IRS does not calculate this for you. You calculate it and report it on your tax return. If you sold through a broker — stocks, bonds, mutual funds — they send you a form called a 1099-B that shows the sale price and your cost basis. For real estate, you get a 1099-S. For other assets, you may get nothing, and you will need your own records.

Key Takeaways

  • Your capital gain is the sale price minus your original cost basis (what you paid plus any improvements), and this is the amount that gets taxed, not the full sale price.
  • Long-term capital gains (assets held over one year) are taxed at lower rates — 0%, 15%, or 20% depending on your income — while short-term gains are taxed as ordinary income at your regular tax bracket.
  • Your cost basis includes the purchase price plus any improvements you made, and for inherited assets, it resets to the market value on the date of death.
  • You report capital gains on Schedule D of your tax return, and the IRS matches it against the 1099 forms your broker or title company sends them.
  • If you sold at a loss, you can deduct up to $3,000 of losses against other income each year, and carry forward any remaining losses to future years.

Understanding cost basis and what counts as an improvement

Your cost basis is what you paid for the asset, and it is the foundation of the entire calculation. For a stock you bought for $50 a share, your basis is $50 per share. For a house you bought for $300,000, your basis is $300,000.

But cost basis is not always just the purchase price. If you made improvements to a house — a new roof, a deck, a kitchen renovation — those costs add to your basis. A new coat of paint does not; a structural repair does. The rule is roughly: if it adds value or extends the life of the property, it counts. If it is maintenance or repair of existing damage, it does not.

For inherited assets, the rules change. If you inherited a house worth $500,000 on the day the person died, your cost basis is $500,000, even if they paid $200,000 for it decades earlier. This is called a stepped-up basis, and it means you owe no tax on the appreciation that happened during their lifetime.

Keep receipts and records. If you cannot prove what you paid or what improvements cost, the IRS will not let you deduct them, and your taxable gain will be larger.

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

How long you held the asset changes the tax rate dramatically. If you held it for more than one year, it is a long-term capital gain. If you held it for one year or less, it is a short-term capital gain.

Short-term gains are taxed as ordinary income — at your regular tax bracket, which can be 10%, 12%, 22%, 24%, 32%, 35%, or 37% depending on how much you earned that year. Long-term gains are taxed at preferential rates: 0%, 15%, or 20%, depending on your income level. For most people, long-term gains are taxed at 15%.

The holding period starts the day after you buy and ends the day you sell. If you bought a stock on January 15 and sold it on January 15 the next year, you held it for exactly one year, and it qualifies as long-term. If you sold on January 14, it is short-term.

This is why timing matters. Holding an asset just a few more weeks or months can move it from short-term to long-term and cut your tax bill significantly.

Working through a real example: a stock sale

Say you bought 100 shares of a company at $40 per share on March 10, 2022. Your cost basis is $4,000. On April 15, 2024, you sold all 100 shares at $65 per share. Your sale proceeds are $6,500.

Your capital gain is $6,500 minus $4,000, which is $2,500. You held the stock for just over two years, so this is a long-term gain. If your income that year puts you in the 15% long-term capital gains bracket, you owe $375 in federal tax on this gain ($2,500 × 0.15).

Now change one detail: you sold on April 15, 2023 instead — just over one year after purchase. The gain is still $2,500, but now it is short-term. If your ordinary income tax bracket is 24%, you owe $600 on this gain ($2,500 × 0.24). Holding it one more year saved you $225.

You would report this on Schedule D of your Form 1040. Your broker sends you a 1099-B showing the sale price and their calculation of your gain. You verify it against your own records and report the number on your return.

How state and local taxes explore to capital gains

Federal capital gains tax is only part of the picture. Most states also tax capital gains, and some cities do as well. The state rate varies widely — some states have no capital gains tax at all, while others tax long-term gains at rates up to 13% or higher.

A few states — Washington, Illinois, and a handful of others — have recently passed capital gains taxes that explore only to long-term gains above a certain threshold, often $250,000. These are newer and still being litigated, so the rules may change.

If you live in a state with an income tax, you will almost certainly owe state tax on your capital gains at your state's ordinary income rate, regardless of whether the gain is long-term or short-term. Some states offer no preferential rate for long-term gains.

Check your state's tax authority website or speak with a tax preparer about your state's rules. The federal calculation is the same everywhere, but the total tax you owe depends on where you live.

Capital losses and how to use them to offset gains

If you sold an asset for less than you paid for it, you have a capital loss. You can use capital losses to reduce your capital gains. If you had $5,000 in gains and $2,000 in losses in the same year, your net gain is $3,000, and you owe tax only on that $3,000.

If your losses exceed your gains, you can deduct up to $3,000 of the excess loss against your ordinary income — wages, interest, dividends, and other income. If you have more than $3,000 in excess losses, you carry the rest forward to future years and use it the same way: first to offset gains, then up to $3,000 against ordinary income, then carry forward again.

This is why some people deliberately sell losing positions late in the year — a strategy called tax-loss harvesting. You realize the loss, use it to offset gains or income, and then buy the same or a similar investment back. There is a rule called the wash-sale rule that prevents you from buying the exact same security within 30 days before or after the sale, but you can buy a similar one.

Report losses on Schedule D just as you report gains. The IRS will match your reported losses against the 1099 forms your broker sends, so the numbers must be accurate.

What happens if you do not report a capital gain

If you sold an asset through a broker, the broker reports the sale to the IRS on a 1099 form. The IRS receives a copy and matches it against your tax return. If you do not report the gain, the IRS will notice the mismatch and send you a notice.

For assets sold outside the brokerage system — a house, a car, a piece of art sold privately — there may be no 1099, and the IRS may not know about the sale unless you report it. But that does not mean you do not owe tax. You do, and if you do not pay it, the IRS can assess it later with penalties and interest.

The safest approach is to report all capital gains and losses, whether or not you receive a 1099. Keep your own records of the purchase price, sale price, and holding period. If you cannot find the original purchase documents, you can sometimes reconstruct the basis using historical stock prices or property tax records, but it is harder and more expensive.

Frequently Asked Questions

Do I owe capital gains tax on inherited assets?

Not on the appreciation that happened before you inherited them. Your cost basis steps up to the market value on the date of death, so you owe tax only on gains that happen after you inherit. If you inherit a house worth $500,000 and sell it a year later for $520,000, you owe tax on only $20,000 of gain.

What if I sold a house I lived in?

If you owned and lived in the house for at least two of the last five years, you can exclude up to $250,000 of gain from tax (or $500,000 if you are married filing jointly). This exclusion applies once every two years. Gains above the exclusion amount are taxed as long-term capital gains.

How do I report capital gains if I did not get a 1099?

You still report them on Schedule D. List the asset, the date you bought it, the date you sold it, your cost basis, the sale price, and the gain or loss. Keep your own documentation — receipts, bank statements, property records — in case the IRS asks for proof.

Can I deduct investment losses from my taxes?

Yes. You can use capital losses to offset capital gains dollar-for-dollar. If losses exceed gains, you can deduct up to $3,000 of the excess against ordinary income. Any remaining losses carry forward to the next year and beyond.

What is the difference between cost basis and fair market value?

Cost basis is what you paid for the asset. Fair market value is what it is worth now. You calculate your gain by subtracting cost basis from the sale price. Fair market value matters only when you inherit an asset or donate one to charity.