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

Capital gains tax is calculated by taking the amount you sold an asset for, subtracting what you originally paid for it (plus any improvements you made), and then explore your tax rate to that difference. That difference is your capital gain. The IRS taxes it differently depending on how long you held the asset and how much money you made that year.

The calculation itself is straightforward arithmetic. The complexity comes from figuring out which tax rate applies to you, because the rate depends on your total income for the year, not just the gain itself. A $10,000 gain might be taxed at 0%, 15%, or 20% depending on your other income and filing status.

Key Takeaways

  • Your capital gain equals the sale price minus your original cost basis, and cost basis includes the purchase price plus any capital improvements you made to the asset.
  • Long-term capital gains (assets held over one year) are taxed at 0%, 15%, or 20% depending on your total income and filing status; short-term gains are taxed as ordinary income.
  • Your tax bracket for capital gains is determined by your total taxable income for the year, including wages, interest, and other gains, not by the gain alone.
  • The IRS requires you to report capital gains on Schedule D (Form 1040), and you must track your purchase date and original cost for every asset you sell.

Cost basis: what you actually paid, not what you think you paid

Before you can calculate a gain, you need to know your cost basis. This is the amount the IRS considers your starting point for the asset. For most purchases, cost basis is straightforward what you paid for it. If you bought 100 shares of stock for $5,000, your cost basis is $5,000.

Cost basis also includes certain expenses tied directly to the purchase. If you paid a broker's commission, that gets added to your cost basis. If you bought a rental property and paid for a home inspection or title search, those costs are part of your basis. The goal is to capture the true amount you invested to acquire the asset.

For real estate, cost basis can grow over time through capital improvements. If you owned a house and spent $20,000 on a new roof or $15,000 on a kitchen renovation, those amounts increase your cost basis. Routine maintenance and repairs do not — only improvements that add value or extend the life of the property. When you sell, you subtract your total cost basis (original purchase price plus improvements) from the sale price.

If you inherited an asset, your cost basis is usually the asset's fair market value on the date the person died, not what they originally paid. This is called a step-up in basis, and it can significantly reduce any gain you owe tax on if you sell soon after inheriting.

Long-term versus short-term: the holding period matters

The IRS taxes capital gains at different rates depending on how long you owned the asset. 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 capital gains are taxed as ordinary income, at the same rates as wages or salary. Those rates range from 10% to 37% depending on your total income and filing status. Long-term capital gains are taxed at preferential rates: 0%, 15%, or 20%, which are much lower for most people.

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

How your tax bracket determines your capital gains rate

Your capital gains tax rate is not based on the size of the gain alone — it is based on your total taxable income for the year. The IRS stacks capital gains on top of your other income (wages, interest, dividends) to determine which rate applies.

For 2024, the long-term capital gains brackets are:

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 change each year. The brackets shown are for 2024 and will be different for 2025 and beyond.

Here is how stacking works in practice: suppose you are single, earned $40,000 in wages, and sold stock for a $20,000 long-term gain. Your total taxable income is $60,000. The first $7,025 of your gain ($47,025 minus $40,000) is taxed at 0%. The remaining $12,975 is taxed at 15%. You owe $1,946 in capital gains tax on the $20,000 gain, not $3,000 (which would be 15% of the whole amount).

Reporting capital gains on your tax return

You report capital gains on Schedule D (Form 1040), which is part of your federal income tax return. Schedule D has two sections: one for long-term gains and one for short-term gains. You list each sale separately, showing the date acquired, date sold, sales price, and cost basis.

If you sold only one or two assets and the gains are small, you may be able to report them directly on Form 1040 without filing Schedule D, but most people with any significant trading activity need Schedule D. Your brokerage or investment company will send you a Form 1099-B (Proceeds from Broker and Barter Exchange Transactions) that shows your sales. Use this to fill out Schedule D accurately.

Schedule D also handles capital losses. If you sold an asset for less than you paid, you have a capital loss. You can use losses to offset gains dollar-for-dollar. If your losses exceed your gains in a year, you can deduct up to $3,000 of the excess loss against ordinary income (like wages). Any remaining loss carries forward to future years.

State and local taxes on capital gains

Federal capital gains tax is only part of the picture. Most states also tax capital gains, usually at the same rate as ordinary income. A few states (like Washington and Tennessee) tax capital gains at a flat rate on high earners. Some states (like Florida and Texas) do not tax capital gains at all.

Your state's rate can significantly change your total tax bill. If you live in California and have a large long-term gain, you will owe 15% federal tax plus California's state income tax (which ranges up to 13.3%), for a combined rate much higher than the federal rate alone.

Common mistakes in calculating capital gains

The most frequent error is using the wrong cost basis. Many people forget to include broker commissions, closing costs, or capital improvements. They also sometimes confuse the original purchase price with the current market value. Your cost basis is always what you actually paid to acquire and improve the asset, not what it is worth today.

Another common mistake is misidentifying the holding period. The day you buy does not count; the holding period starts the day after. Similarly, the day you sell does count. If you are close to the one-year mark, verify the exact dates before filing.

People also sometimes forget that they owe capital gains tax even if they did not receive cash. If you sold an asset and took a promissory note or other payment over time, you still owe tax on the gain in the year of sale, not when you receive the money. And if you received stock as compensation or inherited it, you need to know the fair market value on the date you received it to calculate your basis correctly.

Frequently Asked Questions

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

No tax is owed on the loss itself. Instead, you can use the loss to reduce any capital gains you had that year. If losses exceed gains, you can deduct up to $3,000 against other income like wages. Any loss beyond that carries forward to future tax years.

What if I do not know my original cost basis?

Contact your brokerage or the company that sold you the asset — they often have records going back many years. If records are truly unavailable, the IRS allows you to use a reasonable estimate, but you should document your effort to find the actual amount. For inherited assets, use the fair market value on the date of death.

How do I know if my gain is long-term or short-term?

Count the days from the day after you bought to the day you sold. If it is more than 365 days, it is long-term. Your brokerage statement usually shows the holding period, but verify it yourself because the tax consequences are large — short-term gains are taxed as ordinary income, while long-term gains get preferential rates.

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

Yes. If you donate an appreciated asset directly to a may have access to charity, you avoid the capital gains tax entirely and can deduct the fair market value of the asset as a charitable contribution. You must own it for more than one year for this to work. This strategy is often more valuable than selling and donating the proceeds.

Do I owe capital gains tax on my primary home when I sell?

Most homeowners do not. The IRS allows you to exclude up to $250,000 of gain if you are single, or $500,000 if you are married filing jointly, as long as you owned and lived in the home for at least two of the five years before the sale. Gains beyond that threshold are taxable.