Tax guide
How to calculate capital gains tax (federal formula)
Updated 2026-08-18 · Educational only — not tax advice
The basic federal formula is: capital gain equals sale proceeds minus adjusted cost basis minus selling expenses. Proceeds are what you received on sale. Adjusted basis starts with what you paid and can increase for commissions, reinvested dividends, or capital improvements, and can decrease for depreciation claimed on investment property.
Once you have net gain, classify the holding period. More than one year is generally long-term (0%, 15%, or 20% federally for most assets). One year or less is generally short-term and uses ordinary rates. Then layer NIIT if MAGI exceeds the threshold, and state tax if your state taxes the gain. For current brackets see our 2026 capital gains rates guide; for the 3.8% surtax see the NIIT article.
Gain stacking
Long-term gains are stacked on top of your other taxable income. Part of a large gain can fall in the 0% bracket, part in 15%, and part in 20%. That is why entering approximate taxable income before the gain matters in the calculator — the same $50,000 gain is not taxed the same for every filer.
Enter buy price, sell price, quantity, dates, filing status, income, and state in the free calculator to see federal tax, NIIT, state tax, effective rate, and after-tax proceeds. Estimates are educational only.
