Capital Gains Tax Calculator
Your sale
One sale, the complete federal answer — the 0/15/20% brackets applied slice by slice on top of your income, and the 3.8% NIIT when it actually applies.
Your cost basis — add improvements and selling fees under Refine
Line 15 on your 1040 — this sets your bracket, because the gain STACKS on top of it
How we calculate this
Long-term gains stack on top of your income. The 0/15/20% brackets don't apply to your gain in isolation — they apply to where the gain sits, stacked on top of your ordinary taxable income. For 2026 the breakpoints are $49,450 and $545,500 for single filers, $98,900 and $613,700 married filing jointly (Rev. Proc. 2025-32). A gain can span two rates, so we price it slice by slice. Most calculators multiply the whole gain by one rate; that's wrong in both directions, and the error grows with the gain.
Short-term gains are ordinary income. Held a year or less, the gain is taxed exactly like salary — so we compute the tax with the gain minus the tax without it on the 2026 brackets, never your marginal rate × the gain. Same incremental discipline as our student-loan tax-bomb model, different table.
The NIIT is the difference between right and wrong for exactly the people who need this tool. Above $200,000 MAGI ($250,000 joint), a 3.8% net investment income tax applies to the lesser of your investment income or your MAGI excess over the threshold (IRC §1411 — statutory, never inflation-indexed). We implement the lesser-of rule as written, and we treat this sale as your only investment income, which is labeled.
What we don't model: state capital-gains tax — most states tax gains as ordinary income and it can add thousands, so the headline says federal only. Also out of scope: multiple lots, wash sales, loss carryforwards, MFS and head-of-household filing (their breakpoints differ), collectibles and §1250 recapture rates, and qualified small business stock. One sale, priced correctly.
Real scenarios
The gain that half rides free: $1,582.50 on $20,000
Bought at $10,000, sold at $30,000 after more than a year, with $40,000 of taxable income (single). The gain occupies $40,000→$60,000 — and the first $9,450 of it sits under the $49,450 breakpoint at 0%. Only the remaining $10,550 is taxed, at 15%: $1,582.50 total, an effective 7.9% on the gain. A flat "15% × gain" calculator would have said $3,000 — almost double the real bill.
Selling one month too early costs $1,686
The same $20,000 gain with $100,000 of taxable income (single), sold at 11 months: it's ordinary income, and it crosses a bracket — $5,700 fills the rest of the 22% bracket, $14,300 lands in 24%, for $4,686. (Naive 22% × $20,000 says $4,400 — wrong even here.) Held past one year, the whole gain sits in the 15% long-term bracket: $3,000. Holding on saves $1,686 — that's the number to weigh against the risk of holding.
Where the NIIT kicks in: $5,640 on a $30,000 gain
A $30,000 long-term gain (bought $20,000, sold $50,000) on $223,900 of taxable income, single. The gain sits entirely in the 15% bracket: $4,500. But MAGI including the gain is about $270,000 — $70,000 over the $200,000 threshold, so the lesser-of rule taxes the full $30,000 gain at 3.8%: another $1,140. Total $5,640, an effective 18.8% — and the 3.8% is the part most people discover in April.