How it works
The same rules the calculator uses, in plain language — then jump back up and estimate your sale.
How capital gains tax is calculated in the United States
A capital gain is the profit you realise when you sell a capital asset — such as stocks, ETFs, mutual funds, cryptocurrency, real estate, or collectibles — for more than your adjusted cost basis. The IRS taxes realised gains; unrealised paper gains in a brokerage account are generally not taxable until you sell. That timing flexibility is why planning around holding periods and income brackets can matter so much.
The basic federal formula is straightforward: capital gain equals sale proceeds minus adjusted cost basis minus selling expenses. Adjusted basis starts with what you paid and can increase for commissions, reinvested dividends, or capital improvements (for real estate), and can decrease for depreciation claimed on investment property.
Short-term vs long-term capital gains
The single most important federal factor is the holding period. Assets held 365 days or less generally produce short-term capital gains taxed as ordinary income at rates up to 37%. Assets held more than one year generally qualify for preferential long-term rates of 0%, 15%, or 20%, depending on your taxable income and filing status.
If you are within about 30 days of crossing the one-year mark, waiting can convert a short-term gain into a long-term gain and materially reduce federal tax. Our calculator flags that cliff and estimates the difference so you can see the trade-off before you sell.
Federal brackets, NIIT, and state tax layers
Long-term gains are stacked on top of your other taxable income. That “gain stacking” method means part of a large gain can fall into the 0% bracket, part into 15%, and part into 20%. Short-term gains simply increase ordinary taxable income and move through the progressive ordinary brackets.
High earners may also owe the 3.8% Net Investment Income Tax under IRC Section 1411 when MAGI exceeds the applicable threshold. NIIT stacks on top of the regular capital gains tax and can push the effective top federal long-term rate to 23.8%.
State tax is a separate layer. Some states impose no income tax on capital gains. Others use flat rates or tax gains as ordinary income under graduated brackets. A few — notably Washington, North Dakota, and Montana — apply special capital gains rules. Combined federal-plus-state effective rates can exceed 37% for top earners in high-tax states such as California.
Asset-class rules that change the math
Not every asset uses the same maximum rate. Collectibles can face a 28% long-term federal ceiling. Primary residence sales may qualify for the Section 121 exclusion of up to $250,000 ($500,000 MFJ). Investment real estate can trigger depreciation recapture taxed at up to 25%. Qualified Small Business Stock may qualify for a Section 1202 exclusion after a five-year hold — though state conformity varies.
Cryptocurrency is treated as property. Trades, swaps, and spending crypto can each be taxable events. Wash-sale disallowance currently applies more clearly to securities than to crypto, which is an important planning distinction for loss harvesting.
How to use this free calculator
Enter your asset type, buy and sell prices, quantity, dates, filing status, approximate taxable income before the gain, and state. The tool estimates federal tax, NIIT when applicable, state tax, total tax owed, effective rate, and after-tax proceeds — then suggests personalised optimisation ideas such as holding for long-term treatment or checking Section 121 eligibility.
Use the state hub to open a calculator pre-selected for your state, or jump to asset-specific pages for stocks, crypto, real estate, and collectibles. For the calculation methodology, data sources, and update process, see our methodology page. Estimates are informational only; confirm figures with IRS publications and a licensed tax professional before filing.
Step 1
Your tax profile
Year, filing status, state, and income before the gain.
Step 2
What you sold
Asset type, optional name, prices, and quantity.
Step 3
Buy and sell dates
We classify short-term vs long-term from those dates.
Explore calculators
Jump by state, asset, or filing status — or read how we model the numbers.
