Capital Gains Tax Calculator
Estimate US federal capital gains tax on a stock sale — short vs long term, 0/15/20% brackets, NIIT, and effective rate
Your sale
Taxable income means ordinary taxable income after deductions — not your gross salary.
Long-term requires holding more than one year. A position held exactly one year — or less — is short-term.
Estimated tax on this sale
after-tax gain $10,800
Bracket breakdown
Your gain stacks on top of your taxable income, filling brackets from $45,000 up to $57,000. Bracket thresholds are approximate, as of 2026, and adjusted annually.
Short-term vs long-term
In this scenario, the two estimates differ by $900 — an educational illustration of why holding period matters, not advice to hold or sell.
Out of scope — disclosed, never computed here: collectibles (28% rate), Section 1202 QSBS, depreciation recapture, crypto/property nuances, qualified-dividend interactions, AMT.
How it works
Enter what the sale brought in (proceeds) and what the position cost you (cost basis, including commissions). The difference is your capital gain. If it’s negative, there is no capital gains tax — losses get their own treatment, which the tool explains when it applies.
The gain doesn’t get one flat rate. It stacks on top of your other taxable income and fills federal tax brackets from there upward — so part of a gain can land in one bracket and the rest in the next. Which brackets apply depends on your holding period: positions held more than one year use the preferential long-term rates (0%, 15%, or 20% as of 2026), while positions held exactly one year or less use ordinary income rates (10% to 37% as of 2026).
The tool shows the estimated federal tax, a bracket-by-bracket breakdown, your effective rate on the gain, your after-tax gain, and a short-term vs long-term side-by-side. It also checks whether the 3.8% Net Investment Income Tax (NIIT) might apply, and — when your account capital arrives from another StockTools calculator — it reframes the tax as a percentage of your total capital.
The formula
Capital gain: capitalGain = proceeds − costBasis. The gain is what the sale brought in minus what the position cost. If it’s zero or negative, there is no federal capital gains tax on the sale.
Marginal stacking: the gain fills tax bands from taxableIncome up to taxableIncome + capitalGain. For each band: portionInBand = max(0, min(taxableIncome + capitalGain, bandCeiling) − max(taxableIncome, bandFloor)) and taxInBand = portionInBand × rate. In words: for each bracket, take the slice of the stacked gain that falls between that bracket’s floor and ceiling — zero if the gain never reaches it or has already passed it — and multiply that slice by the bracket’s rate.
Total: estimatedFederalTax = Σ taxInBand across every band the gain touches. This is a marginal-stacking estimate — it does not recompute your entire return, phase-outs, AMT, or credits.
Effective rate: effectiveRate = estimatedFederalTax ÷ capitalGain × 100, computed only when there is a gain. After-tax gain: capitalGain − estimatedFederalTax (NIIT shown separately, not subtracted).
NIIT check: if taxableIncome + capitalGain exceeds the statutory threshold ($200,000 single or head of household, $250,000 married filing jointly, $125,000 married filing separately — as of 2026, not inflation-indexed), the tool estimates 3.8% × min(capitalGain, excess over threshold). Because taxable income is after deductions while MAGI is not, this proxy understates MAGI — so the tool errs toward notflagging NIIT and shows a caution when you’re within $20,000 below the threshold.
Worked example
A single filer with $45,000 of taxable income sells a position: proceeds $30,000, cost basis $18,000. Illustrative approximate bands as of 2026 (single filer): long-term 0% up to ~$49,000 and 15% from ~$49,000 to ~$540,000; ordinary 12% from ~$12,400 to ~$50,400 and 22% from ~$50,400 to ~$105,700.
Capital gain: 30,000 − 18,000 = $12,000, stacking from $45,000 up to $57,000.
Held long-term: the slice in the 0% band is min(57,000, 49,000) − max(45,000, 0) = $4,000 → $0 tax. The slice in the 15% band is 57,000 − 49,000 = $8,000 → $1,200 tax. Estimated federal tax = $1,200, an effective rate of 10.00%, leaving an after-tax gain of $10,800.
Same sale, held short-term: the slice in the 12% band is 50,400 − 45,000 = $5,400 → $648. The slice in the 22% band is 57,000 − 50,400 = $6,600 → $1,452. Estimated federal tax = $2,100, an effective rate of 17.50%, after-tax gain $9,900.
NIIT: income proxy 45,000 + 12,000 = $57,000 is well under the $200,000 single-filer threshold (and under the $180,000 caution line), so no NIIT note appears. If a $100,000 account capital arrived from a previous tool, the $1,200 long-term estimate is shown as 1.20% of capital.
Side by side: in this illustrative scenario the long-term estimate is $2,100 − $1,200 = $900 lower — an educational illustration of why holding period matters, not advice to hold or sell.
Frequently asked questions
What is the difference between short-term and long-term capital gains?
Gains on assets held more than one year are long-term and taxed at preferential federal rates (0%, 15%, or 20% as of 2026). Gains on assets held one year or less are short-term and taxed at ordinary income rates, which are typically higher.
What are the long-term capital gains tax rates?
As of 2026, federal long-term rates are 0%, 15%, or 20%, depending on your taxable income and filing status. The dollar thresholds between those bands are adjusted for inflation each year, so this tool treats them as approximate.
What is the Net Investment Income Tax (NIIT)?
An additional 3.8% federal tax that can apply to investment income when modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly) as of 2026. Those thresholds are set by statute and are not inflation-adjusted.
Does this calculator include state taxes?
No. It estimates federal tax only. Many states also tax capital gains — often as ordinary income — so your total bill may be higher.
What if I sold at a loss?
There is no capital gains tax on a loss. Capital losses can offset gains and up to $3,000 of ordinary income per year ($1,500 if married filing separately, as of 2026), with the excess carried forward — but watch the wash-sale rule if you rebought within 30 days.
Is this tax advice?
No. This is an educational estimate using a simplified model. Consult a CPA or tax professional before making decisions based on taxes.
Continue your analysis
Educational estimate — not tax advice
- Estimate only. This is a simplified marginal-stacking model of US federal tax as of 2026. It ignores AMT, phase-outs, credits, deduction interactions, loss netting across positions, collectibles/QSBS/depreciation-recapture rules, and state or local taxes.
- Bracket thresholds change every year and with legislation. All dollar thresholds shown here are approximate, as of 2026.
- The NIIT figure is an approximation: the tool proxies MAGI with taxable income + gain, and because taxable income is after deductions, the proxy tends to understate MAGI — meaning NIIT can apply even when this tool does not flag it. The near-threshold caution partially mitigates this; always check your actual MAGI.
- US federal taxes only. State, local, and non-US taxes are out of scope.
- Not tax advice and no personalized recommendations — this tool never tells you to sell before or after one year; it only shows how the estimate differs between scenarios. Consult a qualified tax professional before acting on taxes.
- A tax estimate is a terminal output: it is not carried forward into other StockTools calculators. The ticker, if shown, is display-only continuity and never enters any formula.