Capital Gains Calculator — Methodology
Last updated: October 2026
How This Calculator Works
The Capital Gains Calculator works lot by lot. For each position you enter a purchase price, a current value, and a purchase date. It sorts each gain or loss into short-term or long-term, nets them the way Schedule D does, works out the federal tax with the IRS capital gains worksheet, adds the Net Investment Income Tax where it applies, adds state tax, and shows what you would save by waiting until every short-term lot becomes long-term.
It also reports how much long-term gain you could realise at a 0% federal rate, which is the figure most people are unaware of.
Inputs and Assumptions
- Purchase price and current value: The difference is the unrealised gain for that lot.
- Purchase date: Every lot is assumed sold today. A gain is long-term when the lot was held more than one year: counting starts the day after purchase and includes the sale day (IRS Publication 550), in calendar months, so a lot bought on 15 January is long-term from 16 January of the next year, and one bought on the last day of February from 1 March. A lot with no purchase date, or one after today, is left out until it has one.
- Ordinary income: Your other income before the standard deduction (wages, interest, pensions). Short-term gains are added to it, and long-term gains stack on top.
- Filing status and state: Select the federal bracket thresholds, the NIIT threshold, and the state rate.
Assumptions: the basic standard deduction for your filing status, no other deductions or credits, no qualified dividends, and every lot sold in the same tax year.
Formula
isLongTerm = saleDate >= (purchaseDate + 1 day) + 1 calendar year // Schedule D netting (IRC §1222): each character nets on its own first netShortTerm = shortTermGains − shortTermLosses // line 7 netLongTerm = longTermGains − longTermLosses // line 15 combined = netShortTerm + netLongTerm // line 16 lossDeduction = combined < 0 ? min(−combined, $3,000; $1,500 MFS) : 0 // line 21, IRC §1211(b) netCapitalGain = min(netLongTerm, combined) if both > 0, else 0 // 0/15/20% rates // Federal: Qualified Dividends and Capital Gain Tax Worksheet taxableIncome = ordinaryIncome + (combined > 0 ? combined : −lossDeduction) − standardDeduction ordinaryPart = taxableIncome − netCapitalGain // short-term gains sit here, at ordinary rates // the capital gain fills the 0% band above ordinaryPart, then 15%, then 20% federalTaxOnGains = tax(with sales) − tax(without sales) // 0 when the year nets to a loss // Net Investment Income Tax (IRC §1411) niit = 3.8% × min(max(0, combined), MAGI − niitThreshold) totalTax = federalTaxOnGains + niit + stateTax // "Wait" scenario: every lot treated as long-term, same prices, same tax year taxSavingsFromWaiting = totalTaxSellNow − totalTaxIfWait // 0% room: unused standard deduction, then the 0% band above ordinary income + net short-term gain headroom = max(0, deduction − ordinaryCharacter) + max(0, zeroBandTop − max(0, ordinaryCharacter − deduction))
Data Sources
- IRS Revenue Procedure 2025-32 — 2026 long-term capital gains brackets (0% to $49,450 single / $98,900 MFJ; 15% to $545,500 / $613,700), ordinary rate schedules and standard deductions.
- Form 1040 instructions (2025), Qualified Dividends and Capital Gain Tax Worksheet — how long-term gains stack on top of ordinary income, short-term gains included. The 2026 worksheet is not yet published; the calculator applies the 2025 method with the 2026 thresholds.
- Internal Revenue Code §§1211(b), 1212(b) and 1222; Schedule D instructions (2025) — netting by character (lines 7, 15 and 16), the $3,000 ($1,500 married filing separately) limit on a net loss against other income (line 21), and the Capital Loss Carryover Worksheet: a loss carried forward keeps its short-term or long-term character, and the part of the $3,000 that taxable income could not absorb carries too.
- IRS Publication 550 (2025), Holding Period; Rev. Rul. 66-7 — more than one year, counted from the day after purchase in calendar months.
- Internal Revenue Code §1411 — Net Investment Income Tax, 3.8% above the MAGI thresholds.
- State revenue departments, tax year 2026 (Tax Foundation's 2026 state rate table as cross-check) — state income-tax brackets applied to capital gains. States without confirmed 2026 figures use their latest published schedule: California, Idaho, North Dakota, Rhode Island, Vermont and Wisconsin (2025).
- Washington capital gains excise, RCW 82.87 and the Washington Department of Revenue — Washington taxes no income but taxes long-term capital gains: 7% above the standard deduction ($278,000 for 2025), plus 2.9% on taxable gains above $1,000,000 from 2025 (RCW 82.87.040). Real estate is exempt (RCW 82.87.050) and short-term gains are not taxed. The base is the federal net long-term gain with gains and losses on exempt real estate taken out (RCW 82.87.020(1)), so a short-term loss does not reduce it.
Limitations
- Holding period is measured against today's date. A lot within days of its one-year mark will change treatment as the date rolls over.
- Does not model wash sales, or losses carried in from earlier years. The carryover to next year is shown, but its tax value next year is not.
- A net loss lowers the tax on your other income; the calculator shows the deduction and the carryover, not that saving, and it reports the tax on gains as zero rather than negative. State tax ignores the loss deduction.
- Tax is figured on the exact rate schedule, not the IRS Tax Table's $50 bands, so it can differ from a return by a few dollars.
- Uses the basic standard deduction only: not itemized deductions, the additional amount for age 65 or blind, or the 2025–2028 senior deduction. With a larger deduction, more of your gain is sheltered.
- Does not model the Section 121 primary-residence exclusion, Section 1031 exchanges, or Qualified Opportunity Zone deferral.
- Does not model collectibles (28% rate) or Section 1250 unrecaptured depreciation (25% rate) on real estate.
- Assumes every lot is sold in the same tax year, so it does not model multi-year gain spreading.
- State treatment is simplified to a single rate; some states tax gains at rates that vary by income or exclude them entirely.
- Washington: married couples share one standard deduction even on separate returns (RCW 82.87.060), so for married filing separately the calculator assumes an equal split; a joint return applies the $1 million threshold to the couple's combined gains. Washington's charitable and family-business deductions are not modelled, and the 2025 deduction is used until Washington publishes the next one.
- Does not model the Alternative Minimum Tax, or the effect of realised gains on ACA subsidies and IRMAA surcharges. If either applies to you, model those separately.
Last Updated
July 2026 — Methodology page published.
October 2026 — Engine moved from the 2024 figures to 2026 (Rev. Proc. 2025-32), via the shared tax data module.
14 October 2026 — Primary-source audit fixes: losses now net by character before crossing over, with the $1,500 limit for married filing separately and the carryover by character; short-term gains now sit under long-term gains in the stack; a standard deduction your income leaves unused now shelters gains (in the tax, the wait scenario and the 0% room); the long-term date follows the IRS counting rule; and an investment without a purchase date is left out instead of stopping the calculator.
This calculator is for educational purposes only and does not constitute financial advice. Results are estimates from the numbers you enter. Check with a licensed professional before you act on them. Full disclaimer →