Capital Gains Tax Calculator
With what you paid 20000 usd, what you sold for 50000 usd, taxable income before this gain 80000 usd, capital gains tax comes to $4,500 — federal tax on the gain. It is reached in 21 steps, the last of which is 1 * 4500 + 0 * 6686 + 0, and each one is printed on the page with its numbers filled in. The formula is the one published by Rev. Proc. 2025-32, not an approximation fitted to it.
Federal tax on a sale, with the long-term rate stacked on top of your other income the way the law does it — and the 3.8% surtax most calculators forget.
Formula and sources checked · How we check
What you paid 20000, What you sold for 50000, How long you held it More than a year — long term, Filing status Single
$4,500
Federal tax on the gain for the example below. Editing a field recomputes the calculator below; this figure holds the answer the page was loaded with.
It is written into the HTML rather than drawn by a script, so a search engine reading this page without running JavaScript still finds an answer.
- Gain on the sale
50000 - 2000030,000- Top of the 0% band
1 * 49450 + 0 * 98900 + 0 * 66200 + 0 * 4945049,450- Top of the 15% band
1 * 545500 + 0 * 613700 + 0 * 579600 + 0 * 306850545,500- Top of the 10% ordinary band
1 * 12400 + 0 * 24800 + 0 * 17700 + 0 * 1240012,400- Top of the 12% ordinary band
1 * 50400 + 0 * 100800 + 0 * 67450 + 0 * 5040050,400- Top of the 22% ordinary band
1 * 105700 + 0 * 211400 + 0 * 105700 + 0 * 105700105,700- Top of the 24% ordinary band
1 * 201775 + 0 * 403550 + 0 * 201750 + 0 * 201775201,775- Top of the 32% ordinary band
1 * 256225 + 0 * 512450 + 0 * 256200 + 0 * 256225256,225- Top of the 35% ordinary band
1 * 640600 + 0 * 768700 + 0 * 640600 + 0 * 384350640,600- Income with the gain on top
80000 + max(0, 30000)110,000- Ordinary tax on income alone
12,312- Ordinary tax with the gain added
18,998- If short term, tax on the gain
18998 - 123126,686- Gain falling in the 15% band
max(0, min(110000, 545500) - max(80000, 49450))30,000- Gain falling in the 20% band
max(0, 110000 - max(80000, 545500))0- If long term, tax on the gain
30000 * 0.15 + 0 * 0.24,500- Net investment income tax threshold
1 * 200000 + 0 * 250000 + 0 * 200000 + 0 * 125000200,000- Net investment income tax at 3.8%
min(max(0, 30000), max(0, 110000 - 200000)) * 0.0380- Federal tax on the gain
1 * 4500 + 0 * 6686 + 04,500- What you keep
50000 - 20000 - 450025,500- Rate on the gain
4500 / 30000 * 10015 %
Worked example
A $30,000 long-term gain on $80,000 of other income is taxed at 15% — $4,500, and you keep $25,500. Hold the identical position eleven months instead of thirteen and it is short term, taxed as ordinary income: the bill is $6,686 and the effective rate 22.3%, because the gain stacks on top of the salary and part of it crosses into the 24% band. Two months of patience is worth $2,186.
How to work it out yourself
- 1.Enter what you paid including commissions and any dividends you already paid tax on and reinvested. That is the cost basis, and overstating the gain by forgetting reinvested dividends is the most expensive arithmetic error on a long-held fund.
- 2.Say how long you held it. More than a year is long term and gets the 0%, 15% or 20% rates; a year or less is short term and taxed exactly like wages.
- 3.Enter taxable income before the gain — after your deduction, not gross salary. The long-term rate depends on where the gain lands once stacked on top of that income, so a gain can straddle two rates.
- 4.The 3.8% net investment income tax is added automatically above $200,000 of income, or $250,000 filing jointly. It is not indexed, so it reaches further every year.
The formula
- Gain on the sale
50000 - 20000 - Top of the 0% band
1 * 49450 + 0 * 98900 + 0 * 66200 + 0 * 49450 - Top of the 15% band
1 * 545500 + 0 * 613700 + 0 * 579600 + 0 * 306850 - Top of the 10% ordinary band
1 * 12400 + 0 * 24800 + 0 * 17700 + 0 * 12400 - Top of the 12% ordinary band
1 * 50400 + 0 * 100800 + 0 * 67450 + 0 * 50400 - Top of the 22% ordinary band
1 * 105700 + 0 * 211400 + 0 * 105700 + 0 * 105700 - Top of the 24% ordinary band
1 * 201775 + 0 * 403550 + 0 * 201750 + 0 * 201775 - Top of the 32% ordinary band
1 * 256225 + 0 * 512450 + 0 * 256200 + 0 * 256225 - Top of the 35% ordinary band
1 * 640600 + 0 * 768700 + 0 * 640600 + 0 * 384350 - Income with the gain on top
80000 + max(0, 30000) - Ordinary tax on income alone
- Ordinary tax with the gain added
- If short term, tax on the gain
18998 - 12312 - Gain falling in the 15% band
max(0, min(110000, 545500) - max(80000, 49450)) - Gain falling in the 20% band
max(0, 110000 - max(80000, 545500)) - If long term, tax on the gain
30000 * 0.15 + 0 * 0.2 - Net investment income tax threshold
1 * 200000 + 0 * 250000 + 0 * 200000 + 0 * 125000 - Net investment income tax at 3.8%
min(max(0, 30000), max(0, 110000 - 200000)) * 0.038 - Federal tax on the gain
1 * 4500 + 0 * 6686 + 0 - What you keep
50000 - 20000 - 4500 - Rate on the gain
4500 / 30000 * 100
Source: Rev. Proc. 2025-32 — 2026 maximum zero rate and 15 percent rate amounts under § 1(j)(5), IRS Topic 409 — Capital gains and losses, IRS — Questions and answers on the net investment income tax
Questions people actually ask
- What is the capital gains tax rate?
- For an asset held over a year: 0% while the gain sits below $49,450 of taxable income single or $98,900 jointly, 15% up to $545,500 and $613,700, and 20% above. Held a year or less, there is no separate rate at all — the gain is added to your income and taxed at whatever bracket it lands in, up to 37%.
- Does a capital gain push my salary into a higher bracket?
- No, and the reverse is what happens. A long-term gain is stacked on top of ordinary income, so the income decides the gain’s rate rather than the gain raising the rate on the income. But the gain does raise adjusted gross income, and that can reduce credits, raise Medicare premiums two years later, and trigger the 3.8% surtax.
- How do I avoid capital gains tax?
- Legitimately: hold for more than a year to reach the long-term rates, realise gains in a year when taxable income is low enough to sit in the 0% band, offset gains with losses — capital losses cancel gains dollar for dollar and $3,000 of the excess comes off ordinary income each year — hold the asset inside a retirement account, or, for a home, use the $250,000 exclusion on a main residence you lived in for two of the last five years.
- What is the 3.8% net investment income tax?
- A surtax on investment income above $200,000 of modified AGI single, $250,000 filing jointly, $125,000 filing separately. It applies to the smaller of your net investment income or the amount by which income exceeds the threshold. Those thresholds were set in 2013 and are not adjusted for inflation, so it catches more people every year.
- Do I pay state tax on the gain as well?
- In most states, yes, and usually at the ordinary income rate — only a handful tax gains at a lower rate than wages, and nine states have no income tax at all. Washington is the odd case: no tax on wages, but a 7% tax on long-term gains above roughly $270,000.
Related
- Sales Tax CalculatorTax and total from a pre-tax price, plus the reverse — the pre-tax price hidden inside a total you already paid.
- Future Value CalculatorWhat a sum becomes after compounding, with or without regular additions, and how much of the result is the money you put in rather than the return.
- Property Tax CalculatorProperty tax from a home value, with the two things most calculators skip: the assessment ratio, and the exemption that comes off the value rather than the tax.
- Lottery Tax CalculatorThe advertised jackpot is neither the cash nor the take-home: the lump sum is roughly 48% of it, 24% is withheld, and the real federal rate is 37%.
- AGI CalculatorAdjusted gross income from your income and the adjustments taken before it — the figure a dozen credits and phase-outs are measured against.
- 1099 Tax CalculatorTotal tax on 1099 income — self-employment tax and income tax together — and the quarterly payment that keeps the underpayment penalty away.
Put this calculator on your site
Free, no attribution required beyond the link.
<iframe src="https://rulecalculators.com/embed/capital-gains-tax" width="100%" height="420" style="border:1px solid #e7e4de;border-radius:12px" title="Capital Gains Tax Calculator"></iframe>