Tax
How To Calculate Capital Gains Tax
When an asset is sold for more than it cost, the profit is a capital gain. Holding it over a year usually earns a lower long-term rate, while a shorter holding is taxed at the ordinary income rate.
Quick Answer
Gain = proceeds - cost basis; Tax = gain x rate; After-tax profit = gain - tax
- basis
- What you paid, including fees
- proceeds
- What you received on sale
- holding
- How long the asset was held
- rate
- The rate applied to the gain
Subtract what you paid from what you received to get the gain, then apply the long-term rate if the asset was held a year or more, or the ordinary rate if not. A 5,000 gain held long term at a 15 percent rate owes 750, leaving 4,250 of after-tax profit.
What Is Capital Gains Tax?
A capital gain is the profit made when a capital asset, such as shares, a fund or property, is sold for more than it cost. The difference between the sale proceeds and the cost basis is the gain, and it is subject to capital gains tax.
The cost basis is everything paid to acquire the asset, including the purchase price, commissions and fees. Improving an asset can add to the basis, which reduces the taxable gain. Accurate records of the basis matter, because an overstated gain means an overstated tax.
The holding period determines the rate. In the United States, an asset held for more than one year qualifies for the long-term rate, which is lower than the ordinary income rate. An asset held for a year or less is short-term and taxed at the ordinary rate.
The distinction is one of the largest tax levers available. For a high earner in a 22 or 24 percent ordinary bracket, the long-term rate may be 15 percent, and for the lowest earners the long-term rate can be zero. Simply waiting past the one-year mark can cut the tax substantially.
Long-term rates are themselves tiered. Depending on total taxable income, the rate may be zero, 15 percent or 20 percent, plus a surtax on investment income for the highest earners. The calculator here takes the rate as an input rather than deriving it.
Only the gain is taxed, not the entire proceeds. Selling an asset for 20,000 that cost 15,000 produces a 5,000 gain, and the tax is charged on the 5,000. The original 15,000 of basis is returned untaxed.
Capital losses can offset capital gains. If an asset is sold at a loss, the loss reduces the gains realised in the same year, and excess losses can offset a limited amount of ordinary income and be carried forward. This makes the realised gain, not the gross sale, the figure that matters.
The after-tax profit is the gain minus the tax. It is the figure that shows what the investor actually keeps, and it is often far lower than the headline gain once tax is applied, particularly for short-term holdings.
Timing can shift a gain between tax years. Realising a gain in a year with lower income may attract a lower rate, and spreading sales across years can keep each year's gain in a lower tier.
Wash sale rules prevent a loss being claimed and the same asset immediately repurchased. Selling at a loss and buying a substantially identical asset within a short window disallows the loss, so the timing of repurchase matters.
Certain assets are treated differently. A principal residence may qualify for a large exclusion of the gain, and some retirement accounts shelter gains entirely until withdrawal. The general rules are a starting point, not a complete picture.
State tax may apply on top of the federal rate, so the total rate on a gain can be higher than the federal figure alone. A complete estimate adds the state layer where it applies.
The calculator takes the cost basis, the proceeds and the holding period, applies the long-term rate when the holding exceeds a year, and reports the gain, the rate applied, the tax and the after-tax profit. It does not determine which rate you qualify for.
Formula
Gain = sale proceeds - cost basis
The profit subject to capital gains tax.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| P | Sale proceeds | currency | What you received. |
| B | Cost basis | currency | What you paid, including fees. |
Tax = gain x rate; After-tax = gain - tax
Applies the rate that matches the holding period.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| r | Tax rate | percent | Long-term rate if held over a year, otherwise ordinary. |
How To Calculate Capital Gains Tax
- 1
Establish the cost basis
Total everything paid to acquire the asset, including commissions and fees. Improvements can add to the basis and reduce the gain.
- 2
Note the sale proceeds
Use what you actually received after selling, net of any selling costs, so the gain reflects the real profit.
- 3
Compute the gain
Subtract the basis from the proceeds. A negative result is a capital loss, which can offset gains elsewhere.
- 4
Check the holding period
A holding of more than one year qualifies for the long-term rate. A year or less is short-term and taxed at the ordinary income rate.
- 5
Apply the rate and find the after-tax profit
Multiply the gain by the applicable rate to get the tax, then subtract it from the gain to see what you keep.
Examples
Example 1: 5,000 gain held long term
- Cost basis
- 15,000
- Sale proceeds
- 20,000
- Holding period
- 2 years
- Short-term tax rate
- 22%
- Long-term tax rate
- 15%
| Step | Calculation | Result |
|---|---|---|
| Capital gain | 20,000 - 15,000 | 5,000 |
| Holding period | 2 years, so long-term | long-term |
| Rate applied | long-term rate | 15% |
| Tax owed | 5,000 x 0.15 | 750 |
| After-tax profit | 5,000 - 750 | 4,250 |
Result: Held over a year, the 5,000 gain is taxed at the long-term rate of 15 percent, so the tax is 750 and the after-tax profit comes to 4,250 on the sale.
Example 2: Same gain held short term
- Cost basis
- 15,000
- Sale proceeds
- 20,000
- Holding period
- 0.5 years
- Short-term tax rate
- 22%
- Long-term tax rate
- 15%
| Step | Calculation | Result |
|---|---|---|
| Capital gain | 20,000 - 15,000 | 5,000 |
| Holding period | 0.5 years, so short-term | short-term |
| Rate applied | ordinary rate | 22% |
| Tax owed | 5,000 x 0.22 | 1,100 |
| After-tax profit | 5,000 - 1,100 | 3,900 |
Result: Held under a year, the same 5,000 gain is taxed at the ordinary rate of 22 percent, raising the tax to 1,100 and cutting the after-tax profit to 3,900 on the sale.
Calculator
After-tax profit
$4,250.00
- Capital gain
- $5,000.00
- Rate applied
- 1500.00%
- Estimated tax owed
- $750.00
Values update as you type. This calculator covers the single scenario its formula assumes — see Common Mistakes for what it leaves out.
Prefer a full-width tool? Open the Capital Gains Tax calculator page.
Common Mistakes
Forgetting fees in the cost basis
Commissions and purchase fees add to the basis and reduce the taxable gain. Omitting them overstates the gain and the tax.
Selling just before the one-year mark
Holding a few extra days can move a gain from the ordinary rate to the lower long-term rate. Selling early can cost far more in tax than the price movement.
Taxing the whole proceeds
Only the gain is taxed, not the entire sale. The basis is returned untaxed, so charging the rate on the proceeds massively overstates the bill.
Ignoring the offset from losses
Capital losses reduce capital gains. Selling a loser in the same year can wipe out tax on a winner, so the realised gain is what matters.
Triggering a wash sale
Selling at a loss and buying the same asset back too soon disallows the loss. Waiting out the window preserves the deduction.
Overlooking state tax
Many states tax capital gains on top of the federal rate. Ignoring the state layer understates the total tax.
Assuming one rate fits all
Long-term rates are tiered by income and can be zero, 15 or 20 percent. The applicable rate depends on total taxable income, not a single figure.
FAQ
How is capital gains tax calculated?
Subtract the cost basis from the sale proceeds to get the gain, then multiply by the applicable rate. A 5,000 gain at a 15 percent long-term rate owes 750.
What is the difference between short and long term?
A holding of more than one year qualifies for the lower long-term rate. A year or less is short-term and taxed at the ordinary income rate.
Do I pay tax on the whole sale?
No, only on the gain. The cost basis is returned untaxed, so the tax applies to the difference between proceeds and basis.
Can capital losses offset gains?
Yes. Losses reduce gains realised in the same year, and excess losses can offset limited ordinary income and carry forward.
Is the long-term rate always 15 percent?
No. Long-term rates are tiered by income and can be zero, 15 or 20 percent, with a surtax for the highest earners. Check the rate that applies to you.
Does the calculator include state tax?
No. It applies the rates you enter, which should be the federal rates. Add your state rate separately if your state taxes capital gains.
References
- [1]Internal Revenue Service, Capital gains and losses — https://www.irs.gov/taxtopics/tc409
- [2]Investopedia, Capital gains tax — https://www.investopedia.com/terms/c/capital_gains_tax.asp
- [3]USA.gov, Capital gains — https://www.usa.gov/taxes