ComputeYard

The math, explained — built by a derivatives quant.

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. Rates as of the 2025 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.

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% rate set by your annual taxable income and filing status; 365 days or fewer is short-term, taxed at your marginal ordinary income 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 (15% LTCG bracket) 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
federal_rate = marginal_ordinary_rate              (short term)
             = LTCG bracket (0 / 0.15 / 0.20)       (long term)
federal_tax  = max(gain, 0) × federal_rate
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?
From the 2025 brackets for your filing status: 0% below the first threshold, 15% up to the second, and 20% above it, based on your annual taxable income.
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.

More calculators