Methodology: How the Calculator Works
The exact arithmetic behind every number our capital gains tax calculator produces — income-stacking, the 3.8% NIIT, short-term ordinary math, the §121 home-sale exclusion, and the 50-state add-on — each tied to the statute it comes from.
Figures reviewed & verified · 2026 tax-year basis · Author: CapGainsTaxCalc editorial desk
The calculator follows the same four steps as the IRS worksheet in Publication 550: it nets your gain (proceeds − basis), classifies it by holding period, and for long-term gains stacks the gain on top of your taxable ordinary income across the 0/15/20% bands under IRC §1(h). It then adds the 3.8% NIIT where MAGI crosses the §1411 threshold, applies the §121 exclusion for a qualifying home, and — if you pick a state — adds that state's top marginal rate. All math runs in your browser; no input is ever transmitted.
The four-step engine, in order
Every result is produced by pure, unit-tested functions that mirror the IRS long-term capital gains worksheet. In order:
- Net the gain. Proceeds − cost basis (adjusted basis for real estate).
- Classify the holding period. More than one year is long-term (IRC §1(h)); one year or less is short-term, taxed as ordinary income.
- Apply the rate. Long-term: stack the gain over taxable ordinary income across the 0/15/20% bands. Short-term: measure the true marginal ordinary-tax difference.
- Add surtaxes and state. The 3.8% NIIT over the §1411 threshold, plus the selected state's top marginal rate.
CHECK
How does the calculator compute long-term capital gains tax?
Long-term rates are not applied to the gain in isolation — the gain is stacked on top of your other taxable income, and only the portion that lands in each band is taxed at that band's rate. This is the mechanism of IRC §1(h), and it is why two people with the same gain can owe very different tax.
Find taxable ordinary income
First the calculator subtracts the standard deduction (IRC §63) from your entered ordinary income. The 2026 standard deduction figures used are projected and marked (est.):
| Filing status | Standard deduction (2026, est.) |
|---|---|
| Single | $16,100 (est.) |
| Married filing jointly | $32,200 (est.) |
| Head of household | $24,150 (est.) |
| Married filing separately | $16,100 (est.) |
Stack the gain across the 0/15/20% bands
The gain is placed above taxable ordinary income. Starting at that height, the calculator walks up the bands and taxes each slice of the gain at the rate of the band it falls in. The 2026 long-term breakpoints used (projected, est.):
| Filing status | 0% up to | 15% up to | 20% above |
|---|---|---|---|
| Single | $49,450 (est.) | $545,500 (est.) | over $545,500 |
| Married filing jointly | $98,900 (est.) | $613,700 (est.) | over $613,700 |
| Head of household | $66,200 (est.) | $579,600 (est.) | over $579,600 |
| Married filing separately | $49,450 (est.) | $306,850 (est.) | over $306,850 |
Worked example. Single filer, $90,000 ordinary income, $35,000 long-term gain. Taxable ordinary income = $90,000 − $16,100 = $73,900. The gain stacks from $73,900 to $108,900 — entirely inside the 15% band (which runs to $545,500), so:
| $35,000 × 15% | $5,250 |
| Federal long-term tax | $5,250 |
If that same filer had only $20,000 of ordinary income, part of the gain would sit in the 0% band and part in the 15% band — and the calculator would split it at the exact breakpoint.
How is the 3.8% Net Investment Income Tax applied?
On top of the long-term or short-term tax, high earners owe the Net Investment Income Tax under IRC §1411. The calculator adds 3.8% on the lesser of your net investment income (the gain) or the amount your modified adjusted gross income exceeds the statutory threshold.
| Filing status | MAGI threshold (§1411, statutory) |
|---|---|
| Single / Head of household | $200,000 |
| Married filing jointly | $250,000 |
| Married filing separately | $125,000 |
These thresholds are written into the statute and are not inflation-adjusted, so they are shown as exact figures, not estimates. The calculator approximates MAGI as your ordinary income plus the taxable gain; taxpayers with foreign-earned-income adjustments should treat the NIIT line as an estimate. See IRS Topic No. 559 for the full definition of net investment income.
How are short-term gains calculated?
A gain on an asset held one year or less is short-term and taxed as ordinary income (IRS Topic 409). Rather than apply a single top rate, the calculator computes the true marginal cost of adding the gain to your income:
Both terms run through the full 2026 ordinary brackets (10% / 12% / 22% / 24% / 32% / 35% / 37%), so the result reflects exactly which brackets the gain pushes into — not an assumption that all of it is taxed at your top rate. The 2026 ordinary bracket thresholds used are projected and marked (est.); they are owner-verifiable against the final IRS release. Holding period itself is derived from the purchase and sale dates you enter: the calculator treats a sale as long-term only when it occurs after the one-year anniversary of purchase, consistent with the IRS "more than one year" rule.
How does the §121 home-sale exclusion work here?
For a primary residence, IRC §121 lets you exclude gain from tax if you owned and used the home as your main residence for at least two of the five years before sale. When you mark the property as a qualifying primary residence, the calculator subtracts the exclusion before any rate is applied:
| Sale proceeds | proceeds |
| − Adjusted basis (purchase + improvements + selling costs) | basis |
| = Raw gain | proceeds − basis |
| − §121 exclusion (up to $250k single / $500k MFJ) | exclusion |
| = Taxable gain | max(0, raw gain − exclusion) |
The exclusion caps are $250,000 (single, HOH, MFS) and $500,000 (married filing jointly). Adjusted basis follows IRS Publication 523: original purchase price plus capital improvements plus selling costs. Only gain above the exclusion is taxed, at long-term rates. The calculator does not model partial exclusions for a work/health-related move, or depreciation recapture on a home previously used as a rental — those require professional review.
How is state capital gains tax added across all 50 states?
Most states tax capital gains as ordinary income, and nine levy no such tax at all. When you select a state, the calculator applies that state's top marginal income-tax rate to the full taxable gain:
These are 2026 top-marginal figures, owner-verifiable and marked as estimates in the tool. This is deliberately a simplification: it does not model each state's own brackets, deductions, standard exemptions, or preferential capital gains treatment (for example, a state that partially excludes long-term gains, or one — such as Washington — that taxes only high-value gains above a floor). It gives a conservative upper-bound state add-on. The nine no-tax jurisdictions (Alaska, Florida, Nevada, New Hampshire, South Dakota, Tennessee, Texas, Washington's wage income, Wyoming) return zero. For a precise state figure, use the state hub pages, which explain each state's rules individually.
Where does the data come from?
Every rate, threshold, and rule in this calculator is drawn from primary government sources — the statute itself and IRS guidance — never from secondary summaries. Bracket and standard-deduction dollar figures for 2026 come from the annual inflation-adjustment IRS Revenue Procedure for the tax year; where the final 2026 Revenue Procedure figures were not yet released at review time, we use the projected inflation-adjusted amounts and mark them (est.). The statutory rules — the 0/15/20% structure, the NIIT, the §121 exclusion — come from the Internal Revenue Code via the Cornell Legal Information Institute (LII).
Primary sources (linked, not just named)
- 26 U.S.C. §1(h) — capital gains rates
- 26 U.S.C. §1411 — 3.8% NIIT
- 26 U.S.C. §121 — home-sale exclusion
- 26 U.S.C. §63 — standard deduction
- IRS Topic No. 409 — Capital Gains and Losses
- IRS Topic No. 559 — Net Investment Income Tax
- IRS Publication 550 — Investment Income
- IRS Publication 523 — Selling Your Home
Does any of my data leave the browser?
The entire tax engine is plain JavaScript that executes on your device. Your income, sale prices, dates, and filing status are never transmitted to a server, stored in a database, or logged by the calculator. When you create a shareable link, your inputs are encoded into the URL on your device — nothing is sent anywhere until you choose to share that link. This is a structural privacy guarantee: there is no server-side endpoint that receives your figures.
Note that this page, like the rest of the site, serves advertising through Google AdSense, which sets its own cookies governed by our privacy policy. Those ads never receive the numbers you type into the calculator.
How are figures reviewed and corrected?
Figures were reviewed on July 20, 2026. We re-verify every rate and threshold whenever the IRS releases a new Revenue Procedure or updates a relevant publication, and at minimum once per tax-filing season. Each review checks the calculator's constants against the primary sources above and re-runs the engine's unit tests.
Correction policy. If we find — or you report — an error in a rate, threshold, or formula, we fix it promptly, update the "figures reviewed" date, and note material corrections. Because several 2026 dollar figures are projected pending the final IRS release, any amount marked (est.) is expected to be reconciled to the official number when it publishes; the statutory rules (0/15/20% structure, the §1411 thresholds, the §121 caps) are fixed by law and do not change with inflation. Spotted something off? Reach us via the contact page.
Methodology questions, answered
How does the calculator compute long-term capital gains tax?
It stacks the gain on top of your taxable ordinary income and slices it across the 0/15/20% bands under IRC §1(h).
First it subtracts the standard deduction from your ordinary income. Then it places the long-term gain above that figure and taxes each slice at the rate of the band it falls into, summing the slices. Because the gain sits above your ordinary income, a low earner can have part of the same gain taxed at 0% and part at 15%.
How is the 3.8% NIIT applied?
If MAGI exceeds the §1411 threshold — $200k single/HOH, $250k joint, $125k MFS — the calculator adds 3.8% on the lesser of the net gain or the excess over the threshold. Below the threshold, no NIIT is added. These thresholds are statutory and not inflation-adjusted.
How are short-term gains calculated?
As ordinary income, using the true marginal difference: ordinary tax on your income with the gain minus ordinary tax without it, run through the full 2026 brackets. This reflects exactly which brackets the gain pushes into rather than assuming a flat top rate (IRS Topic 409).
How does the calculator handle the home-sale exclusion?
For a qualifying primary residence it subtracts the §121 exclusion — up to $250k single, $500k MFJ — before applying any rate. Only gain above the exclusion is taxed, at long-term rates, and basis is adjusted for improvements and selling costs per IRS Pub 523.
How is state capital gains tax added?
It multiplies the taxable gain by the selected state's top marginal income-tax rate for 2026, since most states tax gains as ordinary income. Nine states return zero. This is a conservative estimate that does not model state-specific brackets, deductions, or preferential rates.
Does any of my data leave the browser?
No. All computation runs client-side. Your figures are never transmitted, stored, or logged by the calculator. A shareable link encodes your inputs in the URL on your own device only.
This methodology is the credibility backbone the rest of the site points to. When a state hub, the crypto page, or the home-sale guide cites "the calculator's method," this is the page they mean. Return to the calculator to run your own numbers, or read the 2026 rate tables for the underlying brackets.