Capital Gains Tax Calculator — ST vs LT + NIIT + State (2026)
Drop cost basis, sale price, holding period, AGI, filing status, and optional state rate — get federal capital-gains tax (short-term at ordinary brackets, long-term at 0/15/20%), NIIT 3.8% if applicable, and the held-vs-sold counterfactual showing what you'd save if you held to 12 months.
- Instant result
- Private — nothing saved
- Works on any device
- AI insight included
Capital Gains Tax Calculator
You might also need
What is Capital Gains Tax?
Capital gains tax is the federal (and usually state) tax owed on the profit when you sell a capital asset for more than you paid for it. Stocks, mutual fund shares, bonds, real estate, cryptocurrency, collectibles, and a private business interest all count as capital assets under IRC §1221. The taxable amount is the gain — sale price minus cost basis — not the gross proceeds. If you bought Apple at $50 and sold at $200, you owe tax on $150 per share, not on $200.
The single most important variable is holding period. Held the asset for more than 12 months? It is a long-term capital gain, taxed at preferential federal rates of 0%, 15%, or 20% depending on your taxable income. Held it for 12 months or less? It is short-term, taxed at your ordinary-income rate, which tops out at 37% federal in 2026. On a $50,000 gain at a 24% ordinary bracket versus a 15% long-term bracket, the holding-period difference is $4,500. That is the “wait one more day” tax math — and it is real.
Layered on top of the base rate are several surcharges that catch high earners off guard. The 3.8% Net Investment Income Tax (NIIT) applies above $200,000 of MAGI for singles or $250,000 for joint filers. State capital-gains tax stacks on most states’ ordinary-income brackets, ranging from 0% in nine no-income-tax states to 13.3% in California. Washington added a new 7% long-term capital-gains tax on gains above $250,000 starting in 2022. The headline 15% federal long-term rate is almost never the all-in number actually paid.
The Formula and Methodology
The IRS computes capital gains tax in two parallel buckets, then combines them with ordinary income for the final return. The calculator walks through the same logic.
Cost basisis what you paid plus any commissions and acquisition fees. For inherited assets, basis is the fair market value at the decedent’s date of death (IRC §1014) — the “stepped-up basis” rule. If your parent bought Microsoft at $20 and it was worth $400 the day they died, your basis is $400. Selling at $410 means a $10 gain, not a $390 gain. This is the most valuable tax break in the entire estate-planning toolkit and is why holding appreciated assets to death often beats selling pre-death.
Long-term capital-gains brackets, 2026 projections.Single filers: 0% up to $48,350 taxable income, 15% from there to $533,400, 20% above. Married filing jointly: 0% up to $96,700, 15% to $600,050, 20% above. Head of household: 0% up to $64,750, 15% to $566,700, 20% above. The 0% bracket is the most underused planning tool in the code — retirees with low taxable income can realize long-term gains at a literal zero rate, harvesting basis step-ups year by year.
NIIT (Net Investment Income Tax)is a 3.8% surtax on net investment income (gains, dividends, interest, passive rental income) above the MAGI threshold — $200,000 single, $250,000 MFJ, $125,000 MFS. The threshold is statutory and not inflation-indexed, so it pulls more taxpayers in every year. NIIT applies to the lesser of net investment income or (MAGI minus threshold). A $100,000 long-term gain at a $300,000 MAGI MFJ household: NIIT applies to the full $100,000 (since MAGI excess of $50,000 is less than the $100,000 gain), adding $3,800 to the federal bill on top of $15,000 of base long-term tax.
Primary-residence exclusion (IRC §121).Single filers can exclude up to $250,000 of gain from selling a primary residence; joint filers up to $500,000. To qualify you must have owned and lived in the home as a primary residence for at least 2 of the last 5 years. This exclusion is per sale, not lifetime — you can use it repeatedly, no more than once every 2 years. Sale of a second home, investment property, or rental does not qualify and is fully taxable as capital gain.
Worked Example
Take a common case: you sold $50,000 of a long-held index fund for a gain, with $150,000 of other taxable income (wages, dividends) and you file single.
Step 1: Stack the gain on top of ordinary income. Your taxable income with the gain is $150,000 + $50,000 = $200,000. The long-term bracket thresholds for single in 2026: 0% to $48,350, 15% to $533,400. Your $200,000 taxable income sits firmly inside the 15% bracket, so the entire $50,000 gain is taxed at 15% federal.
Step 2: Apply NIIT.Your MAGI is $200,000 — exactly at the single-filer threshold. NIIT applies on the lesser of $50,000 net investment income or $0 of MAGI-excess. The MAGI-excess is zero, so NIIT is zero. If your MAGI were $210,000 instead, NIIT would apply on $10,000 (the excess) at 3.8% = $380 extra.
Step 3: State tax.If you live in California, the full $50,000 gain is taxed as ordinary income at your state marginal rate — roughly 9.3% at $200,000 of taxable income = $4,650. If you live in Florida or Texas, zero state tax.
Total federal + state burden.Federal long-term tax = $50,000 × 15% = $7,500. NIIT = $0. State (CA) = $4,650. Total tax = $12,150 = 24.3% effective rate on the gain. Same gain in Texas: $7,500 federal only, 15.0% effective. Domicile matters enormously for large realizations.
The short-term counterfactual.If you had sold at month 11 instead of month 13, the same $50,000 would be taxed at your ordinary marginal rate. At $150,000 of other income, your marginal federal bracket is 24%. Tax owed: $50,000 × 24% = $12,000 federal, plus CA $4,650 = $16,650 total. Waiting two extra months saved $4,500. That is the long-term-vs-short-term holding-period bonus.
Common Mistakes and Edge Cases
Capital-gains planning is dense with rules that look small but compound into real money:
- Forgetting to track lot-level basis.If you bought a stock or fund over many years, each purchase is a separate “lot” with its own basis and acquisition date. Brokers default to FIFO (first-in first-out) when you sell, which usually realizes the most gain. Specifying lots by hand — sell the highest-basis or most-recent lot — lets you control the tax. Most brokers allow lot selection up to settlement; after that it is permanent.
- Wash-sale rule.Under IRC §1091, if you sell at a loss and buy the same or “substantially identical” security within 30 days before or after the sale, the loss is disallowed. It is not lost — the disallowed amount adds to the basis of the replacement security — but you cannot use it to offset gains this year. Wash-sale rules apply to losses only. Note: the IRS has not formally extended wash-sale rules to crypto yet, but proposed legislation could change that.
- Crypto is property, not currency.IRS Notice 2014-21 treats cryptocurrency as property. Every sale, swap, or use to buy goods is a taxable event with a holding-period-determined gain or loss. Tracking basis across a few hundred trades is brutal without a crypto tax service. Form 1099-DA reporting from exchanges is mandatory starting 2025, which closes the “the IRS doesn’t know” gap.
- Forgetting the §121 use test. The primary-residence exclusion requires both ownership AND use for 2 of the last 5 years. A house you rented out for 4 years and lived in for 1 does not qualify. Partial exclusion is available for moves driven by a job change, health, or unforeseen circumstance, prorated by months of qualifying use.
- Loss carryforwards lapsing at death.Capital losses are deductible up to $3,000 a year against ordinary income, with excess carrying forward indefinitely. But they do NOT pass to your heirs — unused carryforwards die with you. If you have large carryforwards and modest realized gains, consider accelerating gain realization in your final years to consume them.
- Mutual-fund capital-gains distributions.Even if you don’t sell, mutual funds (not ETFs) often distribute realized internal gains in December. You owe tax on these in the year distributed, with the holding period tied to the fund’s internal sales (usually long-term). A new investor who buys a fund in November can owe tax on gains realized before they owned it — the “buying a tax bill” pitfall. Check the year-end estimate before buying late in the year.
Strategy and Comparison
Long-term capital gains is the most-favored income in the US tax code. Strategy clusters around three goals: extend holding period, harvest losses against gains, and time realizations to optimal brackets.
Loss harvestingis the highest-ROI tactic for taxable brokerage investors. Realize losses in down years against realized gains; deduct up to $3,000 of net loss against ordinary income; carry the rest forward indefinitely. The wash- sale rule forces a 30-day gap before re-buying the same security, but you can immediately buy a similar fund (Vanguard S&P 500 for Fidelity S&P 500, or Schwab Total Market for Vanguard Total Market) without triggering wash-sale — functionally identical exposure with the loss locked in.
Gain harvesting in the 0% bracketis the inverse strategy for retirees. If your taxable income (after deductions) is below the 0%-bracket ceiling — $48,350 single, $96,700 joint in 2026 — long-term gains stack into the 0% bracket tax-free. Selling appreciated positions and immediately re-buying them steps up your basis at zero federal cost. Combine with Roth conversions for the full retirement-tax-strategy stack.
Charitable giving with appreciated stock. Donating long-term-held appreciated stock directly to a qualified charity gets you a deduction at fair market value AND skips the capital-gains tax entirely (the charity sells tax-free). On $50,000 of donated stock with $40,000 of embedded gain at 24% combined federal plus state long-term rate, you save $9,600 of capital-gains tax plus get the $50,000 itemized deduction. Donor-advised funds make this easy at scale.
For employees with RSUs, stock options, or ESPP grants, capital-gains math is layered on top of compensation-income recognition. The RSU tax calculator and ISO / NSO calculator handle the basis-tracking and qualifying-disposition rules that vanilla capital-gains math misses. For broader after-tax retirement planning, pair this calculator with the after-tax income calculator and the retirement savings calculator to model the full lifetime tax bill.
Related Calculators
Capital-gains tax interacts with nearly every other tax-planning tool. Run these alongside:
- Tax bracket calculator— your marginal ordinary-income rate is what applies to short-term gains.
- RSU tax calculator— basis tracking for restricted stock units is different and easy to get wrong.
- ISO / NSO stock options calculator — handles qualifying-disposition rules that vanilla capital-gains math ignores.
- After-tax income calculator — model your year-end total income (wages plus realized gains) for bracket planning.
- Retirement savings calculator — long-run tax drag on a taxable portfolio is a material variable in retirement-cash-flow modeling.
Frequently Asked Questions
The most common questions we get about this calculator — each answer is kept under 60 words so you can scan.
What's the difference between short-term and long-term capital gains?
Holding period is the dividing line. ≥1 year (≥12 months) = long-term, taxed at preferential rates (0/15/20%). <1 year = short-term, taxed at ordinary income rates (up to 37% federal). The single most important holding-period decision is whether to push to the 12-month mark — going from a 24% ordinary bracket to a 15% LT bracket on a $30K gain saves $2,700.What are the 2026 long-term capital-gains brackets?
Approximate 2026 projections (2024 inflation-indexed). Single: 0% up to $48,350 taxable, 15% up to $533,400, 20% above. Married Filing Jointly: 0% up to $96,700, 15% up to $600,050, 20% above. Head of Household: 0% up to $64,750, 15% up to $566,700, 20% above. The 0% bracket is a powerful planning tool for retirees with low taxable income.What is NIIT (Net Investment Income Tax)?
NIIT is a 3.8% federal surtax on net investment income (capital gains, dividends, interest, rental income) when your MAGI exceeds the threshold. Thresholds (statutory, NOT inflation-adjusted): single $200K, MFJ $250K, MFS $125K, HoH $200K. NIIT applies to the LESSER of (a) net investment income or (b) MAGI minus threshold. Realized capital gains push you into NIIT range fast — it's a separate calculation from regular cap-gains tax.Are capital losses deductible?
Yes — up to $3,000/year deductible against ordinary income (MFS halves this to $1,500). Excess losses carry forward indefinitely. Loss harvesting strategy: realize losses in down years to offset realized gains, then carry remaining losses forward to offset future gains. Be aware of the 30-day wash-sale rule — selling for a loss and buying back the same security within 30 days disallows the loss.How is the gain calculated on inherited assets?
Inherited assets get a STEPPED-UP BASIS at the decedent's date of death (IRC §1014). If your parent bought stock for $10 and it's worth $100 when they died, your basis is $100 — selling at $105 means you have a $5 gain, not $95. This is one of the most valuable tax breaks in the code, and is why holding appreciated assets to death (rather than selling pre-death) is the optimal strategy for estate planning when income is sufficient.What about wash-sale rules?
IRS wash-sale rule (IRC §1091) disallows a capital LOSS if you buy the same or 'substantially identical' security within 30 days before OR after the sale. The loss isn't lost — it's added to the basis of the replacement security. Wash-sale rules apply to losses only, not gains. They apply within retirement accounts (IRAs) for trades involving the same person.Do real estate sales trigger capital gains tax?
Yes, with a HUGE exception for primary residences. IRC §121 lets single filers exclude up to $250K of gain on primary-residence sales ($500K joint), provided you owned and used the home as primary residence for 2 of the last 5 years. Investment properties and second homes don't qualify — those gains are fully taxable (LT or ST per holding period). 1031 exchange for investment property can defer gains by rolling into a like-kind property.Does my state tax capital gains?
Most states tax capital gains as ordinary income at state rates (CA 13.3% top, NY 10.9%, NJ 10.75%). Nine states have NO state income tax and therefore no state cap-gains tax: AK, FL, NV, NH, SD, TN, TX, WA, WY. Washington added a new 7% tax on long-term gains above $250K starting 2022 (only on LT, not ST). New Hampshire taxes only interest + dividends. Tennessee phased out its investment tax in 2021.What if I have both gains and losses in the same year?
Aggregate by holding-period bucket. Step 1: Net short-term gains and short-term losses → net short-term result. Step 2: Same for long-term → net long-term result. Step 3: If both are positive, ST taxed at ordinary rates + LT at preferential rates. Step 4: If one is negative, it offsets the other; net negative carries forward (capped at $3K/yr against ordinary income).Can I avoid capital-gains tax by gifting appreciated stock?
Yes — partly. Gifting appreciated stock to charity gets you a deduction at the asset's FAIR MARKET VALUE without realizing the gain. The charity sells tax-free (it's a charity). This is a 2-for-1 tax win: avoid cap-gains + get a charitable deduction. Gifting to family transfers your basis to them (no step-up); they pay the gain when they sell. Only death triggers the step-up.What about cryptocurrency capital gains?
Treated as property for federal tax purposes (IRS Notice 2014-21). Each crypto sale or trade is a taxable event — short-term or long-term based on holding period from acquisition. Selling at a loss for tax purposes is allowed but be aware of wash-sale rules (currently NOT applied to crypto by IRS, but proposed for future legislation). Track basis carefully — crypto-to-crypto trades create gains; the IRS now requires Form 1099-DA from exchanges starting 2025.When are capital gains taxes due?
Capital gains are realized and taxed in the year of sale. Federal tax owed is due April 15 of the following year (Q4 estimated payments due Jan 15 if you owe enough to trigger underpayment). For large gains (>$10K), file Q4 estimated to avoid the IRS underpayment penalty — the safe harbor is paying either 100%/110% of prior-year liability or 90% of current-year liability. Check IRS Pub 505 for thresholds.