CCal
United States

Capital Gains Tax Calculator

When you sell a capital asset — stocks, funds, crypto, or real estate that is not your home — for more than you paid, the gain is taxed, and the rate depends above all on how long you held the asset. A holding period of one year or less produces a short-term gain taxed at your ordinary income rate, the same rate that applies to your salary. More than one year produces a long-term gain taxed under the preferential schedule in IRC §1(h): 0%, 15%, or 20%, depending on how much taxable income you have in the year of the sale.

The long-term brackets are not applied to the gain alone. IRC §1(h) stacks your ordinary taxable income first, then fills the preferential brackets with long-term gains on top. That means a single long-term sale can straddle two or even three rates: part of it fills the remainder of the 0% bracket, more spills into the 15% bracket, and a very large gain can push the top slice into 20%. Netting rules under IRC §1222 also matter: you first net short-term against long-term losses and vice versa, and short-term losses offset short-term gains before anything else.

A second layer applies to higher earners: the net investment income tax (NIIT) under IRC §1411 adds 3.8% on the lesser of net investment income or the excess of modified adjusted gross income over a threshold ($200,000 single, $250,000 married filing jointly in recent years). The NIIT is not withheld and is easy to miss when planning a large sale.

This calculator stacks your ordinary taxable income, applies the 0%/15%/20% structure to your long-term gain, taxes the short-term gain at your ordinary marginal rate, and adds the NIIT if you exceed the threshold. Because the bracket breakpoints and the NIIT threshold are indexed and change annually, they are editable inputs — verify the current-year figures in the Form 1040 instructions or with a CPA, and treat the result as an educational estimate, not tax advice.

Advertisement

Calculate

$
Ordinary taxable income (wages, interest, minus deductions), excluding the sales below.
$
Net gains on assets held one year or less, after netting against short-term losses.
$
Net gains on assets held more than one year, after netting against long-term losses.
%
Your marginal income-tax bracket for ordinary income.
$
Taxable income (including gains) up to which long-term gains are taxed at 0%. Changes yearly — verify.
$
Above this taxable income the long-term rate becomes 20%. Changes yearly — verify.
$
$200,000 single / $250,000 married filing jointly in recent years; confirm the current figure.
Total tax on capital gainsincome tax on gains plus NIIT$7,100
Short-term gain tax22.0% ordinary rate$1,100
Long-term gain tax0% on $0 · 15% on $40,000 · 20% on $0$6,000
Net investment income tax (3.8%)applies to $0 above the threshold$0
Total gain sold$45,000
Effective tax rate on gains15.8%
After-tax proceeds of the gain$37,900
Advertisement

How the math works

  • Short-term gains (held one year or less) are taxed at your ordinary marginal income tax rate.
  • Long-term gains fill the preferential brackets of IRC §1(h) on top of ordinary taxable income: 0% up to the first breakpoint, 15% up to the second, 20% above it.
  • Net investment income tax (IRC §1411) = 3.8% of the lesser of net investment income or MAGI above the threshold.
  • Enter the current-year bracket breakpoints and NIIT threshold from the Form 1040 instructions; they are indexed annually.

Frequently asked questions

What is the difference between short-term and long-term capital gains?
Holding period. Assets sold one year or less after purchase produce short-term gains taxed at your ordinary income rate, which can reach 37%. Assets held more than one year produce long-term gains taxed at 0%, 15%, or 20% under IRC §1(h). The one-year mark is measured from the day after acquisition to the sale date.
How do the 0%, 15%, and 20% long-term brackets work?
Your ordinary taxable income fills the brackets first, and long-term gains stack on top. If your ordinary income is low, part of the gain can be taxed at 0%; as income rises, gains slide into 15% and eventually 20%. The breakpoints are indexed annually — check the current-year amounts in the Form 1040 instructions.
What is the net investment income tax?
A 3.8% tax under IRC §1411 on the lesser of your net investment income or the amount by which your MAGI exceeds a threshold — $200,000 single or $250,000 married filing jointly in recent years. It applies on top of the regular capital gains rates.
How do losses offset gains?
Under IRC §1222 you net short-term against short-term and long-term against long-term first, then net the two results against each other. Up to $3,000 of net capital loss can deduct against ordinary income each year, and the rest carries forward.
Does this apply to my home sale?
A main home gets a separate exclusion — $250,000 single / $500,000 married filing jointly of gain is excluded if you meet the ownership and use tests. Only the excess is taxable, and this calculator does not apply that exclusion.
Can I control which bracket my gain lands in?
Partly. Spreading sales across tax years, realizing losses before gains (tax-loss harvesting), and keeping ordinary income low can keep gains in the 0% or 15% bracket. The stacking rule means a large single-year gain can still push its own top slice to 20%.
Are state taxes included?
No. Most states tax capital gains as ordinary income with no preferential rate, and a few have their own rules. Add your state's rate on top of the federal figures shown here.

This calculator is an educational estimate, not tax advice. Bracket breakpoints, the ordinary rate schedule, and the NIIT threshold change annually, and netting, carryforwards, wash sales, and state taxes are not modeled. Verify current-year figures with the IRS Form 1040 instructions or a CPA.