The basic formula: sale price minus what you paid, then explore your tax rate
Capital gains tax is calculated on the profit you make when you sell an asset — a stock, rental property, cryptocurrency, or other investment. The profit itself is called your capital gain, and it's the difference between what you sold it for and what you originally paid for it, plus any costs tied directly to the sale.
The calculation looks like this: Sale Price − Original Cost Basis − Selling Costs = Capital Gain. Then you explore either the short-term capital gains rate (your ordinary income tax rate) or the long-term capital gains rate (0%, 15%, or 20%, depending on your income) to that gain.
The tax rate you pay depends on two things: how long you held the asset before selling it, and your total taxable income for the year. An asset held for one year or less is taxed as a short-term gain. An asset held for more than one year is taxed as a long-term gain at a preferential rate.
Key Takeaways
- Your capital gain is the sale price minus your original purchase price, adjusted for any selling costs like broker fees or commissions.
- Short-term gains (assets held one year or less) are taxed at your ordinary income tax rate, which can be as high as 37%.
- Long-term gains (assets held more than one year) are taxed at 0%, 15%, or 20% depending on your filing status and total income for the year.
- You report capital gains on Schedule D (Form 1040) and may owe estimated taxes if the gain is large and you did not have enough tax withheld during the year.
What counts as your cost basis and what does not
Your cost basis is what you paid for the asset, but it includes more than just the purchase price. If you bought stock through a broker, your basis includes the commission you paid. If you inherited property, your basis is typically its fair market value on the date of death, not what the original owner paid. If you received stock as compensation, your basis is the fair market value on the day you received it.
Cost basis also includes improvements you made to an asset. If you bought a rental house for $200,000 and spent $50,000 on a new roof and foundation repairs, your basis is $250,000. But routine maintenance — painting, landscaping, fixing a broken window — does not increase basis.
Some assets have special basis rules. If you sell a mutual fund and reinvested the dividends, each dividend reinvestment has its own basis date and amount. If you sold only part of your holdings, you can choose which shares you're selling (average cost method, specific identification, or first-in-first-out) to minimize your gain — but you must tell your broker which method you're using before the sale.
How holding period changes your tax rate
The date you bought the asset and the date you sold it determine whether your gain is short-term or long-term. If you held the asset for one year or less, it's short-term. If you held it for more than one year, it's long-term. The holding period starts the day after you buy and ends on the day you sell.
Short-term capital gains are taxed as ordinary income. Your rate depends on your tax bracket for the year — it could be 10%, 12%, 22%, 24%, 32%, 35%, or 37%. This is the same rate you pay on wages and salary.
Long-term capital gains have their own tax brackets, separate from ordinary income. For 2024, the rates are 0%, 15%, or 20%. Which rate you pay depends on your filing status and your total taxable income, including the capital gain itself. A single filer with taxable income up to $47,025 pays 0%. Income from $47,026 to $518,900 is taxed at 15%. Income above $518,900 is taxed at 20%. These thresholds change each year.
Calculating gain when you sell part of what you own
If you own 100 shares of a stock and sell 30 of them, you need to know the cost basis of those 30 shares specifically. If you bought them at different times or prices, you have options for which shares you're selling.
The specific identification method lets you choose exactly which shares to sell — for example, the 30 shares you bought most recently, or the 30 with the lowest cost basis. You must tell your broker in writing which shares you want to sell before the transaction settles. This method gives you the most control over your tax outcome.
If you don't specify, most brokers use first-in-first-out (FIFO), which means the oldest shares are sold first. This often creates a larger gain because older shares typically have a lower cost basis. The average cost method
Losses that reduce or eliminate your tax bill
If you sell an asset for less than you paid for it, you have a capital loss. You can use capital losses to offset capital gains. 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). Any loss beyond $3,000 carries forward to future years with no time limit.
Capital losses must be matched by type: long-term losses offset long-term gains first, and short-term losses offset short-term gains first. Only after you've used up losses of the same type can you use one type to offset the other.
Some investors use tax-loss harvesting — selling a losing investment specifically to create a loss that offsets gains elsewhere. However, the IRS has a wash-sale rule: if you sell a security at a loss and buy the same or a substantially identical security within 30 days before or after the sale, 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 bonds or other securities.
Where you report capital gains on your tax return
You report all capital gains and losses on Schedule D (Form 1040), which is part of your federal income tax return. Part I of Schedule D is for short-term gains and losses. Part II is for long-term gains and losses. You list each transaction separately — the asset, the date acquired, the date sold, the sale price, the cost basis, and the gain or loss.
After you complete Schedule D, the net result (total gains minus total losses) transfers to line 7 of Form 1040. If you have a net long-term capital gain, you may also need to fill out Form 8949 (Sales of Capital Assets) first, depending on how many transactions you have and whether your broker reported them to the IRS on Form 1099-B.
If you have a large capital gain and did not have enough tax withheld from paychecks or other income during the year, you may owe estimated taxes. Estimated tax payments are due on April 15, June 17, September 16, and January 15 of the following year. If you don't pay estimated taxes and owe more than $1,000 when you file, you may owe a penalty.
Special situations: inherited assets, gifts, and like-kind exchanges
When you inherit an asset, your cost basis is its fair market value on the date of the owner's death (or six months later if the estate chooses the alternate valuation date). This is called a step-up in basis. If the original owner bought stock for $10,000 and it was worth $50,000 when they died, your basis is $50,000. If you sell it when ready for $50,000, you have no gain and owe no tax. This applies to all inherited assets — stocks, real estate, cryptocurrency, art.
If someone gives you an asset as a gift, your cost basis is generally the donor's cost basis, not the fair market value at the time of the gift. If your parent bought stock for $5,000, it's now worth $20,000, and they give it to you, your basis is $5,000. If you sell it for $20,000, you owe tax on a $15,000 gain. The only exception is if the asset has declined in value: your basis for calculating a loss is the fair market value on the date of the gift, not the donor's original cost.
Prior to 2022, investors could use like-kind exchanges to defer capital gains by trading one investment property for another similar one. As of January 1, 2022, this rule applies only to real property (real estate), not stocks, bonds, or other securities. If you exchange one rental property for another, you can still defer the gain, but the rules are strict and require the exchange to happen within specific timeframes.
Frequently Asked Questions
Do I owe capital gains tax if I haven't sold yet?
No. Capital gains tax is owed only when you sell the asset and realize the gain. An increase in value while you still own it is an unrealized gain and is not taxed. You owe tax only in the year you sell.
What if I sold at a loss — do I still file Schedule D?
Yes. You must report all sales on Schedule D, even if you had a loss. Losses offset gains and can reduce your taxable income, but only if you report them. If you have no gains to offset, you can deduct up to $3,000 of net losses against ordinary income.
How do I know my cost basis if I lost the original purchase confirmation?
Your broker's account statements and tax documents (Form 1099-B) show cost basis for most securities. For older transactions, you may need to contact the broker directly or search your email archives. If you truly cannot find it, you can estimate based on historical price data, but keep records of how you calculated it in case the IRS asks.
Can I deduct capital losses from my paycheck taxes?
Only up to $3,000 per year. If your capital losses exceed your gains by more than $3,000, the excess carries forward to future years. You can use it to offset future gains or deduct another $3,000 against ordinary income each year until the loss is used up.
What's the difference between capital gains and dividend income?
Capital gains come from selling an asset for more than you paid. Dividends are payments a company makes to shareholders from its profits. may have access to dividends (from U.S. companies, held for specific periods) are taxed at the same long-term capital gains rates. Unqualified dividends are taxed as ordinary income.