How the capital gains tax is worked out
On the defaults — a $10,000.00 purchase, a $25,000.00 sale, long-term, $80,000.00 of taxable income, single — the gain is $15,000.00, the federal tax is $2,250.00, the NIIT is $0.00, the total tax is $2,250.00 and the after-tax proceeds are $22,750.00. The effective rate is 15.00% and the marginal rate is 15.00%. The whole calculation is three moves: find the gain, stack it on top of your taxable income through the bands, and add the NIIT if your income is high enough.
Six things about the model are worth stating plainly. First, the thresholds are on TAXABLE income (after the standard deduction), not gross income — a $80,000 salary with the standard deduction taken out is less than $80,000 of taxable income, and the bands are measured from the smaller number. Second, a loss (sale below purchase) owes $0 tax and the loss can offset other gains, up to $3,000 a year against ordinary income. Third, the calculator is federal only — state tax is extra, and most states tax capital gains as ordinary income. Fourth, collectibles (28% max) and unrecaptured Section 1250 gain (25% max) use different rates and are NOT modelled — this page covers plain stocks, funds and similar assets. Fifth, the home-sale exclusion ($250,000 single / $500,000 joint) is NOT modelled — selling your main home is a different calculation. And sixth, MAGI here is approximated as taxable income + gain — your real modified adjusted gross income can differ, so the NIIT line is an estimate, not a filing figure.
And the number that catches people out: selling after one year instead of two costs $1,050.00 on the same $15,000 gain — $3,300.00 of tax short-term against $2,250.00 long-term. The holding period is the cheapest tax move in the whole calculator: it costs nothing but patience, and on the defaults it is worth more than a thousand dollars.
The worked example, line by line
Setup: purchase price $10,000.00, sale price $25,000.00, long-term, taxable income $80,000.00, single.
Line 1 — the gain. Sale price minus purchase price: $25,000.00 − $10,000.00 = $15,000.00.
Line 2 — stack the gain. Taxable income of $80,000.00 is already above the $49,450 ceiling of the 0% band, so none of the gain is taxed at 0%. The whole $15,000.00 sits inside the 15% band, which runs to $545,500.00.
Line 3 — the federal tax. The gain at 15%: $15,000.00 × 15% = $2,250.00.
Line 4 — the NIIT. MAGI is approximated as $80,000.00 + $15,000.00 = $95,000.00, below the $200,000.00 single threshold, so the NIIT is $0.00.
Line 5 — total tax and proceeds. Total tax is $2,250.00 + $0.00 = $2,250.00. After-tax proceeds are $25,000.00 − $2,250.00 = $22,750.00.
Line 6 — the two rates. The effective rate is $2,250.00 ÷ $15,000.00 = 15.00%. The marginal rate — the rate on the last dollar of the gain, which sits at $95,000.00 of stacked income — is 15.00%. Rounding convention: totals are computed from unrounded values, so rounded parts may differ by a cent from their rounded sum.
Every branch, checked
Short-term: gain $15,000.00, federal tax $3,300.00, NIIT $0.00, total tax $3,300.00, after-tax proceeds $21,700.00, effective rate 22.00%, marginal rate 22.00% — holding long-term saves $1,050.00. The same sale, taxed at ordinary rates instead of the 15% band, costs almost half as much again.
Income $40,000: gain $15,000.00, federal tax $832.50, NIIT $0.00, total tax $832.50, after-tax proceeds $24,167.50, effective rate 5.55%, marginal rate 15.00%. Part of the gain still sits in the 0% band — $9,450.00 of it is taxed at 0% and only $5,550.00 at 15% — which is why the effective rate is a third of the marginal rate.
Income $30,000: gain $15,000.00, federal tax $0.00, NIIT $0.00, total tax $0.00, after-tax proceeds $25,000.00, effective rate 0.00%, marginal rate 0.00%. The whole gain fits inside the 0% band — $30,000.00 + $15,000.00 = $45,000.00, still under $49,450.00 — so you keep every dollar of the sale.
Sale $110,000: gain $100,000.00, federal tax $15,000.00, NIIT $0.00, total tax $15,000.00, after-tax proceeds $95,000.00, effective rate 15.00%, marginal rate 15.00%. A gain more than six times bigger, still entirely inside the 15% band — $80,000.00 + $100,000.00 = $180,000.00, far below $545,500.00.
Income $250,000: gain $15,000.00, federal tax $2,250.00, NIIT $570.00, total tax $2,820.00, after-tax proceeds $22,180.00, effective rate 18.80%, marginal rate 15.00%. The NIIT adds $570.00 — 3.8% of the whole $15,000.00 gain, because MAGI of $265,000.00 clears the $200,000.00 threshold by more than the gain itself.
Income $520,000, sale $90,000: gain $80,000.00, federal tax $14,725.00, NIIT $3,040.00, total tax $17,765.00, after-tax proceeds $72,235.00, effective rate 22.21%, marginal rate 20.00%. The stacked income reaches $600,000.00, so the last $54,500.00 of the gain crosses into the 20% band — $25,500.00 at 15% is $3,825.00 and $54,500.00 at 20% is $10,900.00 — and the NIIT takes 3.8% of the whole gain.
Joint, income $90,000: gain $15,000.00, federal tax $915.00, NIIT $0.00, total tax $915.00, after-tax proceeds $24,085.00, effective rate 6.10%, marginal rate 15.00%. The joint 0% band runs to $98,900.00, so $8,900.00 of the gain is taxed at 0% and only $6,100.00 at 15% — the same sale costs less than half as much as it does for a single filer at $80,000.00.
Loss, sale $8,000: gain −$2,000.00, federal tax $0.00, NIIT $0.00, total tax $0.00, after-tax proceeds $8,000.00, effective rate 0.00%, marginal rate 0.00%. A loss owes no tax — and it can offset other gains, up to $3,000.00 a year against ordinary income.
The reverses, worked backwards
Sale price for federal tax exactly $5,000: $43,333.33 — the exact sale price is $43333.3333. At $43,333.33 the federal tax is $5,000.00; 7 cents less, $43,333.26, it is $4,999.99; one cent more, $43,333.34, it is $5,000.00. $43,333.33 rounds JUST UNDER the target in the sense that 7 cents less already drops a cent — do not round the reverse up to force an exact hit. The star is DOLLARS.
Income for $0 tax: $34,450.00 a year — the exact income is $34450.0000. At $34,450 the tax is $0.00; $1 less, $34,449, it is also $0.00; $1 more, $34,451, it is $0.15. Earn a dollar more than $34,450 and the first dollar of the gain leaves the 0% band. The star is DOLLARS/YEAR.
Sale price for after-tax proceeds exactly $30,000: $33,529.41 — the exact sale price is $33529.4118. At $33,529.41 the proceeds are $30,000.00; $1 less, $33,528.41, they are $29,999.15; $1 more, $33,530.41, they are $30,000.85. You need to sell for about $3,529.41 more than the $30,000.00 you want to keep, because the tax takes 15 cents of every extra dollar. The star is DOLLARS.
Gain for NIIT exactly $1,000 (income $250,000): $26,315.79 — the exact gain is $26315.7895. At a gain of $26,315.79 the NIIT is $1,000.00; $1 less gain, $26,314.79, it is $999.96; $1 more gain, $26,316.79, it is $1,000.04. $26,315.79 rounds JUST UNDER the target in the sense that $1 less gain already drops the NIIT below $1,000 — do not round the reverse up. The star is DOLLARS.
Income where the gain first hits the 20% band: $530,500.00 a year — the exact income is $530500.0000. At $530,500 the tax is $2,250.00 — all of the gain still at 15%, though the NIIT of $570.00 also applies at this income, for a total of $2,820.00; $1 less, $530,499, the tax is also $2,250.00; $1 more, $530,501, it is $2,250.05. One dollar of income moves one dollar of gain from 15% to 20% — five cents of extra tax. The star is DOLLARS/YEAR.
Income where NIIT first applies: $185,000.00 a year — the exact income is $185000.0000. At $185,000 the NIIT is $0.00, because MAGI is exactly $200,000.00; $1 less, $184,999, it is also $0.00; $1 more, $185,001, it is $0.04. The NIIT starts as a trickle — four cents on the first dollar over the line — and grows to $570.00 on the full $15,000.00 gain. The star is DOLLARS/YEAR.
What the defaults assume
The thresholds are on TAXABLE income (after the standard deduction), not gross income; the 2026 long-term bands are 0% to $49,450.00 single / $98,900.00 joint, 15% to $545,500.00 single / $613,700.00 joint, 20% above, per IRS Rev. Proc. 2025-32; the short-term rates are the 2026 ordinary brackets; the NIIT is 3.8% on the lesser of the gain and (MAGI − threshold), with thresholds of $200,000.00 single / $250,000.00 joint, and MAGI approximated as taxable income + gain; the calculator is federal only — state tax is extra; collectibles (28% max) and unrecaptured Section 1250 gain (25% max) are NOT modelled; and the home-sale exclusion ($250,000.00 single / $500,000.00 joint) is NOT modelled. At the edges the model stays honest: with a gain of $0.00 (sale = purchase $10,000.00), Gain $0.00, federal tax $0.00, NIIT $0.00, total tax $0.00, after-tax proceeds $10,000.00, effective rate 0.00%, marginal rate 0.00% — no gain, no tax; that is the model at its boundary, not an error. With a loss of $2,000.00, Gain -$2,000.00, federal tax $0.00, NIIT $0.00, total tax $0.00, after-tax proceeds $8,000.00, effective rate 0.00%, marginal rate 0.00% — losses are not taxed. With income of $0.00, Gain $15,000.00, federal tax $0.00, NIIT $0.00, total tax $0.00, after-tax proceeds $25,000.00, effective rate 0.00%, marginal rate 0.00% — the whole gain sits inside the 0% band. With income of $600,000.00, Gain $15,000.00, federal tax $3,000.00, NIIT $570.00, total tax $3,570.00, after-tax proceeds $21,430.00, effective rate 23.80%, marginal rate 20.00% — the whole gain is at 20%. With a short-term gain at income of $700,000.00, Gain $15,000.00, federal tax $5,550.00, NIIT $570.00, total tax $6,120.00, after-tax proceeds $18,880.00, effective rate 40.80%, marginal rate 37.00% — the NIIT applies to short-term gains too. Rounding convention: totals are computed from unrounded values, so rounded parts may differ by a cent from their rounded sum.
Output · formula · meaning
| Output | Formula | What it means |
|---|
| Gain | S − P | $15,000.00. |
| Federal tax | long-term bands 0% / 15% / 20%, or ordinary rates if short-term | $2,250.00. |
| NIIT | 3.8% × lesser of gain and (MAGI − threshold) | $0.00. |
| Total tax | federal tax + NIIT | $2,250.00. |
| After-tax proceeds | S − total tax | $22,750.00. |
| Effective rate | total tax ÷ gain | 15.00%. |
| Marginal rate | rate on the last dollar of gain | 15.00%. |
| Sale price for federal tax exactly $5,000 | exact $43333.3333 | $43,333.33 → $43,333.33. |
| 7 cents less than the R1 star | $43,333.26 | Gain $33,333.26, federal tax $4,999.99, NIIT $0.00, total tax $4,999.99, after-tax proceeds $38,333.27, effective rate 15.00%, marginal rate 15.00%. |
| One cent more than the R1 star | $43,333.34 | Gain $33,333.34, federal tax $5,000.00, NIIT $0.00, total tax $5,000.00, after-tax proceeds $38,333.34, effective rate 15.00%, marginal rate 15.00%. |
| Income for $0 tax | exact $34450.0000 | $34,450.00 → $34,450.00. |
| $1 less than the R2 star | $34,449.00 | Gain $15,000.00, federal tax $0.00, NIIT $0.00, total tax $0.00, after-tax proceeds $25,000.00, effective rate 0.00%, marginal rate 0.00%. |
| $1 more than the R2 star | $34,451.00 | Gain $15,000.00, federal tax $0.15, NIIT $0.00, total tax $0.15, after-tax proceeds $24,999.85, effective rate 0.00%, marginal rate 15.00%. |
| Sale price for after-tax proceeds exactly $30,000 | exact $33529.4118 | $33,529.41 → $33,529.41. |
| $1 less than the R3 star | $33,528.41 | Gain $23,528.41, federal tax $3,529.26, NIIT $0.00, total tax $3,529.26, after-tax proceeds $29,999.15, effective rate 15.00%, marginal rate 15.00%. |
| $1 more than the R3 star | $33,530.41 | Gain $23,530.41, federal tax $3,529.56, NIIT $0.00, total tax $3,529.56, after-tax proceeds $30,000.85, effective rate 15.00%, marginal rate 15.00%. |
| Gain for NIIT exactly $1,000 (income $250,000) | exact $26315.7895 | $26,315.79 → $26,315.79. |
| $1 less gain than the R4 star | $26,314.79 | Gain $26,314.79, federal tax $3,947.22, NIIT $999.96, total tax $4,947.18, after-tax proceeds $31,367.61, effective rate 18.80%, marginal rate 15.00%. |
| $1 more gain than the R4 star | $26,316.79 | Gain $26,316.79, federal tax $3,947.52, NIIT $1,000.04, total tax $4,947.56, after-tax proceeds $31,369.23, effective rate 18.80%, marginal rate 15.00%. |
| Income where the gain first hits the 20% band | exact $530500.0000 | $530,500.00 → $530,500.00. |
| $1 less than the R5 star | $530,499.00 | Gain $15,000.00, federal tax $2,250.00, NIIT $570.00, total tax $2,820.00, after-tax proceeds $22,180.00, effective rate 18.80%, marginal rate 15.00%. |
| $1 more than the R5 star | $530,501.00 | Gain $15,000.00, federal tax $2,250.05, NIIT $570.00, total tax $2,820.05, after-tax proceeds $22,179.95, effective rate 18.80%, marginal rate 20.00%. |
| Income where NIIT first applies | exact $185000.0000 | $185,000.00 → $185,000.00. |
| $1 less than the R6 star | $184,999.00 | Gain $15,000.00, federal tax $2,250.00, NIIT $0.00, total tax $2,250.00, after-tax proceeds $22,750.00, effective rate 15.00%, marginal rate 15.00%. |
| $1 more than the R6 star | $185,001.00 | Gain $15,000.00, federal tax $2,250.00, NIIT $0.04, total tax $2,250.04, after-tax proceeds $22,749.96, effective rate 15.00%, marginal rate 15.00%. |
| Short-term | same model | Gain $15,000.00, federal tax $3,300.00, NIIT $0.00, total tax $3,300.00, after-tax proceeds $21,700.00, effective rate 22.00%, marginal rate 22.00%. |
| Income $40,000 | same model | Gain $15,000.00, federal tax $832.50, NIIT $0.00, total tax $832.50, after-tax proceeds $24,167.50, effective rate 5.55%, marginal rate 15.00%. |
| Income $30,000 | same model | Gain $15,000.00, federal tax $0.00, NIIT $0.00, total tax $0.00, after-tax proceeds $25,000.00, effective rate 0.00%, marginal rate 0.00%. |
| Sale $110,000 | same model | Gain $100,000.00, federal tax $15,000.00, NIIT $0.00, total tax $15,000.00, after-tax proceeds $95,000.00, effective rate 15.00%, marginal rate 15.00%. |
| Income $250,000 | same model | Gain $15,000.00, federal tax $2,250.00, NIIT $570.00, total tax $2,820.00, after-tax proceeds $22,180.00, effective rate 18.80%, marginal rate 15.00%. |
| Income $520,000, sale $90,000 | same model | Gain $80,000.00, federal tax $14,725.00, NIIT $3,040.00, total tax $17,765.00, after-tax proceeds $72,235.00, effective rate 22.21%, marginal rate 20.00%. |
| Joint, income $90,000 | same model | Gain $15,000.00, federal tax $915.00, NIIT $0.00, total tax $915.00, after-tax proceeds $24,085.00, effective rate 6.10%, marginal rate 15.00%. |
| Loss, sale $8,000 | same model | Gain -$2,000.00, federal tax $0.00, NIIT $0.00, total tax $0.00, after-tax proceeds $8,000.00, effective rate 0.00%, marginal rate 0.00%. |
Who uses this
- The investor selling stock after two years: they learn the gain is $15,000.00, the federal tax is $2,250.00 and the after-tax proceeds are $22,750.00 — and they check the short-term branch to see the same sale would cost $3,300.00 if they had sold a year earlier.
- The seller with $40,000 of income: they learn the tax is only $832.50, an effective rate of 5.55% — and they check the $30,000 income branch to see the tax falls to $0.00 when the whole gain fits inside the 0% band.
- The high earner at $250,000 of income: they learn the NIIT adds $570.00 on top of the $2,250.00 federal tax, for a total of $2,820.00 — and they check the $185,000 income reverse to see the NIIT starts as just $0.04 on the first dollar over the line.
- The seller with a loss: they learn a $8,000.00 sale on a $10,000.00 purchase is a −$2,000.00 gain that owes $0.00 tax — and they check the loss rule to see it can offset other gains, up to $3,000.00 a year against ordinary income.
Accuracy & limitations
The math is first-principles: the gain is the sale price minus the purchase price; for a long-term gain, taxable income plus the gain is stacked through the 2026 bands — 0% to $49,450.00 single / $98,900.00 joint, 15% to $545,500.00 single / $613,700.00 joint, 20% above (IRS Rev. Proc. 2025-32) — and only the gain's portion in each band is taxed at that band's rate; for a short-term gain, the tax is the ordinary tax on (income + gain) minus the ordinary tax on income alone, using the 2026 ordinary brackets; the NIIT is 3.8% on the lesser of the gain and (MAGI − threshold), with thresholds of $200,000.00 single / $250,000.00 joint; the total tax is the federal tax plus the NIIT; the after-tax proceeds are the sale price minus the total tax; the effective rate is the total tax divided by the gain; and the marginal rate is the band or bracket rate on the last dollar of the gain. Every figure is rounded to cents half-up, and the totals are computed from unrounded values, so rounded parts may differ by a cent from their rounded sum. What the model cannot do is file YOUR return: it uses taxable income, not gross income, so it never works out your standard deduction for you; it is federal only, so it never includes state tax; it does NOT model collectibles at 28% or unrecaptured Section 1250 gain at 25%; it does NOT model the home-sale exclusion; it approximates MAGI as taxable income + gain, so the NIIT line is an estimate; and it treats a loss as $0.00 tax without working out how much of it you can actually use this year. Use it to judge what a sale costs you in federal tax, then check the 2026 brackets and your own return before you sell.
Cite this calculatorBright Side Kit. “Capital Gains Tax Calculator: Long & Short Term 2026” brightoolbox.com, 2026. Method: gain = sale price − purchase price; long-term gain stacked through the 2026 bands (0% to $49,450 single / $98,900 joint, 15% to $545,500 single / $613,700 joint, 20% above, IRS Rev. Proc. 2025-32); short-term gain taxed at ordinary rates (ordinary tax on income + gain minus ordinary tax on income alone); NIIT = 3.8% on the lesser of the gain and (MAGI − threshold), thresholds $200,000 single / $250,000 joint, MAGI approximated as taxable income + gain; total tax = federal tax + NIIT; after-tax proceeds = sale price − total tax; effective rate = total tax ÷ gain; marginal rate = rate on the last dollar of gain; all money figures rounded to cents half-up, totals from unrounded values. Reverses: the sale price for federal tax exactly $5,000 is $43,333.33 (exact $43333.3333; at $43,333.33 the tax is $5,000.00; 7 cents less, $43,333.26, it is $4,999.99; one cent more, $43,333.34, it is $5,000.00); the income for $0 tax is $34,450 (exact $34450.0000; at $34,450 the tax is $0.00; $1 more, $34,451, it is $0.15); the sale price for after-tax proceeds exactly $30,000 is $33,529.41 (exact $33529.4118; at $33,529.41 the proceeds are $30,000.00; $1 less, $33,528.41, they are $29,999.15); the gain for NIIT exactly $1,000 (income $250,000) is $26,315.79 (exact $26315.7895; at $26,315.79 the NIIT is $1,000.00; $1 less gain, $26,314.79, it is $999.96); the income where the gain first hits the 20% band is $530,500 (exact $530500.0000; at $530,500 the tax is $2,250.00; $1 more, $530,501, it is $2,250.05); the income where NIIT first applies is $185,000 (exact $185000.0000; at $185,000 the NIIT is $0.00; $1 more, $185,001, it is $0.04). Defaults: Gain $15,000.00, federal tax $2,250.00, NIIT $0.00, total tax $2,250.00, after-tax proceeds $22,750.00, effective rate 15.00%, marginal rate 15.00%. Bright Side Kit. "Capital Gains Tax Calculator: Long & Short Term 2026" https://brightoolbox.com/capital-gains-tax-calculator/ Accessed October 26, 2026.
Embed this calculator
Frequently asked questions
How much federal tax do I pay on a $15,000 long-term gain with $80,000 of taxable income?
$2,250.00. The gain is $15,000.00, the NIIT is $0.00, the total tax is $2,250.00 and the after-tax proceeds are $22,750.00. The effective rate is 15.00% and the marginal rate is 15.00%.
How much does holding long-term save over short-term?
$1,050.00. Short-term, the same $15,000.00 gain costs $3,300.00 in tax (22.00% effective) and leaves $21,700.00 after tax, against $2,250.00 and $22,750.00 long-term.
What if my taxable income is $40,000?
$832.50. Part of the gain still sits in the 0% band — $9,450.00 of it is taxed at 0% and only $5,550.00 at 15% — so the effective rate is 5.55% and the after-tax proceeds are $24,167.50.
Can the capital gains tax be $0?
Yes. With $30,000.00 of taxable income, the whole $15,000.00 gain fits inside the 0% band ($30,000.00 + $15,000.00 = $45,000.00, still under $49,450.00), so the tax is $0.00 and you keep the full $25,000.00. The income for $0 tax is $34,450.00 — $1 more, $34,451.00, and the tax is $0.15.
What sale price gives exactly $5,000 of federal tax?
$43,333.33. The exact sale price is $43333.3333. At $43,333.33 the federal tax is $5,000.00; 7 cents less, $43,333.26, it is $4,999.99; one cent more, $43,333.34, it is $5,000.00.
When does the 3.8% NIIT kick in?
At $185,000.00 of taxable income on a $15,000.00 gain. At $185,000.00 the NIIT is $0.00, because MAGI is exactly $200,000.00; $1 more, $185,001.00, and it is $0.04. At $250,000.00 of income the NIIT is $570.00 on the whole gain, for a total tax of $2,820.00.
What income puts my gain in the 20% band?
$530,500.00. At $530,500.00 the tax is still $2,250.00 — all of the gain at 15% — but $1 more, $530,501.00, and the tax is $2,250.05, because one dollar of the gain has crossed into the 20% band.
What does this calculator NOT cover?
State tax, collectibles, Section 1250 gain, and the home-sale exclusion. It is federal only — state tax is extra. Collectibles (28% max) and unrecaptured Section 1250 gain (25% max) use different rates and are NOT modelled. The home-sale exclusion ($250,000 single / $500,000 joint) is NOT modelled. A loss owes $0 tax and can offset other gains, up to $3,000 a year against ordinary income. And the thresholds are on TAXABLE income, not gross income.