US Capital Gains Tax Calculator
Estimate the federal (and optional state) capital gains tax on a single stock sale, and see your net proceeds, after-tax gain and effective tax rate. Updated for the 2026 US tax year. Federal estimate (plus an optional flat state rate); short-term gains use the marginal rate you enter. Verify current figures before filing.
Educational estimate only, not investment, tax, or financial advice or a recommendation to buy or sell any security. Investing and options involve risk of loss; verify independently. By using this tool you accept our Terms and Disclaimer.
How it works
Your gain is (sell price − buy price) × shares. How it's taxed depends on
how long you held: more than 365 days is long-term, taxed
at the preferential 0% / 15% / 20% rates; 365 days or fewer
is short-term, taxed at your marginal ordinary income rate.
For a long-term gain, enter your taxable income excluding this gain. The gain then stacks on top of that income across the brackets, so a gain that spans a threshold is split (part at 0%, part at 15%, and so on) rather than taxed at a single flat rate. The headline rate shown is the resulting blended rate.
An optional flat state rate is applied on top. A loss (gain ≤ 0) produces zero tax here. This is a back-of-envelope estimate: it ignores the 3.8% Net Investment Income Tax, wash-sale rules and capital-loss offsets or carryforwards.
Worked example
Buy 100 shares at $50 and sell at $90, held 800 days (long-term), filing single with $100,000 taxable income excluding the gain (so the $4,000 gain stacks into the 15% band) and a 5% state rate:
- Gain = ($90 − $50) × 100 = $4,000.
- Federal tax = $4,000 × 15% = $600; state tax = $4,000 × 5% = $200.
- Total tax = $800; effective rate = $800 / $4,000 = 20%.
- Net proceeds = $90 × 100 − $800 = $8,200; after-tax gain = $3,200.
The formula
term = "long" if holding_period_days > 365 else "short"
gain = (sell_price − buy_price) × shares
short term: federal_tax = max(gain, 0) × marginal_ordinary_rate
long term: federal_tax = stack the gain on taxable_income (excl. gain)
across the 0 / 15 / 20% bands, summing tax per band
federal_rate = federal_tax / max(gain, 0) (blended; 0 if gain ≤ 0)
state_tax = max(gain, 0) × state_rate
total_tax = federal_tax + state_tax
net_proceeds = sell_price × shares − total_tax
effective_rate = total_tax / gain (0 if gain ≤ 0)
FAQ
- What's the difference between long-term and short-term?
- Holding more than 365 days qualifies for the preferential long-term rate (0%, 15% or 20%). Holding 365 days or fewer is short-term and taxed at your ordinary marginal income rate.
- How is my long-term rate chosen?
- Enter your taxable income excluding this gain; the gain stacks on top across the 2026 brackets for your filing status (0% below the first threshold, 15% up to the second, 20% above), so a gain spanning a threshold is split across rates. The rate shown is the resulting blended rate.
- Does this include state tax or NIIT?
- You can add a flat state rate. It does not include the 3.8% Net Investment Income Tax, wash-sale rules or loss carryforwards. It's an estimate, not tax advice.
- Who pays the 3.8% NIIT?
- The Net Investment Income Tax adds 3.8% on investment income, including capital gains, for higher earners, above roughly $200,000 modified AGI (single) or $250,000 (married filing jointly). These thresholds are not inflation-adjusted. This tool does not add it, so add 3.8% yourself if you are over the threshold.
- What is the 0% capital gains bracket?
- For the 2026 tax year, long-term gains are taxed at 0% federal if your taxable income is up to $49,450 (single) or $98,900 (married filing jointly); above that it is 15%, then 20% at the top bracket.
Related calculators
Embed this calculator on your site (free)
Paste this HTML where you want the calculator to appear. It loads live from ComputeYard, stays up to date automatically, and includes a link back.