The basic formula for capital gains tax
Capital gains tax is calculated by taking the price you sold an asset for, subtracting what you paid for it, and then explore your tax rate to that profit. That difference — the profit — is your capital gain. The tax you owe depends on how long you held the asset and your income level.
The formula looks like this: Sale Price minus Purchase Price equals Capital Gain. Then: Capital Gain multiplied by Your Tax Rate equals Tax Owed. The tricky part is that your tax rate is not one number — it depends on whether you held the asset for more or less than one year, and on your total income that year.
You report capital gains on your tax return using Schedule D (Form 1040), which is the IRS form for listing gains and losses from sales of stocks, real estate, and other investments. The IRS uses this form to separate short-term gains (held one year or less) from long-term gains (held more than one year), because they are taxed at different rates.
Key Takeaways
- Your capital gain is the sale price minus the purchase price, and you calculate tax by multiplying that gain by your tax rate.
- Short-term capital gains (assets held one year or less) are taxed as ordinary income at rates up to 37 percent, while long-term gains have lower rates of 0, 15, or 20 percent depending on your income.
- You must report the purchase price, sale price, and holding period for each asset on Schedule D of your tax return.
- If you sold an asset for less than you paid for it, you have a capital loss, which you can use to reduce other gains or up to $3,000 of ordinary income in a single year.
- Inherited assets receive a "step-up in basis," meaning your purchase price for tax purposes is the value on the date of death, not what the original owner paid.
Short-term versus long-term capital gains rates
The IRS taxes short-term and long-term capital gains at completely different rates. Short-term capital gains are profits from assets you held for one year or less. These are taxed as ordinary income, meaning they use the same tax brackets as your wages or salary — up to 10, 12, 22, 24, 32, 35, or 37 percent depending on your income and filing status.
Long-term capital gains are profits from assets you held for more than one year. These have their own, lower tax brackets: 0 percent, 15 percent, or 20 percent. Which rate you pay depends on your income level. For 2024, if you are single and your income is under roughly $47,000, you pay 0 percent on long-term gains. Between roughly $47,000 and $518,900, you pay 15 percent. Above that, you pay 20 percent. These income thresholds are different for married filing jointly and other filing statuses, and they change each year.
This is why holding an investment for more than one year usually saves you money in taxes. If you sell a stock after 11 months and make a $10,000 profit, you might owe $2,200 in federal tax (at 22 percent). If you wait one more month and sell it as a long-term gain, you might owe only $1,500 (at 15 percent) — a savings of $700 just by waiting.
Calculating gain or loss on individual assets
For each asset you sold, you need three pieces of information: the date you bought it, the price you paid (including any fees or commissions), and the price you sold it for (minus any fees or commissions). Subtract the purchase price from the sale price. If the number is positive, you have a gain. If it is negative, you have a loss.
Example: You bought 100 shares of a stock for $50 per share on March 15, 2023. You paid a $10 commission, so your total cost was $5,010. You sold all 100 shares for $65 per share on July 20, 2024, and paid a $10 commission on the sale. Your sale proceeds were $6,490. Your capital gain is $6,490 minus $5,010, which equals $1,480. Because you held the stock for more than one year, this is a long-term gain.
If you sold real estate, the calculation is the same but the numbers are larger. Your purchase price includes the price you paid plus any closing costs (title insurance, appraisal fees, attorney fees). Your sale price is what the buyer paid minus your closing costs on the sale (realtor commission, title insurance, attorney fees). Some improvements you made to the property — like a new roof or kitchen renovation — can be added to your purchase price, but regular maintenance cannot.
Handling multiple sales and net capital gains
If you sold more than one asset during the year, you calculate the gain or loss for each one separately, then combine them. First, add up all your short-term gains and losses to get your net short-term capital gain or loss. Then add up all your long-term gains and losses to get your net long-term capital gain or loss. These two numbers are reported separately on Schedule D.
If you have both short-term and long-term gains, you report them separately because they are taxed at different rates. If you have a short-term gain of $5,000 and a long-term gain of $3,000, you owe tax on both, but the long-term gain is taxed at the lower rate.
If you have a loss in one category and a gain in another, you can use the loss to reduce the gain. For example, if you have a short-term loss of $2,000 and a long-term gain of $5,000, you first use the loss to reduce the gain in the same category if possible. If you have losses left over after reducing gains, you can use up to $3,000 of losses per year to reduce ordinary income (like wages). Any losses beyond that carry forward to future years.
The role of cost basis and how to track it
Cost basis is the purchase price you use to calculate your gain or loss. For most assets, it is straightforward what you paid. But basis can be more complicated if you inherited the asset, received it as a gift, or bought it through a dividend reinvestment plan.
If you inherited an asset, your basis is not what the original owner paid — it is the value of the asset on the date of death. 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 a month later for $410,000, your capital gain is only $10,000, not $310,000. This can save you thousands in taxes.
If you received an asset as a gift, your basis is usually what the giver paid for it. If you later sell it for more than that, you owe tax on the gain. If you sell it for less than what the giver paid, your loss is limited — you can only deduct a loss based on the lower of the giver's basis or the fair market value when you received it.
Keep records of what you paid for each asset, including purchase date, purchase price, and any fees. Your brokerage or investment company sends you a 1099-B form each year listing sales, but it may not have your correct basis if you bought the asset years ago or transferred it between accounts. You are responsible for providing the correct basis to the IRS.
State and local taxes on capital gains
Federal capital gains tax is only part of what you owe. Most states also tax capital gains, and a few cities do as well. State tax rates vary widely. Some states tax capital gains as ordinary income (using the same brackets as wages), while others have separate, lower rates. A few states do not tax capital gains at all.
California, for example, taxes capital gains as ordinary income at rates up to 13.3 percent. New York taxes them at rates up to 10.9 percent. But Florida, Texas, and Washington have no state income tax at all, so residents pay only federal capital gains tax. New York City residents also pay a city income tax on capital gains.
When you calculate what you owe, add your state and local tax to your federal tax. This is why the total tax on a capital gain can be much higher than the federal rate alone. A long-term gain taxed at 15 percent federally could be taxed at 15 percent plus 10 percent state, for a total of 25 percent.
Special situations: real estate, collectibles, and may have access to small business stock
Most long-term capital gains are taxed at 0, 15, or 20 percent. But some assets have their own rules. Collectibles — art, coins, stamps, and similar items — are taxed at a maximum of 28 percent even if they are long-term gains. This is higher than the standard long-term rate.
Real estate has a special rule called the Section 1031 exchange. If you sell investment real estate and buy another piece of investment real estate of equal or greater value within 180 days, you can defer (not eliminate) your capital gains tax. You do not pay tax on the gain from the first property — instead, your basis in the new property is reduced, and you will owe tax when you eventually sell that property without doing another exchange.
If you sell a home you lived in, you may be able to exclude up to $250,000 of gain from tax (or $500,000 if you are married filing jointly). You must have owned and lived in the home for at least two of the last five years. This exclusion applies once every two years, so you can use it multiple times if you buy and sell homes over your lifetime.
may have access to small business stock — stock in a C corporation with assets under $50 million that you held for more than five years — may allow you to exclude 50 to 100 percent of your gain from tax. This is a complex rule with strict requirements, and you should consult a tax professional if you think you may have access to.
Frequently Asked Questions
Do I have to pay capital gains tax if I reinvest the money?
Yes. The tax is based on the gain itself, not on what you do with the money afterward. If you sell a stock for a $5,000 profit and when ready buy another stock with that money, you still owe tax on the $5,000 gain. Reinvesting does not reduce or defer the tax.
What if I sold an asset at a loss?
You can use capital losses to reduce capital gains dollar-for-dollar. If you have a $3,000 loss and a $5,000 gain, your net gain is $2,000. If your losses exceed your gains, you can deduct up to $3,000 of the excess loss against ordinary income (wages, interest, etc.) in that year. Any remaining loss carries forward to future years.
How do I report capital gains on my tax return?
You report each sale on Schedule D (Form 1040), listing the asset, the date bought, the date sold, the purchase price, the sale price, and the gain or loss. Your short-term and long-term totals then transfer to your Form 1040. If you have a net capital gain, it is added to your income and taxed. If you have a net loss, it reduces your income.
What is the difference between cost basis and fair market value?
Cost basis is what you paid for an asset. Fair market value is what it is worth on a given date. You use cost basis to calculate your gain or loss. Fair market value matters for inherited assets (where your basis is the value on the date of death) and for charitable donations (where you deduct the fair market value).
Can I carry forward unused capital losses to next year?
Yes. If you have capital losses that exceed your gains and you have already used $3,000 against ordinary income, the remaining loss carries forward indefinitely. You can use it in future years to reduce future gains or ordinary income, following the same $3,000 annual limit on ordinary income.