Skip to main content

HomeAll guides

How to Calculate Capital Gains Tax on Investments and Property Sales

What capital gains tax is and when you owe it

Capital gains tax is a tax on the profit you make when you sell an investment or property for more than you paid for it. The difference between what you paid (your cost basis) and what you sold it for (your sale price) is your gain, and that gain is what gets taxed. You do not owe tax on the full sale price — only on the profit.

You owe capital gains tax when you sell stocks, bonds, real estate, cryptocurrency, collectibles, or other assets at a profit. The tax applies whether you sell through a broker, a private sale, or any other method. If you sell at a loss, you do not owe tax on that transaction, though you may be able to use the loss to reduce taxes on other gains.

Capital gains tax is separate from income tax. Even if you have no job income, you can owe capital gains tax if you sold investments or property at a profit during the year. The IRS requires you to report these transactions on your tax return, and your broker or the person who bought your property may send you a form documenting the sale.

Key Takeaways

  • Your capital gain is the sale price minus what you originally paid, including any improvements or fees you added to your cost basis.
  • Long-term capital gains (assets held over one year) are taxed at lower rates than short-term gains, which are taxed as ordinary income.
  • You calculate the tax by multiplying your gain by the tax rate that applies to you, which depends on your total income and filing status.
  • Brokers and real estate closing agents report sales to the IRS, so unreported gains can trigger an audit or penalty.
  • Losses on one investment can reduce gains on another, potentially lowering or eliminating your capital gains tax for the year.

How to find your cost basis

Cost basis is what you originally paid for the asset, plus any costs directly tied to buying or improving it. For stocks or mutual funds, this is the purchase price plus any commissions or fees you paid to buy them. For real estate, it includes the purchase price, closing costs, and the cost of major improvements like a new roof or addition — but not routine maintenance like painting or repairs.

If you inherited an asset, your cost basis is usually the value on the date the person died, not what they originally paid. This is called a "step-up in basis" and can significantly reduce or eliminate capital gains tax if you sell soon after inheriting. If you received an asset as a gift, your cost basis is generally what the giver paid, not the gift's value at the time you received it.

Your broker or financial institution should provide a cost basis statement when you sell, especially for stocks and mutual funds. For real estate, your closing documents from the purchase show the purchase price, and you will need to gather receipts for any improvements. Keep these records for at least three years after you file your tax return, since the IRS can audit transactions from prior years.

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

How long you held the asset determines which tax rate applies. Long-term capital gains are profits on assets you owned for more than one year. Short-term capital gains are profits on assets you owned for one year or less. The holding period starts the day after you buy and ends the day you sell.

Short-term capital gains are taxed as ordinary income, using the same tax brackets as your wages or salary. If you are in the 24% tax bracket for income, your short-term gains are also taxed at 24%. Long-term capital gains use lower tax rates: 0%, 15%, or 20%, depending on your total income and filing status. For most people, long-term gains are taxed at 15%. The 0% rate applies to lower-income filers, and the 20% rate applies to high-income filers.

This difference can be substantial. If you sold a stock for a $10,000 gain after holding it for six months, and you are in the 24% bracket, you would owe $2,400 in tax. If you held the same stock for 13 months and are in the 15% long-term rate, you would owe $1,500 — a $900 difference just from waiting a few months.

Calculating your capital gain or loss

The math is straightforward: Sale Price minus Cost Basis equals Capital Gain (or Loss). If the result is positive, you have a gain. If it is negative, you have a loss.

Here is a concrete example. You bought 100 shares of a stock at $50 per share, paying a $10 commission, for a total cost of $5,010. You sold all 100 shares at $75 per share, paying a $15 commission, for a net sale price of $7,485. Your capital gain is $7,485 minus $5,010, which equals $2,475. If you held the stock for more than one year, this is a long-term gain taxed at the long-term rate. If you held it for less than one year, it is a short-term gain taxed as ordinary income.

For real estate, the calculation is the same but the numbers are larger. You bought a house for $300,000 and spent $50,000 on a kitchen renovation and new roof (improvements that add value). Your cost basis is $350,000. You sold it for $425,000, paying $12,000 in realtor commissions and closing costs. Your net sale price is $413,000. Your capital gain is $413,000 minus $350,000, which equals $63,000.

Finding your tax rate based on income and filing status

Your capital gains tax rate depends on your taxable income for the year, not just the gain itself. Taxable income includes wages, interest, dividends, and other income, plus your capital gains. The IRS publishes tax brackets each year that show which rate applies at each income level.

For 2024, the long-term capital gains brackets are roughly: 0% if your taxable income is below $47,025 (single) or $94,050 (married filing jointly), 15% for income between those amounts and $518,900 (single) or $583,750 (married), and 20% for income above those thresholds. These numbers change each year, so check the IRS website or a tax guide for the current year. Short-term gains use the ordinary income brackets, which are higher.

If you have both long-term and short-term gains in the same year, you calculate the tax on each separately. Short-term gains are taxed first at the ordinary income rate, then long-term gains are taxed at the lower rate. This can matter if your income is close to a bracket boundary.

Using capital losses to reduce your tax bill

If you sold an investment at a loss, you can use that loss to reduce capital gains from other sales. If you sold Stock A for a $5,000 gain and Stock B for a $2,000 loss in the same year, your net capital gain is $3,000, and you owe tax only on that $3,000.

If your losses exceed your gains in a year, you can deduct up to $3,000 of the excess loss against your ordinary income (wages, salary, interest, and other income). Any loss beyond $3,000 carries forward to future years, so you can use it to reduce gains or income in later tax years. This carryforward has no time limit — you can use it decades later if needed.

This strategy, called tax-loss harvesting, is common among investors who want to reduce their tax bill. You sell a losing position to lock in the loss, then may buy a similar investment to maintain your portfolio. The IRS has a "wash sale" rule that prevents you from buying the same or substantially identical security within 30 days before or after the sale, so timing matters if you want to use this approach.

What forms and records you need

When you sell stocks or mutual funds through a broker, the broker sends you a Form 1099-B showing the sale price and, usually, the cost basis. When you sell real estate, the closing agent sends you a Form 1099-S showing the sale price. You use these forms to fill out Schedule D (Capital Gains and Losses) on your tax return, which calculates your total gain or loss and the tax owed.

Keep your own records of cost basis, holding period, and sale details. For stocks, this means your purchase confirmations and sale confirmations. For real estate, keep your deed, closing statement, and receipts for improvements. If the broker's cost basis is wrong — which can happen with inherited accounts or reinvested dividends — you may need to correct it on your tax return with a written explanation.

If you sold cryptocurrency, collectibles, or other assets not reported on a 1099 form, you still owe tax and must report it yourself on Schedule D. The IRS has been increasing enforcement on unreported cryptocurrency sales, so reporting these transactions is important even if you did not receive a form.

Frequently Asked Questions

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

No, you do not owe tax on a loss. Instead, you can use the loss to reduce capital gains from other sales or up to $3,000 of your ordinary income in the same year. Any unused loss carries forward to future years.

What if I do not know my original purchase price?

Contact your broker or the financial institution where you held the asset — they may have records going back several years. For older transactions, you may need to estimate based on historical price data or statements you kept. If you genuinely cannot find the cost basis, the IRS allows you to use the sale price as your basis, resulting in zero gain, but this is a last resort and may trigger questions if audited.

How do I report capital gains on my tax return?

Use Schedule D (Form 1040) to list each sale, the sale price, cost basis, and gain or loss. The form calculates your total long-term and short-term gains, and you transfer the result to your main tax return. If you use tax software, it usually walks you through this process and pulls data from your 1099 forms automatically.

Can I avoid 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 fair market value of the asset as a charitable contribution. You must own the asset for more than one year for this to work. This is often more tax-efficient than selling and donating the proceeds.

Do I owe capital gains tax on a primary residence sale?

Most homeowners do not. The IRS allows you to exclude up to $250,000 of gain (or $500,000 if married filing jointly) on the sale of a primary residence if you owned and lived in it for at least two of the five years before the sale. Gains above that threshold are taxed as long-term capital gains. Investment properties and second homes do not may have access to for this exclusion.

This guide is for general information only and is not medical, financial, legal, or other professional advice. For decisions specific to your situation, consult a qualified professional. See our Editorial Policy.