The basic steps to find what you owe

To figure out capital gains tax, you need three numbers: what you paid for an asset, what you sold it for, and how long you held it. Subtract the purchase price from the sale price to get your gain. Then explore the tax rate that matches your income level and how long you owned the asset. The IRS taxes long-term gains (held over one year) at lower rates than short-term gains (held one year or less), which are taxed as ordinary income.

The math itself is straightforward, but the details matter. You need the exact cost basis — the original price plus any fees or improvements you made — not just a rough memory of what you paid. You also need to know your filing status and total income for the year, because capital gains tax rates depend on both. The rate brackets change each year, so a gain that falls in the 15% bracket one year might fall in the 20% bracket the next.

Key Takeaways

  • Capital gain equals the sale price minus your cost basis, which includes the original purchase price plus any fees, commissions, or improvements you made to the asset.
  • Long-term gains (assets held over one year) are taxed at 0%, 15%, or 20% depending on your income and filing status; short-term gains are taxed as ordinary income at your regular tax bracket.
  • You report capital gains on Schedule D (Form 1040) and calculate the tax using the worksheets in the Form 1040 instructions or tax software.
  • If you sell at a loss, you can deduct up to $3,000 of losses against other income in a single year, and carry unused losses forward to future years.

Finding your cost basis

Cost basis is what you actually paid for the asset, including all costs to buy it. For a stock, this is the share price plus any brokerage commission. For real estate, it includes the purchase price, closing costs, title insurance, and any capital improvements you made — like adding a deck or replacing the roof. It does not include maintenance or repairs, which are separate deductions.

Your broker or financial institution should send you a statement showing cost basis for stocks and mutual funds sold during the year. For real estate, you will need to gather your closing documents and receipts for any improvements. If you inherited an asset, the cost basis is usually the market value on the date of death, not what the person who left it to you originally paid. This is called a "step-up in basis" and can significantly reduce your tax.

Keep records of everything: purchase confirmations, brokerage statements, receipts for improvements, and sale documents. The IRS can ask for these records years later, and without them you may have to pay tax on the full sale price if you cannot prove your basis.

Calculating the gain or loss

Subtract your cost basis from the sale price. If the result is positive, you have a capital gain. If it is negative, you have a capital loss.

Example: You bought a stock for $5,000 (including commission) and sold it for $8,500. Your gain is $3,500. If you held it for more than one year, this is a long-term gain.

If you sold multiple assets in the same year, calculate the gain or loss for each one separately. Then add them together. You may have some long-term gains and some short-term losses in the same year — these do not cancel out at the same rate. Long-term and short-term gains are taxed differently, so you track them separately on Schedule D.

Determining if your gain is long-term or short-term

The holding period starts the day after you buy and ends on the day you sell. If you held the asset for more than one year, it is long-term. If one year or less, it is short-term. The date matters: if you bought on January 15, 2023, and sold on January 15, 2024, that is exactly one year, which counts as short-term. You need to hold until January 16, 2024, for it to be long-term.

Long-term gains are taxed at preferential rates: 0%, 15%, or 20%, depending on your total income and filing status. Short-term gains are taxed as ordinary income at your regular tax bracket, which can be as high as 37%. This difference is why holding period matters so much.

For stocks and mutual funds, your brokerage statement will usually show the holding period. For real estate and other assets, you need to track the dates yourself.

Finding your tax rate based on income and filing status

Long-term capital gains tax rates are 0%, 15%, or 20%. Which rate applies depends on your taxable income (not gross income) and your filing status. The IRS publishes income thresholds each year that determine which bracket you fall into.

For 2024, the 0% rate applies to single filers with taxable income up to $47,025 and married filing jointly filers up to $94,050. The 15% rate applies to income above those thresholds up to $518,900 (single) or $583,750 (married filing jointly). Income above those amounts is taxed at 20%. These numbers change each year, so check the IRS website or your tax software for the current year.

Your taxable income includes wages, interest, dividends, and capital gains all added together. If you have a large capital gain, it may push you into a higher bracket. For example, if you are single with $40,000 in wages and a $20,000 long-term capital gain, your taxable income is $60,000, which puts the gain partly in the 0% bracket and partly in the 15% bracket.

Short-term gains use your ordinary income tax brackets, which range from 10% to 37% depending on income and filing status.

Using Schedule D to report your gains

You report all capital gains and losses on Schedule D (Form 1040), which you file with your federal tax return. Part I is for short-term gains and losses. Part II is for long-term gains and losses. You list each transaction separately: the asset, the date acquired, the date sold, the sale price, the cost basis, and the gain or loss.

At the bottom of Schedule D, you combine all short-term gains and losses into one net number, and all long-term gains and losses into another. If your long-term gains exceed long-term losses, you have a net long-term gain, which gets taxed at the preferential rates. If short-term gains exceed short-term losses, you have a net short-term gain, which gets taxed as ordinary income.

If you have a net loss in either category, you can deduct up to $3,000 against other income (wages, interest, dividends) in that year. Any loss above $3,000 carries forward to future years with no time limit. You will need to file Schedule D every year you have a capital gain or loss, even if the loss carries forward.

What happens if you have a capital loss

A capital loss occurs when you sell an asset for less than you paid for it. You can use capital losses to offset capital gains dollar-for-dollar. If you have $10,000 in long-term gains and $4,000 in long-term losses, your net long-term gain is $6,000, and you pay tax only on that amount.

If your losses exceed your gains, you can deduct up to $3,000 of the excess against other income — wages, interest, dividends, or business income — in a single tax year. If you have more than $3,000 in unused losses, they carry forward to the next year. You can keep using $3,000 per year until the losses are gone.

Example: You have $2,000 in capital gains and $8,000 in capital losses. You offset the $2,000 gain completely. You deduct $3,000 of the remaining $6,000 loss against other income. The unused $3,000 loss carries to next year.

Frequently Asked Questions

Do I have to pay capital gains tax if I reinvest the money?

Yes. The tax is based on the gain itself, not on what you do with the proceeds. If you sell a stock for a $5,000 profit and when ready buy another stock with that money, you still owe tax on the $5,000 gain. Reinvesting does not defer or eliminate the tax.

What if I inherited an asset and then sold it?

Inherited assets receive a "step-up in basis" to their market value on the date of death. If you inherited a house worth $300,000 and the person who left it to you paid $150,000 for it, your cost basis is $300,000, not $150,000. If you sell it shortly after for $305,000, your gain is only $5,000. This step-up applies whether you inherit stocks, real estate, or other assets.

How do I report a capital loss if I did not have any gains?

You still file Schedule D and report the loss. You can deduct up to $3,000 against your other income for the year. Any unused loss carries forward to the next year on a new Schedule D. You will need to file Schedule D in future years to claim the carryover, even if you have no new transactions.

Are cryptocurrency gains taxed the same way as stock gains?

Yes. The IRS treats cryptocurrency as property. When you sell or trade it, you calculate the gain or loss the same way: sale price minus cost basis. If you held it over one year, it is long-term and taxed at the preferential rates. If one year or less, it is short-term and taxed as ordinary income. You report it on Schedule D like any other asset.

What if I sold an asset at a loss to avoid taxes — can I buy it back right away?

You can buy it back, but the "wash sale rule" may prevent you from deducting the loss. If you buy the same or substantially identical security within 30 days before or after the sale, the loss is disallowed. The loss is added to the cost basis of the new purchase instead. This rule applies to stocks and mutual funds but not to real estate or cryptocurrency.