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, or piece of land. The profit itself is called your capital gain. To find it, subtract what you originally paid (your cost basis) from what you sold it for (your sale price). That number is your gain. Then multiply that gain by the tax rate that applies to you, which depends on how long you held the asset and your income level.
The math looks like this: (Sale Price − Cost Basis) × Tax Rate = Capital Gains Tax Owed. If you bought stock for $5,000 and sold it for $8,000, your gain is $3,000. If your tax rate is 15 percent, you owe $450. The tricky part is not the multiplication — it is figuring out your cost basis and knowing which tax rate applies to you.
Key Takeaways
- Your capital gain is the difference between what you sold an asset for and what you originally paid for it, including purchase fees and improvements.
- Long-term capital gains (assets held over one year) are taxed at lower rates — 0%, 15%, or 20% depending on your income — while short-term gains use your regular income tax rate.
- Your cost basis is not just the purchase price; it includes commissions, closing costs, and for real estate, the cost of major improvements or repairs.
- You report capital gains on Schedule D of your tax return, and the IRS matches your report against what brokers and title companies report to them.
Long-term versus short-term: the holding period matters
How long you owned the asset determines which tax rate applies. 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. This distinction changes your tax bill significantly.
Short-term gains are taxed as ordinary income — the same rate as your salary or wages. If you are in the 24 percent tax bracket, short-term gains are taxed at 24 percent. Long-term gains are taxed at preferential rates: 0 percent, 15 percent, or 20 percent, depending on your total income for the year. For most people, long-term rates are much lower. The holding period clock starts the day after you buy and ends the day you sell.
Understanding cost basis: what counts as what you paid
Cost basis is not just the price tag. It includes everything you spent to acquire and improve the asset. For stock or mutual funds, add any commissions or fees you paid to buy it. For real estate, include the purchase price, closing costs, title insurance, property surveys, and any major improvements like a new roof or foundation work.
Repairs and maintenance do not count — only improvements that add value or extend the life of the property. If you inherited the property, your cost basis is usually the fair market value on the date of death, not what the previous owner paid. If you received stock as compensation, your basis is the value on the day you received it. Keep receipts and closing documents; the IRS will ask for proof if you are audited.
How tax brackets affect your long-term rate
Your long-term capital gains rate depends on which income bracket you fall into. The brackets change every year and are different for single filers, married filing jointly, and heads of household. For 2024, the 0 percent rate applies to single filers with taxable income up to roughly $47,000 and married filers up to roughly $94,000. The 15 percent rate covers the next tier, and the 20 percent rate applies to the highest earners.
Your "taxable income" includes your wages, interest, dividends, and capital gains added together. If you are near a bracket boundary, a large capital gain can push you into a higher rate. Some people sell assets across two tax years to stay in a lower bracket. This is legal and common, but it requires planning. A tax professional can model different scenarios for you.
Losses offset gains and can reduce other income
If you sell an asset for less than you paid, you have a capital loss. Capital losses reduce capital gains dollar-for-dollar. If you have $10,000 in gains and $3,000 in losses, you report a net gain of $7,000. If losses exceed gains in a year, you can deduct up to $3,000 of the excess against other income like wages or interest. Any remaining loss carries forward to future years.
This is why people sometimes sell losing positions before year-end — to offset gains they made elsewhere. It is called tax-loss harvesting. You can sell the same type of investment again after 30 days without triggering the "wash sale" rule, which prevents you from claiming a loss if you buy back a substantially identical asset within 30 days before or after the sale.
Where you report gains on your tax return
You report capital gains on Schedule D (Form 1040), which is part of your federal tax return. List each transaction separately: the asset, the date acquired, the date sold, the cost basis, the sale price, and the gain or loss. Your broker sends you a Form 1099-B showing sales proceeds, and the IRS receives a copy. Your brokerage or title company also reports to the IRS, so mismatches are flagged.
If you have many transactions, you may use Form 8949 (Sales of Capital Assets) to organize them before transferring totals to Schedule D. State income tax returns often require the same information. Some states tax capital gains at your ordinary income rate; others have separate rates or exemptions. Check your state's rules — they vary widely.
Special situations: real estate, inherited assets, and gifts
If you sell a primary residence, you may exclude up to $250,000 of gain (or $500,000 if married filing jointly) if you owned and lived in it for at least two of the last five years. This exclusion applies once every two years. Rental properties do not may have access to for this exclusion.
Inherited assets receive a "step-up" in basis. If your parent bought a house for $200,000 and it was worth $400,000 when they died, your cost basis is $400,000, not $200,000. You owe no tax on the appreciation that happened during their lifetime. If you sell it immediately after inheriting it, you owe little or no capital gains tax. Gifts work differently — the person who gives you an asset does not owe tax, but your cost basis is usually what they paid, not the gift's value at the time you received it.
Frequently Asked Questions
Do I owe capital gains tax if I have not sold yet?
No. Tax is owed only when you actually sell the asset and realize the gain. Unrealized gains — the profit on assets you still own — are not taxed. You can hold an appreciating stock for decades without owing anything until you sell it.
What if I sold at a loss — do I get a refund?
No refund, but losses reduce your taxable income. You can deduct up to $3,000 of net losses against wages, interest, and other income in one year. Excess losses carry forward indefinitely to future years. If you have no other income to offset, the loss just sits there until you have gains or income to use it against.
Can I avoid capital gains tax by donating the asset to charity?
Yes, and it is often the best move. If you donate appreciated stock or real estate directly to a may have access to charity, you avoid the capital gains tax entirely and get a charitable deduction for the full fair market value. You cannot do this if you sell first and then donate the cash — the tax is already owed at that point.
How do I know my cost basis if I lost the original receipt?
Your broker or mutual fund company has records going back years. Request a cost basis report from them — they are required to provide it. For real estate, check your closing statement and any receipts for improvements. If records are truly gone, the IRS may accept a reasonable estimate, but documentation is always safer.
Does the capital gains rate change every year?
The tax rates themselves (0%, 15%, 20%) do not change, but the income thresholds that determine which rate applies adjust annually for inflation. The IRS publishes updated brackets each January. A gain that fell in the 15% bracket last year might fall in the 20% bracket this year if your income rose.