The basic formula: sale price minus what you paid, times your tax rate
Capital gains tax is calculated on the profit you made when you sold an asset — a stock, rental property, or other investment. The profit itself is called your capital gain, and it equals the sale price minus your original cost (called your basis). You then explore your tax rate to that gain. The rate depends on how long you held the asset and your income level.
The simplest version: if you bought stock for $5,000 and sold it for $8,000, your capital gain is $3,000. If your tax rate on that gain is 15%, you owe $450 in federal capital gains tax. But the real calculation is more complex because you need to track your basis accurately, account for holding periods, and know which tax rate applies to you.
Most people calculate this once a year when they file their tax return, using information from their brokerage statements and the IRS Form 8949 (Sales of Capital Assets). You report the gain or loss on Schedule D, which feeds into your overall tax liability.
Key Takeaways
- Your capital gain equals the sale price minus your original cost (basis), and you owe tax only on the gain, not the full sale price.
- Long-term gains (assets held over one year) are taxed at 0%, 15%, or 20% depending on your income; short-term gains are taxed as ordinary income at rates up to 37%.
- Your basis includes the purchase price plus any fees or improvements, and you must track it accurately or use your brokerage's cost basis records.
- You report gains and losses on Form 8949 and Schedule D when you file your tax return, and you can use losses to offset gains in the same year.
- State and local taxes may add 3% to 13% to your federal rate, depending on where you live and where you earned the gain.
The difference between long-term and short-term gains
The IRS taxes gains differently based on how long you held the asset. If you held it for more than one year before selling, 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 gains are taxed as ordinary income, at your regular tax bracket rate — anywhere from 10% to 37% depending on your total income. Long-term gains get preferential rates: 0%, 15%, or 20%, depending on your taxable income and filing status. For most people, long-term rates are significantly lower. For example, a single filer with $50,000 in taxable income pays 15% on long-term gains but would pay 22% on short-term gains.
The holding period clock starts the day after you buy and ends the day you sell. If you bought on January 15 and sold on January 16 of the next year, you meet the one-year threshold. If you sold on January 15, you do not.
How to find and verify your cost basis
Your cost basis is what you originally paid for the asset, plus any fees or improvements. For a stock purchase, it includes the share price plus any brokerage commissions. For a rental property, it includes the purchase price, closing costs, and the cost of capital improvements (a new roof, not routine repairs). For inherited assets, the basis is usually reset to the market value on the date of death, not what the original owner paid.
Your brokerage or mutual fund company is required by law to track and report your cost basis to you and to the IRS on Form 1099-B. You can usually view it in your account online under "cost basis" or "tax information." If you have multiple purchases of the same stock, you can choose which shares to sell — selling the highest-cost shares first (called the "highest cost" method) minimizes your gain. If you do not specify, most brokerages use FIFO (first in, first out), which may not be optimal for your taxes.
If your brokerage does not have accurate records — for example, if you bought shares decades ago or transferred accounts — you may need to reconstruct your basis using old statements, trade confirmations, or dividend records. Keep all purchase and sale documents for at least three years after you file the return reporting the gain.
Calculating gain or loss step by step
Here is the actual order of steps you follow when you sell an asset:
- Find the sale price. This is the total amount you received, minus any fees the broker charged to sell. If you sold 100 shares at $80 per share and paid a $10 commission, your sale price is $7,990.
- Find your cost basis. Get this from your brokerage statement or cost basis report. If you bought 100 shares at $50 per share and paid a $10 commission, your basis is $5,010 (or $50.10 per share).
- Subtract basis from sale price. $7,990 − $5,010 = $2,980 gain.
- Determine holding period. Count the days from the day after purchase to the day of sale. If it is more than one year, it is long-term; one year or less is short-term.
- Find your tax rate. For long-term gains, use the 0%, 15%, or 20% rate based on your 2024 taxable income and filing status. For short-term gains, use your ordinary income tax bracket.
- Multiply gain by rate. $2,980 × 15% = $447 in federal tax (if you are in the 15% long-term bracket).
You will also owe state and local tax in most states, which ranges from 0% (in states like Florida and Texas) to over 13% (in California and New York). Some states tax capital gains as ordinary income; others have separate rates.
Using capital losses to reduce your tax bill
If you sold an asset at a loss, you can use that loss to offset gains in the same year. If you have $5,000 in gains and $2,000 in losses, you report a net gain of $3,000 and pay tax only on that amount. This is called loss harvesting and is one of the few ways to reduce capital gains tax without changing your investment strategy.
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, interest, etc.). Any remaining loss carries forward to future years, where you can use it again. This means a large loss in one year can reduce your tax burden for several years.
There is one catch: the wash-sale rule. If you sell a stock at a loss and buy the same stock (or a substantially identical one) within 30 days before or after the sale, the IRS disallows the loss. You can avoid this by waiting 31 days or by buying a different but similar investment (for example, a different index fund) in the meantime.
When to report gains and losses on your tax return
You report capital gains and losses on Form 8949 (Sales of Capital Assets), which lists each transaction separately. You then summarize the totals on Schedule D (Capital Gains and Losses), which shows your net long-term and short-term gains or losses. Schedule D feeds into your Form 1040.
Your brokerage sends you Form 1099-B in January or February, which lists all your sales from the previous year. Use this to fill out Form 8949. If the cost basis on the 1099-B is wrong, you can correct it on Form 8949 — the IRS will see both numbers and will not penalize you if you explain the discrepancy.
You must file your return by April 15 (or the next business day) to report gains from the previous year. If you owe tax on the gain, you should pay it by that date to avoid penalties and interest. If you have a large gain, you may need to make quarterly estimated tax payments in the current year to avoid underpayment penalties.
Special situations: inherited assets, gifts, and real estate
If you inherited an asset, your cost basis is reset to its market value on the date of the owner's death (or six months later if the estate chooses). This is called a step-up in basis. If your parent bought a house for $100,000 and it was worth $400,000 when they died, your basis is $400,000. If you sell it when ready for $400,000, you owe no capital gains tax.
If you received an asset as a gift, your basis is the donor's original cost basis, not the gift's current value. If your friend bought stock for $1,000 and gave it to you when it was worth $5,000, your basis is $1,000. If you sell it for $6,000, your gain is $5,000, not $1,000.
For real estate, you can exclude up to $250,000 of gain ($500,000 if married filing jointly) if you lived in the home as your primary residence for at least two of the last five years before selling. This exclusion applies once every two years. Rental properties do not may have access to for this exclusion.
Frequently Asked Questions
Do I owe capital gains tax if I have not sold yet?
No. Capital gains tax is owed only when you sell the asset and realize the gain. If you own stock worth $10,000 more than you paid, you owe nothing until you sell. This is called an "unrealized gain." Once you sell, it becomes a "realized gain" and is taxable.
What if I sold at a loss — do I get a refund?
Not directly. You can use losses to offset gains in the same year, and if losses exceed gains, you can deduct up to $3,000 against ordinary income. Any remaining loss carries forward to future years. You do not get a refund, but the loss reduces your taxable income.
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 usually marks this on your 1099-B. When in doubt, use the date on your purchase confirmation and sale confirmation.
Can I avoid capital gains tax by donating the asset to charity?
Yes, partially. If you donate appreciated stock or property to a may have access to charity, you avoid the capital gains tax on the appreciation and can deduct the full fair market value as a charitable contribution. You must itemize deductions for this to help you, and the charity must be IRS-recognized.
What if I made a mistake on my capital gains calculation last year?
You can file an amended return using Form 1040-X within three years of the original filing date. Attach a corrected Schedule D and Form 8949. If you owe additional tax, you will owe interest from the original due date, but you may avoid penalties if the error was reasonable.