How to use the capital gains tax calculator
Tax on a sale estimates the tax on a single sale and shows it both ways: as a short-term and as a long-term gain. Capital losses nets a full year of gains and losses and works out the deduction and carryforward.
- Filing status and other income. Choose whether you know your taxable income (after the standard or itemized deduction, as shown on last year’s Form 1040) or only your gross income. With gross income the calculator subtracts the 2026 standard deduction for you. Do not include the sale itself.
- Purchase and sale price. Enter the totals for the whole position, not per share. Include the purchase commission in the purchase price; it is part of your cost basis.
- Selling costs. Commissions and fees on the sale. They reduce the gain.
- State tax rate. Your state’s rate on the gain, or 0.
- Holding period. More than one year makes the gain long-term.
The results show the tax for the holding period you chose, the alternative next to it, and the difference. The tables compare both treatments line by line and at seven income levels.
How capital gains tax is calculated
Short-term tax = Income tax(Other income + Gain) − Income tax(Other income)
Long-term tax = the part of the gain in each band × 0%, 15% or 20%The gain is stacked on top of your other taxable income, so your other income decides which rates the gain reaches. Bands and brackets are the official 2026 figures.
State tax = Gain × State rate
Effective rate = (Federal + NIIT + State) ÷ GainThe net investment income tax threshold is $200,000 of modified adjusted gross income (MAGI) for single filers and $250,000 for joint filers. The calculator estimates MAGI from your inputs.
A worked example
A single filer with $70,000 of taxable income sells a position bought for $20,000 for $32,000, paying $40 in selling costs. The capital gain is $11,960.00.
Held more than a year, the gain falls entirely in the 15% band: $1,794.00 of federal tax. A 5% state rate adds $598.00, and MAGI of about $98,060 is far below the NIIT threshold. Total tax is $2,392.00, an effective rate of 20.0%, leaving $9,568.00 of after-tax profit.
Sold within a year, the same gain would be taxed at the 22% ordinary rate: $2,631.20 federal and $3,229.20 in total. Waiting past the one-year mark saves $837.20.
Short-term versus long-term at different incomes
Your other income changes the answer more than anything else. The same $11,960.00 gain, no state tax, single filer:
| Other taxable income | Short-term tax | Long-term tax | Long-term rate |
|---|---|---|---|
| $30,000 | $1,435.20 | $0.00 | 0.0% |
| $70,000 | $2,631.20 | $1,794.00 | 15.0% |
| $250,000 | $4,453.73 | $2,248.48 | 18.8% |
| $600,000 | $4,640.48 | $2,846.48 | 23.8% |
At $30,000 the whole gain fits under the $49,450 line and is taxed at 0%. At $250,000 the gain also triggers the net investment income tax ($454.48), and at $600,000 it falls in the 20% band with NIIT on top. In dollar terms the gap is largest in the upper brackets, where short-term gains are taxed at 32% to 37% while long-term gains pay 15% or 20% plus NIIT.
A few kinds of long-term gain have their own maximum rates: up to 28% on collectibles such as art, coins and physical gold, and up to 25% on the part of a real estate gain that reflects past depreciation (unrecaptured section 1250 gain). This calculator applies the standard 0/15/20% rates.
How capital losses work
A sale below your cost basis produces a capital loss. Losses are not wasted:
- They offset gains first. Short-term losses net against short-term gains and long-term losses against long-term gains, then any remaining loss in one group offsets gains in the other.
- Up to $3,000 a year comes off ordinary income once all gains are used up ($1,500 if married filing separately).
- The rest carries forward indefinitely, used against future gains first and then at the annual limit.
In the Capital losses tool, a single filer has $2,500 of short-term gains, $9,000 of short-term losses, $1,500 of long-term gains and $4,000 of long-term losses. After netting, the net capital loss is $9,000.00. $3,000.00 reduces ordinary income this year, worth $1,435.00 in federal tax counting the gains it cancelled, and $6,000.00 carries forward: $3,500.00 short-term and $2,500.00 long-term.
If the same filer had $20,000 of long-term gains instead, the losses would offset part of them, leaving a net gain of $9,500.00 taxed at $1,425.00 instead of $3,550.00. That is why selling losing positions to offset gains, often called tax-loss harvesting, can pay. If you buy the same or a substantially identical security within 30 days before or after the loss sale, the wash-sale rule postpones the loss.
On the Tax on a sale tool, a single sale at a loss shows the same logic. Selling the example position for $15,000 gives a $5,000.00 loss: with no other gains, $3,000.00 is deductible this year and $2,000.00 carries forward.
What this calculator does not include
- Exact MAGI. The NIIT uses an estimate of MAGI from your inputs; your return may differ.
- Special rates for collectibles, unrecaptured section 1250 gain and qualified small business stock.
- The home sale exclusion, depreciation recapture on business property and installment sales.
- Alternative minimum tax, credits and income-based phase-outs that a gain can trigger.
- State rules. A few states tax gains differently from wages; one flat rate is an approximation.
To work out the cost basis of shares bought at different times, use the cost basis calculator, and for dividend income the dividend tax calculator.