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

Capital gains tax is calculated by taking the amount you sold something for, subtracting what you originally paid for it (plus any improvements you made), and then applying the tax rate that matches your income and how long you held the asset. If you bought stock for $5,000 and sold it for $8,000, your gain is $3,000. That $3,000 is what gets taxed, not the full $8,000 sale price.

The tax rate itself depends on two things: your total income for the year and whether you held the asset for more than one year (long-term) or one year or less (short-term). Long-term gains are taxed at lower rates — 0%, 15%, or 20% depending on your income bracket. Short-term gains are taxed as ordinary income, which means they use the same rates as wages or salary, and those rates go up to 37% at the highest bracket.

You report capital gains on Schedule D of your federal tax return (Form 1040). State taxes may also apply, and some states tax capital gains differently than the federal government does. The calculation itself is straightforward arithmetic, but the rate you use depends on your filing status, total income, and how long you owned the asset.

Key Takeaways

  • Gain equals sale price minus your original cost basis (what you paid plus improvements), and only the gain is taxed, not the full sale price.
  • Long-term gains (held over one year) are taxed at 0%, 15%, or 20% depending on your income; short-term gains use ordinary income tax rates up to 37%.
  • Your tax bracket for capital gains is determined by your total income for the year and your filing status, not by the size of the gain alone.
  • You report gains on Schedule D (Form 1040) for federal taxes, and most states also tax capital gains, though some states have different rules.
  • Losses can offset gains dollar-for-dollar, and unused losses can carry forward to future years up to $3,000 per year against ordinary income.

Cost basis: what counts as your original investment

Cost basis is the starting number for your calculation. It is not just the price you paid — it includes commissions, fees, and the cost of improvements. If you bought a rental house for $200,000 and spent $50,000 on a new roof and foundation repair, your basis is $250,000. If you later sell that house for $350,000, your gain is $100,000, not $150,000.

For stocks and mutual funds, basis includes the purchase price plus any brokerage fees or commissions you paid to buy them. If you inherited an asset, your basis is usually the market value on the date the person died, not what they originally paid. This is called a "stepped-up basis" and can significantly reduce or eliminate the gain you owe tax on.

Keeping records of your basis is essential. Save purchase confirmations, receipts for improvements, and statements showing any fees. If you cannot prove your basis, the IRS may treat your entire sale price as gain, which would result in much higher taxes.

Long-term versus short-term: how holding time changes your rate

An asset is long-term if you held it for more than one year before selling. Long-term capital gains receive preferential tax rates: 0%, 15%, or 20% depending on your income. An asset is short-term if you held it for one year or less. Short-term gains are taxed as ordinary income, using the same brackets as wages — 10%, 12%, 22%, 24%, 32%, 35%, or 37%.

The holding period starts the day after you buy and ends the day you sell. If you bought stock on March 15, 2023, and sold it on March 15, 2024, that is exactly one year, which means it qualifies as long-term. If you sold on March 14, 2024, it would be short-term.

For most people, the difference between long-term and short-term rates is substantial. A $10,000 short-term gain taxed at 24% costs $2,400. The same $10,000 long-term gain taxed at 15% costs $1,500. Timing a sale to cross the one-year threshold can save thousands in taxes.

Tax brackets for long-term gains in 2024

Long-term capital gains are taxed at three rates: 0%, 15%, or 20%. Which rate applies depends on your taxable income and filing status. The brackets shift slightly each year for inflation.

Tax RateSingle FilersMarried Filing JointlyHead of Household
0%Up to $47,025Up to $94,050Up to $62,975
15%$47,025 to $518,900$94,050 to $583,750$62,975 to $551,350
20%Over $518,900Over $583,750Over $551,350

These brackets are based on your total taxable income for the year, not just the capital gain. If you are single and earn $40,000 in wages, plus $20,000 in long-term gains, your total taxable income is $60,000. The first $7,025 of your gain falls in the 0% bracket, and the remaining $12,975 falls in the 15% bracket. You would owe $1,946 in federal capital gains tax on that $20,000 gain.

The brackets change each year, so check the current year's IRS tables before calculating. The IRS publishes updated brackets in late 2023 for the following year.

How to handle multiple gains and losses in the same year

If you sold multiple assets in the same year, you combine all long-term gains and losses, then combine all short-term gains and losses separately. Long-term gains and losses net against each other first. Short-term gains and losses net against each other. Then, if one category has a net loss, it can offset gains in the other category.

Suppose you sold Stock A for a $5,000 long-term gain and Stock B for a $2,000 long-term loss. Your net long-term gain is $3,000. You also sold Stock C for a $1,500 short-term gain. Your total capital gain for the year is $4,500 ($3,000 long-term plus $1,500 short-term), and you report both amounts on Schedule D.

If your losses exceed your gains, you can deduct up to $3,000 of the net loss against your ordinary income (wages, salary, interest) in that year. Any loss above $3,000 carries forward to the next year, where you can use another $3,000 against ordinary income, and so on until the loss is exhausted. This is called loss carryforward.

State taxes on capital gains

Most states tax capital gains as part of ordinary income, meaning they apply your state income tax rate to the gain. A few states — including Washington, Tennessee, and Florida — do not tax capital gains at all. A handful of others, like California and New York, tax capital gains at the same rate as wages.

Some states have recently introduced separate capital gains taxes. Washington State, for example, taxes long-term gains on the sale of stocks and certain other assets at a flat 7% rate, separate from income tax. Illinois taxes capital gains at a flat 4.5%. These state taxes are in addition to federal tax, so you may owe both.

Check your state's tax authority website or speak with a tax preparer to understand how your state treats capital gains. State taxes can add 5% to 13% or more to your federal bill, depending on where you live.

Special situations: real estate, inherited assets, and gifts

Real estate sales follow the same calculation as stocks, but with additional complexity. If you sell a home you lived in, you may be able to exclude up to $250,000 of gain (or $500,000 if married filing jointly) if you meet the ownership and use tests. You must have owned the home and lived in it as your primary residence for at least two of the last five years before the sale.

Inherited assets receive a stepped-up basis, meaning your cost basis becomes the fair market value on the date of death, not what the deceased person paid. If someone bought a stock for $10,000 and it was worth $50,000 when they died, your basis is $50,000. If you sell it immediately for $50,000, you owe no capital gains tax. This rule applies to most inherited property, including real estate, stocks, and bonds.

Gifts do not receive a stepped-up basis. If someone gives you stock they bought for $10,000 that is now worth $50,000, your basis is $10,000. If you sell it for $50,000, you owe tax on the $40,000 gain. The person who gave you the gift may also owe gift tax if the value exceeds annual limits, though this is separate from your capital gains calculation.

Frequently Asked Questions

Do I owe capital gains tax if I sold at a loss?

No. If you sold an asset for less than you paid for it, you have a loss, not a gain. You can use that loss to offset gains from other sales, or deduct up to $3,000 per year against your ordinary income. Any unused loss carries forward to future years.

What if I do not know my original cost basis?

Contact your broker or the financial institution that held the asset — they may have records going back several years. If you cannot find documentation, the IRS may treat your entire sale price as gain. For inherited assets, you can use a professional appraiser to establish the value on the date of death.

How do I report capital gains on my tax return?

Use Schedule D (Form 1040) to report all capital gains and losses. List each transaction separately, showing the date acquired, date sold, sale price, cost basis, and gain or loss. Then transfer the totals to your main Form 1040. If you use tax software, it usually walks you through this step by step.

Can I reduce my capital gains tax by donating the asset to charity instead of selling it?

Yes. If you donate appreciated stock or real estate directly to a may have access to charity, you avoid the capital gains tax entirely and can deduct the full fair market value as a charitable contribution. You must own the asset for more than one year for this to work. Consult a tax professional to structure the donation correctly.

Are cryptocurrency and NFT sales taxed the same way as stocks?

Yes. The IRS treats cryptocurrency, NFTs, and other digital assets as property. When you sell them, you calculate gain or loss the same way: sale price minus cost basis. Holding for more than one year qualifies for long-term rates. Keep detailed records of purchase dates, amounts, and fees, as the IRS has been increasing scrutiny of crypto transactions.