Indexes
2026 IRS brackets

Long term capital gains tax calculator: short term capital gains, stock sale tax and tax loss harvesting.

Enter what you sold and what you paid. This prices the gain against the real 2026 federal breakpoints, stacks it on top of your other income the way the tax code does, adds the 3.8% net investment income tax and your state rate, and then shows how much of the bill a harvested loss removes.

Rev. Proc. 2025-32 figures NIIT included Nothing leaves your browser

Every calculator gives you the gain and the rate. Almost none of them price the one lever you can still pull after the gain exists, which is offsetting it with losses you realize elsewhere in the same year.

Capital gains tax calculator

Taxable gain
Offset by harvested losses
Net investment income tax, 3.8%
State tax
Total tax on this sale
Effective rate on the gain
You keep, of the proceeds

Harvesting of losses cuts this bill by . A further comes off ordinary income, which is the annual cap. carries forward to future years.

Estimate only, for planning. Federal brackets from Revenue Procedure 2025-32 for tax year 2026. Educational information, not tax advice. Indexes never places a trade or connects to a brokerage.

In short

You are taxed on the gain, not on what the sale is worth. If you held the stock more than a year, the 2026 federal rate is 0%, 15% or 20%, and the breakpoints published in Revenue Procedure 2025-32 are $49,450 and $545,500 for a single filer and $98,900 and $613,700 for married filing jointly. Held a year or less, the gain is stacked onto ordinary income at 10% to 37% instead. Add 3.8% net investment income tax once modified adjusted gross income passes $200,000 single or $250,000 joint, which puts the true federal ceiling on a long-term gain at 23.8%. Then add state tax, which most states charge at their ordinary rates. The one thing that still moves the number after the gain exists is realized losses: they offset gains dollar for dollar with no cap, and up to $3,000 of any excess comes off ordinary income each year with the rest carried forward indefinitely.

Last updated August 2026

// THE BRACKETS

Long term capital gains tax rates

The 2026 breakpoints, straight from the revenue procedure

These are taxable income thresholds, not gain thresholds. The gain sits on top of your other taxable income, so a $40,000 gain on top of a $520,000 salary is taxed very differently from the same gain on top of $40,000 of salary. Equity compensation is the usual reason that total jumps in a single year, because a vest is wage income that lands all at once, and the RSU tax calculator works out where it leaves you before you sell anything else.

Filing status 0% up to 15% up to 20% applies
Married filing jointly and surviving spouse $98,900 $613,700 Above $613,700
Head of household $66,200 $579,600 Above $579,600
Single $49,450 $545,500 Above $545,500
Married filing separately $49,450 $306,850 Above $306,850

Source: Internal Revenue Service, Revenue Procedure 2025-32, section 3.03, "Maximum Capital Gains Rate", for taxable years beginning in 2026. Worth knowing: on the day this page was written, the IRS's own Topic 409 explainer still showed the tax year 2025 thresholds, which is why so many published "2026 rates" are a year stale.

Short term

No preferential rate at all

Sell inside one year and the gain joins your wages at your marginal bracket: 10, 12, 22, 24, 32, 35 or 37 percent for 2026. For a single filer earning $150,000 that is usually 24% against 15%, so the same trade costs roughly 60% more in tax for the sake of a few days.

The surtax

3.8% that is not indexed

The net investment income tax applies to the lesser of your net investment income or your modified adjusted gross income above $200,000 single, $250,000 joint, $125,000 married filing separately. Those numbers are statutory and never adjust for inflation, so the surtax quietly reaches further every year.

State

Usually taxed as ordinary income

Most states give capital gains no break, so California's 13.3% top rate lands on the full gain. Several states levy no individual income tax. Washington is the exception worth knowing: no income tax, but a 7% excise tax on long-term capital assets above a standard deduction its Department of Revenue set at $278,000 for 2025.

// THE METHOD

How to calculate capital gains tax on a stock sale

Four steps, in the order the tax code applies them

01

Find the gain, not the proceeds

Proceeds minus adjusted cost basis, including commissions and any reinvested dividends that were already taxed. People routinely overestimate their bill by an order of magnitude because they look at the sale value instead of the gain.

02

Net your losses first

Realized losses come off realized gains before any rate is applied, with short-term netted against short-term and long-term against long-term first. There is no cap on this step, which is what makes it the strongest lever available.

03

Stack the gain on your income

The 0/15/20 breakpoints are read against your total taxable income with the gain included. A gain can straddle two brackets, so part of it is taxed at 15% and part at 20%. The calculator above does this properly rather than applying one flat rate.

04

Add the surtax and the state

Apply 3.8% NIIT to the lesser of investment income and the MAGI excess, then your state rate. A California filer above the thresholds can land near 37% all in on a long-term gain, which is close to the top ordinary federal rate on its own.

Scenario What applies Federal tax
$50,000 long-term gain, single filer, $120,000 salary 15% federal, no NIIT (income under $200,000) $7,500
$50,000 short-term gain, single filer, $120,000 salary Ordinary rates, mostly the 24% bracket About $12,000
$50,000 long-term gain, single filer, $300,000 salary 15% federal plus 3.8% NIIT on the full gain $9,400
$50,000 long-term gain, MFJ, $700,000 income 20% federal plus 3.8% NIIT $11,900
The same $50,000 long-term gain, $300,000 salary, with $50,000 of harvested losses applied Gain fully offset, nothing left to tax $0

Federal only, before state tax, 2026 brackets, standard deduction assumed. The last row is the point of the whole page: the gain did not change, the tax did.

// THE LEVER

Tax loss harvesting calculator

What a harvested loss is actually worth

Once a gain is realized, the rate is fixed and your income is what it is. Losses are the only input still under your control, and they behave differently depending on how much you have.

Against gains: unlimited

A realized loss offsets a realized gain dollar for dollar, with no ceiling. Harvest $200,000 of losses in a year you realized a $200,000 gain and the federal bill on that gain goes to zero. This is the step that matters, and it is why harvesting is worth the most to people who actually have gains to offset.

Against income: $3,000 a year

Excess losses come off ordinary income at only $3,000 a year, $1,500 if you file separately, and IRS Topic 409 lets the rest carry forward indefinitely. A $60,000 loss with no gains to absorb it takes twenty years to use at that rate, which is why loss banking without gains is worth far less than it sounds.

The wash sale trap

Buy the same or a substantially identical security within 30 days either side of the sale and the loss is disallowed. The full mechanics, including why a replacement purchase inside an IRA forfeits the loss permanently, are in our guide to tax loss harvesting rules.

This is where the calculator above stops being an arithmetic exercise. If your portfolio is a single S&P 500 ETF, there is nothing to harvest in a year the index is up, because you own one position and it has one cost basis. If you hold the index as several hundred individual stocks, roughly a third of them are below their purchase price even in a strong year, and each is a separately harvestable lot. That is the entire argument for direct indexing, and it is priced out honestly on our direct indexing fees page and compared provider by provider in tax loss harvesting software. The catch is that harvesting is worth roughly nothing unless you have gains to offset, which is the honest case laid out in direct indexing and tax loss harvesting.

Before you sell

Model the basket you would hold instead

If the reason you are running this calculation is that one position has grown into too much of your portfolio, the question after the tax number is what you would rather own. Build the replacement as a weighted index, backtest the construction against real market history, and see how it would have tracked the S&P 500 before you trigger anything taxable.

Indexes is analysis software. It never places a trade, never connects to a brokerage and never holds money, so nothing you do here has a tax consequence.

Build your own ETF
Index Studio
· vs
Index
Backtested against - illustrative sample data
Holdings
Weighting
Performance Index
Total return
--
Vs
--
Max drawdown
--

Educational only · Never places a trade

// ASKED AND ANSWERED

Capital gains tax on stocks

The questions people actually type

How much tax do you pay on stock gains?

If you held the stock more than one year, the federal rate is 0%, 15% or 20% depending on your total taxable income. For 2026 a single filer pays 0% until taxable income reaches $49,450, then 15% up to $545,500, then 20%. If you held it a year or less, the gain is taxed as ordinary income at 10% to 37%. High earners add the 3.8% net investment income tax, which is why the real top federal rate on a long-term gain is 23.8%.

How much tax do you pay when you sell stock?

You are taxed on the gain, not the sale price. Subtract your cost basis from the proceeds, and only the difference is taxable. Selling $200,000 of stock you bought for $180,000 produces a $20,000 gain, so a 15% long-term rate costs $3,000, not $30,000. Losses on other positions sold the same year reduce that gain dollar for dollar before any rate is applied.

What is the capital gains tax rate on stocks in 2026?

Long-term gains, meaning positions held more than one year, are taxed at 0%, 15% or 20% federally. Revenue Procedure 2025-32 sets the 2026 breakpoints at $49,450 and $545,500 for single filers and $98,900 and $613,700 for married filing jointly. Short-term gains have no preferential rate and are stacked onto ordinary income at your marginal bracket, up to 37%.

How do I calculate capital gains tax on a stock sale?

Take the proceeds, subtract the cost basis including commissions, and that is your gain. Check whether you held the position more than one year. Add the gain on top of your other taxable income, because the rate depends on your total, not on the gain alone. Apply the 0/15/20 breakpoints for a long-term gain or your ordinary bracket for a short-term one, then add 3.8% NIIT if your modified adjusted gross income exceeds $200,000 single or $250,000 joint, then add state tax.

Does a capital loss reduce the tax on a gain?

Yes, and this is the largest lever most people ignore. Realized losses offset realized gains dollar for dollar with no cap. If losses exceed gains, you may deduct up to $3,000 of the excess against ordinary income each year, $1,500 if married filing separately, and IRS Topic 409 lets you carry the remainder forward indefinitely. A $40,000 loss against a $40,000 gain removes the entire tax bill on that gain.

What is the 3.8% net investment income tax?

It is a surtax on investment income for higher earners, charged on the lesser of your net investment income or the amount your modified adjusted gross income exceeds a statutory threshold. The IRS sets those thresholds at $250,000 for married filing jointly, $125,000 for married filing separately and $200,000 for single and head of household. They are written into the statute and are not adjusted for inflation, so more households cross them every year.

How much tax do I pay on stocks held less than a year?

A short-term gain gets no preferential rate at all. It is added to your wages and taxed at your marginal ordinary bracket, which for 2026 runs 10%, 12%, 22%, 24%, 32%, 35% and 37%. A single filer with $150,000 of salary pays 24% on most of a short-term gain versus 15% if the same position had been held one day past the one-year mark, and the 3.8% NIIT applies on top either way.

Do I pay state tax on capital gains too?

In most states, yes, and most of them tax capital gains as ordinary income rather than at a preferential rate. California taxes gains at its regular rates, topping out at 13.3%. Several states levy no individual income tax at all. Washington is the odd case: it has no income tax but does levy a 7% excise tax on long-term capital assets such as stocks above an annual standard deduction, which its Department of Revenue put at $278,000 for 2025.

Can I avoid capital gains tax by reinvesting the money?

Not in a taxable brokerage account. There is no equivalent of the 1031 exchange for publicly traded stock, so buying a different stock with the proceeds does not defer anything. The realistic levers are holding past the one-year mark for the lower rate, harvesting losses elsewhere in the portfolio to offset the gain, contributing appreciated shares to charity instead of selling them, or contributing the position to an exchange fund under IRC 721, which defers rather than eliminates the tax.

How accurate is this calculator?

It applies the published 2026 federal brackets, the 3.8% NIIT thresholds and whatever state rate you enter, and it stacks the gain on top of your other income the way the tax code actually does. It deliberately does not model the alternative minimum tax, the qualified small business stock exclusion, collectibles at 28%, wash sale disallowances or state-specific preferences. Treat the number as a planning estimate, not a return. It is educational information, not tax advice.

Know the bill, then design what you hold next

Build a weighted index of the stocks or crypto you want, backtest the construction against real history, and track it against the S&P 500. No brokerage, no trades, no money moved.

See pricing