Capital Gains Tax Calculator
Legal basis: IRC §1(h) (capital gains rates and brackets); IRC §1222 (short-term vs long-term holding periods); IRC §1411 (net investment income tax) · checked 2026-10-04 · Rates and limits change — verify the current figures.
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.
Calculate
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?
How do the 0%, 15%, and 20% long-term brackets work?
What is the net investment income tax?
How do losses offset gains?
Does this apply to my home sale?
Can I control which bracket my gain lands in?
Are state taxes included?
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.