The basic formula for capital gains tax

Capital gains tax is calculated by subtracting what you paid for an asset from what you sold it for, then explore your tax rate to that profit. The IRS calls the amount you paid the cost basis. The difference between your sale price and cost basis is your capital gain. You only pay tax on the gain, not on the full sale price.

The formula is straightforward: Sale Price minus Cost Basis equals Capital Gain. Then multiply your capital gain by your tax rate. Your tax rate depends on how long you held the asset — short-term gains (held one year or less) use your ordinary income tax rate, while long-term gains (held more than one year) use lower rates set by the IRS, which vary by income level.

You report capital gains on Schedule D (Form 1040), which is the IRS form for reporting investment income. If you sold stocks, real estate, collectibles, or other property during the year, you will need this form and the supporting documents from your sale.

Key Takeaways

  • Capital gain equals the sale price minus what you originally paid (cost basis), and you only pay tax on that gain amount.
  • Short-term capital gains (assets held one year or less) are taxed at your ordinary income tax rate, which can be as high as 37 percent depending on your income.
  • Long-term capital gains (assets held more than one year) are taxed at preferential rates of 0, 15, or 20 percent, depending on your total income for the year.
  • You must report all capital gains on Schedule D and attach it to your Form 1040, even if you had a loss.
  • Your broker or the person who bought your asset will send you a Form 1099-B or similar document showing the sale price, which you use to verify your gain calculation.

Gathering the documents you need

Before you calculate anything, collect the paperwork that shows what you paid and what you sold the asset for. Your broker or financial institution will send you a Form 1099-B (Proceeds from Broker and Barter Exchange Transactions) if you sold stocks, bonds, or mutual funds. For real estate sales, you will receive a Form 1099-S (Proceeds from Real Estate Transactions) from the title company or real estate agent.

You also need documentation of your original purchase. This might be a brokerage statement, a receipt, a deed, or a closing statement from when you bought the property. If you inherited the asset or received it as a gift, the rules for cost basis are different — you may need to establish the value on the date you received it rather than the original purchase price.

Keep records of any improvements you made to the asset. If you sold a house, the cost of a new roof, addition, or major renovation can be added to your cost basis, which lowers your taxable gain. Repairs and maintenance do not count — only improvements that add value or extend the life of the asset.

Calculating cost basis for stocks and mutual funds

For stocks and mutual funds, cost basis is usually straightforward: the price you paid per share times the number of shares you sold, plus any commissions or fees you paid to buy them. If you bought 100 shares at $50 per share and paid a $10 commission, your cost basis is $5,010.

If you bought the same stock at different times and prices, you need to track which shares you sold. The IRS allows several methods: specific identification (you choose which shares to sell), first-in-first-out (FIFO, the oldest shares are sold first), or average cost (you use the average price of all shares you own). Your brokerage statement will show which method your account uses by default, but you can request a different method if you notify your broker in writing before the sale.

If you received dividends and reinvested them, those reinvested amounts are part of your cost basis. Your broker's records will show this. If you sold mutual funds, the same rules explore — track the price per share when you bought and when you sold, and account for any reinvested distributions.

Calculating cost basis for real estate

For a house or other real property, cost basis starts with the purchase price shown on your closing statement. Add the cost of any capital improvements: a new roof, an addition, a new heating system, or a deck. Do not include routine maintenance like painting, repairs, or lawn care.

If you inherited the property, your cost basis is usually the fair market value on the date the previous owner died, not what they originally paid. This is called a step-up in basis and can significantly reduce your taxable gain. If you received the property as a gift, your cost basis is generally what the giver paid, unless the property had declined in value at the time of the gift.

If you sold your primary residence, you may be able to exclude up to $250,000 of gain (or $500,000 if married filing jointly) if you owned and lived in the home for at least two of the five years before the sale. This exclusion is not a deduction — it means you do not report that portion of the gain at all. You still report the sale on Schedule D, but you enter the excluded amount in the appropriate column.

Determining holding period and tax rate

The date you bought the asset and the date you sold it determine your holding period. Count the days between purchase and sale. If you held the asset for one year or less, it is a short-term capital gain. If you held it for more than one year, it is a long-term capital gain.

Short-term capital gains are taxed at your ordinary income tax rate — the same rate that applies to wages and salary. This rate ranges from 10 percent to 37 percent depending on your total income and filing status. Long-term capital gains have preferential rates: 0 percent, 15 percent, or 20 percent, also depending on your total income and filing status.

The IRS publishes the income thresholds for each rate each year. For 2024, for example, the 0 percent long-term rate applies to single filers with taxable income up to $47,025, the 15 percent rate applies to income between $47,025 and $518,900, and the 20 percent rate applies to income above that. These thresholds change annually. Check the IRS website or your tax software for the current year's thresholds.

Working through a calculation example

Suppose you bought 50 shares of a stock at $40 per share in March 2022 and sold them in July 2024 for $60 per share. Your cost basis is 50 × $40 = $2,000. Your sale proceeds are 50 × $60 = $3,000. Your capital gain is $3,000 − $2,000 = $1,000.

You held the stock for more than one year, so this is a long-term capital gain. If your total taxable income for 2024 places you in the 15 percent long-term capital gains bracket, your tax on this gain is $1,000 × 0.15 = $150. If you were in the 20 percent bracket, it would be $200. If you were in the 0 percent bracket, you would owe no federal tax on this gain.

Now suppose you bought a rental property for $300,000 in 2015, made $50,000 in capital improvements, and sold it in 2024 for $500,000. Your cost basis is $300,000 + $50,000 = $350,000. Your capital gain is $500,000 − $350,000 = $150,000. If this is a long-term gain and you are in the 15 percent bracket, your tax is $150,000 × 0.15 = $22,500.

Reporting capital gains on your tax return

You report capital gains on Schedule D (Form 1040). Part I of Schedule D is for short-term capital gains and losses. Part II is for long-term capital gains and losses. List each sale separately: the date acquired, date sold, sales price, cost basis, and gain or loss.

At the bottom of Schedule D, you calculate your net short-term gain or loss and your net long-term gain or loss. If you have both gains and losses, you net them within each category first. If you have a net loss in one category and a net gain in the other, you can use losses to offset gains.

If your net capital loss exceeds your net capital gain, you can deduct up to $3,000 of the loss against your ordinary income in that year. Any loss above $3,000 carries forward to future years. Attach Schedule D to your Form 1040 and include the net gain or loss on the appropriate line of your return.

Special situations and adjustments

If you sold an asset at a loss, you still report it on Schedule D. Capital losses offset capital gains dollar-for-dollar. If you have more losses than gains in a year, you can use the excess to reduce your ordinary income, up to $3,000 per year. Unused losses roll forward indefinitely.

If you sold a collectible — art, coins, stamps, or similar items — the long-term capital gains rate is 28 percent, not the standard 0, 15, or 20 percent. Collectibles are treated differently because they are considered personal property with special tax rules.

If you received stock options or restricted stock units as compensation, the cost basis and holding period depend on when you exercised the option or when the shares vested, not when you received the grant. Consult your grant documents and any Form 3921 or Form 3922 your employer provided.

Frequently Asked Questions

Do I have to report a capital gain if I reinvested the money?

Yes. The IRS taxes the gain when you sell the asset, regardless of what you do with the proceeds. Whether you spend the money, reinvest it, or leave it in a bank account does not change the tax you owe on the gain. You report the gain in the year of the sale.

What if I sold an asset at a loss — do I still file Schedule D?

Yes. You report losses on Schedule D so you can use them to offset gains or reduce your ordinary income. Even if you have no gains, filing Schedule D with your losses allows you to claim the deduction. Keep your documentation of the loss in case the IRS asks.

Can I use the cost basis my broker shows on Form 1099-B?

Your broker's Form 1099-B shows the sale price, but the cost basis may not be accurate if you bought shares at different times, reinvested dividends, or transferred shares from another account. Verify the cost basis against your own records before you file. If the broker's figure is wrong, use your records and keep documentation.

How do I handle a sale if I do not know what I originally paid?

If you have no records of the purchase price, you may be able to reconstruct it from old brokerage statements, bank records, or tax returns. If you truly cannot find the cost basis, the IRS may allow you to use the fair market value on the date you received the asset as your basis, but you will need to document your efforts to find the original cost. Consult a tax professional if this applies to you.

Does the net investment income tax explore to my capital gains?

If your modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly), you may owe an additional 3.8 percent net investment income tax on your capital gains. This tax is reported on Form 8960 and attached to your Form 1040. Your tax software will calculate this if you may have access to.