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

Capital gains tax is calculated on the profit you make when you sell an asset — a stock, rental property, cryptocurrency, or mutual fund. The profit itself is called your capital gain, and it's the difference between what you sold it for and what you paid for it (plus any costs of the sale, like broker fees).

The formula is straightforward: take your sale price, subtract your original purchase price and any selling costs, and you have your gain. Then multiply that gain by your tax rate. Your tax rate depends on how long you held the asset and how much total income you earned that year.

The IRS taxes short-term gains (assets held one year or less) as ordinary income — the same rate as your salary or wages. Long-term gains (held over one year) get preferential rates: 0%, 15%, or 20% for most people, depending on your total income. This is where the real tax savings happen.

Key Takeaways

  • Your capital gain is the sale price minus what you paid, minus selling costs like broker fees or realtor commissions.
  • Short-term gains are taxed at your ordinary income rate; long-term gains are taxed at 0%, 15%, or 20% depending on your income bracket.
  • Holding an asset for more than one year before selling it usually cuts your tax bill significantly.
  • You report gains on Schedule D (Form 1040) and may owe tax even if you don't receive a 1099 form from your broker.
  • Losses can offset gains dollar-for-dollar, and unused losses can carry forward to future years.

The difference between short-term and long-term holding periods

The IRS draws a hard line at one year. If you sell an asset you've owned for 12 months or less, any profit is a short-term capital gain and is taxed as ordinary income — at your regular tax bracket, which could be 10%, 12%, 22%, 24%, 32%, 35%, or 37% depending on your income.

If you hold the asset for more than one year before selling, the profit becomes a long-term capital gain. Long-term rates are much lower: 0% (if your income is below a certain threshold), 15% (for most people), or 20% (for high earners). For 2024, the 15% rate applies to single filers with income between roughly $47,000 and $518,000; the 20% rate kicks in above that.

The holding period is measured from the date you bought the asset to the date you sold it. If you bought stock on March 15, 2023, and sold it on March 15, 2024, it qualifies as long-term. If you sold it on March 14, 2024, it's short-term. This one-day difference can mean thousands of dollars in tax.

How to find your cost basis and calculate the actual gain

Cost basis is what you paid for the asset, plus any fees or commissions you paid to buy it. If you bought 100 shares of stock at $50 per share and paid a $10 broker fee, your cost basis is $5,010 (not $5,000). This matters because a higher cost basis means a lower taxable gain.

Your broker should provide a cost basis report when you sell, especially for stocks and mutual funds. For real estate, your basis includes the purchase price plus the cost of improvements (a new roof, kitchen renovation), but not routine maintenance (painting, repairs). For inherited assets, your basis is typically "stepped up" to the fair market value on the date of death, which can eliminate tax on gains that occurred before you inherited it.

Once you know your cost basis, subtract it from the sale price. Then subtract any costs of selling — realtor commission (typically 5–6% for real estate), broker fees, or title transfer costs. What's left is your taxable gain. If the sale price is lower than your cost basis, you have a capital loss instead, which can offset other gains.

When you owe tax on gains you haven't received yet

You owe capital gains tax in the year you sell the asset, even if you don't receive the money when ready. If you sell a rental property in December 2024 but the buyer doesn't close until February 2025, you still report the gain on your 2024 tax return (the year of the sale, not the year you get paid).

This matters for installment sales, where the buyer pays you over time. You report the gain in the year of sale, but you can spread the tax liability across the years you receive payments using the installment method. This requires filing Form 6252 with your return.

It also matters if you sell through a 1031 exchange (a like-kind property swap for real estate). You defer the tax, but you don't eliminate it — you'll owe it when you eventually sell the replacement property for cash.

How to report capital gains on your tax return

You report capital gains on Schedule D (Form 1040), which lists each sale separately. Part I is for short-term gains; Part II is for long-term gains. You'll need the date acquired, date sold, sales price, cost basis, and gain or loss for each transaction.

Your broker sends you a Form 1099-B (for stocks, mutual funds, and options) or Form 1099-S (for real estate) showing the sale price. The form may or may not include your cost basis — it depends on the broker and the asset type. You are responsible for providing the correct basis, even if the broker doesn't report it.

After you complete Schedule D, you transfer the totals to your Form 1040. If you have net long-term gains, they go to a separate line that applies the preferential tax rates. If you have net short-term gains, they're added to your ordinary income. If you have losses, they can offset gains, and up to $3,000 of unused losses can offset other income in that year; any excess carries forward to future years.

Using losses to reduce your tax bill

Tax-loss harvesting is the practice of selling an investment at a loss to offset gains elsewhere. If you sold one stock for a $5,000 gain and another for a $2,000 loss, your net gain is $3,000, and you pay tax only on that amount. This is a real strategy, not a loophole.

The IRS has one restriction: the wash-sale rule. If you sell a security at a loss, you cannot buy the same security (or a substantially identical one) within 30 days before or after the sale. If you do, the loss is disallowed and added to the basis of the new purchase instead. This rule applies to stocks and mutual funds but not to real estate or other assets.

Capital losses can offset capital gains dollar-for-dollar. If your losses exceed your gains, you can deduct up to $3,000 of the excess against your ordinary income (wages, interest, etc.) in that year. Any remaining loss carries forward indefinitely to future years, where it can offset future gains or income.

Special situations: inherited assets, gifts, and employee stock options

When you inherit an asset, your cost basis is "stepped up" to its fair market value on the date of the owner's death. If your parent bought stock for $10,000 and it was worth $50,000 when they died, your basis is $50,000. If you sell it the next day for $50,000, you owe no tax. This step-up is one of the largest tax breaks in the code.

If you receive an asset as a gift, your basis is generally the donor's basis (what they paid), not the value when you received it. If the gift has declined in value, you use the lower of the donor's basis or the fair market value on the date of the gift. This rule prevents you from using gifts to harvest losses.

Employee stock options are taxed differently depending on the type. Incentive stock options (ISOs) can may have access to for long-term treatment if you hold the stock for at least two years from grant and one year from exercise. Non-may have access to options (NSOs) are taxed as ordinary income at exercise, and any gain from exercise to sale is a capital gain. Restricted stock units (RSUs) are taxed as ordinary income when they vest, and gains from vesting to sale are capital gains.

Frequently Asked Questions

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

No, you don't owe tax on a loss. Instead, you can use the loss to offset capital gains from other sales. If losses exceed gains, you can deduct up to $3,000 against your ordinary income, and carry the rest forward to future years.

What if my broker didn't send me a 1099 form?

You still owe tax on the gain and must report it on Schedule D. Brokers are required to send 1099-B forms for stocks and mutual funds, but if you didn't receive one, contact the broker. For real estate, the seller's agent or title company sends Form 1099-S. You are responsible for reporting the transaction regardless of whether you receive a form.

Can I avoid capital gains tax by donating the asset to charity?

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 as a charitable contribution. This is often more valuable than selling and donating the proceeds, because you get the deduction and avoid the tax.

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

Count the days from the date you bought the asset to the date you sold it. If it's more than one year, it's long-term. The IRS counts the purchase date as day zero, so if you bought on January 1, 2023, and sold on January 2, 2024, it qualifies as long-term (more than 365 days).

What happens to capital gains if I die before selling?

Your heirs inherit the asset with a stepped-up basis equal to its fair market value on your date of death. They owe no tax on the gains that occurred during your lifetime. This is why holding appreciated assets until death can be a tax strategy, though it should never be the only reason to hold or sell an investment.