Capital Gains Tax Calculator: How to Estimate What You Will Owe Before You Sell
Step-by-step guide to estimating your capital gains tax before you sell. Covers the basic formula, cost basis calculations, short-term vs long-term rates, real walkthroughs, the 3.8% NIIT, state taxes, and common mistakes.

Why You Should Estimate Your Tax Before Selling
Nobody likes a surprise tax bill. Yet every year, thousands of people sell stocks, crypto, or real estate without running the numbers first. They assume the tax will be small — or they just don't think about it until April.
That mistake can cost you thousands. Capital gains tax rates swing from 0% to 37% depending on how long you held the asset and how much income you earn. Two people selling the exact same stock could pay very different amounts.
Running the math before you sell gives you power. You can time the sale for a better rate. You can offset gains with losses. You can decide whether selling now makes sense at all.
Think of it this way: if you knew you'd owe $9,000 in tax on a $30,000 gain, you might hold the asset a few more months to qualify for the lower long-term rate. That simple timing shift could cut your bill by more than half.
The Basic Capital Gains Formula
Every capital gains calculation starts with one formula:
Sale price minus cost basis equals your gain.
That gain is what the IRS taxes. Not the full sale price — just the profit. If you bought shares for $10,000 and sold them for $15,000, your gain is $5,000. The tax applies to that $5,000 alone.
But the formula only works if you know your real cost basis. And that number is often more complex than people realize. For a deeper look at the full calculation process, check our guide on hh[how to calculate capital gains tax.
How Cost Basis Actually Works
Your cost basis is not just what you paid for the asset. It includes several additions and adjustments that can lower your taxable gain — if you track them.

Purchase price is the starting point. That's whatever you originally paid for the stock, property, or other asset.
Improvements come next. If you're selling real estate, any capital improvement you made — a new roof, a kitchen renovation, an added bathroom — gets added to your basis. Routine repairs like painting or fixing a leaky pipe don't count. Only improvements that add value or extend the life of the property qualify.
Commissions count too: buy-side and sell-side fees both raise basis. A $500 fee to buy plus $500 to sell adds $1,000 of basis and cuts taxable gain by the same amount.
Let's look at a real example. Say you bought a rental property for $200,000. Over the years, you added a $30,000 deck and a $15,000 HVAC system. You paid a $6,000 commission when you bought it and a $12,000 commission when you sold it for $350,000.
Your cost basis would be $200,000 + $30,000 + $15,000 + $6,000 + $12,000 = $263,000. Your gain is $350,000 minus $263,000, which equals $87,000. Not the $150,000 you might have guessed if you ignored basis adjustments.
Short-Term vs Long-Term: The Rate Difference Matters
The IRS draws a hard line at one year. Assets held for one year or less get taxed at short-term rates, which mirror your ordinary income brackets. Assets held longer than one year get the preferential long-term rates.
This distinction can change your entire tax picture. A $50,000 short-term gain could land in the 32% or 35% bracket, costing you $16,000 to $17,500. The same $50,000 as a long-term gain might fall in the 15% bracket, costing just $7,500.
The difference is that stark. For a full breakdown of how each rate tier works, see our short-term vs long-term rate difference guide.
Here are the 2026 long-term rates:
0% rate — Single filers with taxable income up to $49,450. Married filing jointly up to $66,200. Yes, zero. If your income lands here, you pay nothing on long-term gains.
15% rate — Single filers from $49,451 to $545,500. Married couples from $66,201 to $579,200. This bracket covers most taxpayers.
20% rate — Single filers over $545,500. Married couples over $579,200. The top tier for high earners.
Short-term gains use ordinary brackets instead: 10%, 12%, 22%, 24%, 32%, 35%, and 37%. These stack on top of your other income, so a big short-term gain can push you into a much higher bracket than you normally occupy.
For more on how each bracket works, see our capital gains tax rates breakdown.
Walkthrough: Single Filer With $50K Salary and $30K Long-Term Gain
Let's run the numbers for a real scenario. Meet Alex — single filer, $50,000 W-2 salary, and a $30,000 long-term capital gain from stock she held for three years.

First, Alex needs her total taxable income. Her salary of $50,000 gets the standard deduction of $15,700 (2026 single), bringing her ordinary taxable income to $34,300.
Total taxable income: $34,300 + $30,000 = $64,300. The 0% bracket covers up to $49,450 for single filers, so part of her gain escapes tax entirely and the rest gets 15%.
To find the rate, the IRS looks at where Alex's total income falls in the long-term bracket table. The 0% bracket covers up to $49,450 for single filers. Alex's total of $64,300 exceeds that, so some of her gain escapes tax and the rest gets 15%.
Here's the split. The first $49,450 of her total income is covered by the 0% rate. But since $34,300 of that is already ordinary income, only $49,450 minus $34,300 = $15,150 of her gain qualifies for the 0% rate.
The remaining $30,000 minus $15,150 = $14,850 of her gain falls into the 15% bracket.
Tax on the 0% portion: $15,150 x 0% = $0
Tax on the 15% portion: $14,850 x 15% = $2,227.50
Alex's total capital gains tax is $2,227.50 on a $30,000 gain. That's an effective rate of about 7.4% — far below the 15% headline rate because part of her gain fell into the zero bracket.
Sold eleven months earlier, the same gain turns short-term: stacked on her salary it lands mostly in the 22% bracket, roughly $6,600 in tax. Waiting a few extra weeks saved more than $4,300.
Her tax would jump to roughly $6,600. The difference? More than $4,300 — all from waiting a few extra weeks to sell.
Walkthrough: Married Couple Selling Stock With a $200K Gain
Jamie and Mark file jointly with $150,000 of combined income ($110,000 salary, $40,000 freelance) and a six-year-held stock position they want to sell: a $200,000 long-term gain.

They've held a concentrated stock position for six years and want to sell. The gain is $200,000 — all long-term.
Their standard deduction for 2026 MFJ is $31,400. So ordinary taxable income = $150,000 minus $31,400 = $118,600.
Total taxable income including the gain: $118,600 + $200,000 = $318,600.
Now we apply the long-term brackets for married couples. The 0% bracket goes up to $66,200. Since their ordinary income alone is $118,600, they've already cleared the 0% threshold. None of the $200,000 gain qualifies for 0%.
The 15% bracket covers income from $66,201 to $579,200 for MFJ. Their total of $318,600 sits squarely inside this range, so the entire $200,000 gain gets taxed at 15%.
Tax on the gain: $200,000 x 15% = $30,000
Held only nine months, the same gain stacks on their ordinary income — mostly 24%, some 32% — pushing the bill past $45,000. That is $15,000 extra purely from holding-period timing.
Their short-term tax on the same gain could easily exceed $45,000. That's $15,000 more than the long-term route — again, purely from holding period timing.
The 3.8% NIIT Layer That Changes Your Math
There's one more tax many people miss. The Net Investment Income Tax — NIIT — adds a 3.8% surcharge on investment income for higher earners. It kicks in when your modified adjusted gross income crosses a threshold.
For single filers, that threshold is $200,000. For married couples filing jointly, it's $250,000. The NIIT applies to the lesser of your net investment income or the amount your MAGI exceeds the threshold.
Let's revisit Jamie and Mark. Their MAGI of $318,600 exceeds the $250,000 MFJ threshold by $68,600. Their investment income is $200,000. The NIIT hits the smaller number — $68,600 — at 3.8%.
NIIT: $68,600 x 3.8% = $2,586.80
So their real total is $30,000 in capital gains tax plus $2,586.80 in NIIT. That's $32,586.80 on a $200,000 gain — an effective rate of about 16.3%.
This surcharge catches a lot of people off guard. If you're near the threshold, even a modest gain can push you over it. For a full walkthrough of how NIIT works, read our net investment income tax guide.
How State Taxes Stack On Top
Federal tax is only part of your bill. Most states tax capital gains too, and their rates range widely.
California treats capital gains as ordinary income and tops out at 13.3%. A $200,000 gain in California could add over $20,000 in state tax on top of your federal bill. New York hits 6.85% on ordinary income brackets. New Jersey can reach 10.75%.
Some states are far gentler. Pennsylvania taxes capital gains at a flat 3.07%. Colorado uses a flat 4.4%. And a handful of states — including Wyoming, Nevada, Florida, Texas, and Washington — charge zero state income tax at all.
If you live in a high-tax state and plan a big sale, the combined federal-plus-state rate can be eye-opening. A California resident in the 20% federal bracket with NIIT pays 20% + 3.8% + 13.3% = 37.1% on the top portion of long-term gains. That's close to the short-term federal rate — for an asset you held for years.
Check our state capital gains rates comparison to see exactly where your state falls.
Using Our Free Calculator on the Homepage
You don't have to work through all these brackets by hand. Our capital gains tax calculator on the homepage handles the math for you in about 30 seconds.
Here's how it works. You plug in a few inputs: your filing status, your ordinary income, your capital gain amount, your holding period, and your state. The calculator runs the bracket logic, finds your marginal and effective rates, estimates NIIT if applicable, and adds state tax.
It shows you the total estimated bill and the effective rate as a percentage of your gain. You can toggle between short-term and long-term to see how waiting a few months changes your result.
The tool also lets you compare scenarios. Say you're deciding whether to sell now or next year. You can run both numbers side by side and see the exact dollar difference. That kind of comparison is hard to do on paper but takes seconds with the calculator.
For people selling homes, the calculator factors in the primary residence exclusion. If you qualify, up to $250,000 (single) or $500,000 (married) of gain on your home sale can be excluded entirely. Learn the full rules in our selling your home tax exclusion guide.
Common Calculation Mistakes That Cost People Money
Even with a calculator, people make errors that inflate their tax or miss savings opportunities. Here are the most common ones.
Ignoring basis adjustments. Using only the purchase price as basis skips improvements and commissions — on a big real estate sale that alone can overstate your gain by tens of thousands of dollars.
Forgetting the holding period cutoff. Three hundred sixty-four days versus three hundred sixty-six can swing thousands in tax — check your purchase date before selling.
Not accounting for NIIT. Income near the $200K or $250K threshold plus a gain can cross it — the 3.8% surcharge stacks on top, and many calculators never flag it.
Mixing up taxable income and total income. Brackets apply to taxable income, not gross — subtract your standard deduction first or you will overestimate your bracket.
Overlooking state tax. In high-tax states the real bill can run 30–40% above the federal-only number — always factor in your state rate.
Selling without checking offsets. Sell unrealized losers first to offset gains — tax-loss harvesting can wipe out much of the bill, and up to $3,000 of net losses can offset ordinary income. See our guide on how to avoid capital gains legally.
Assuming a flat 15% rate. The rate is tiered — parts of your gain can fall at 0%, 15%, and 20% depending on where your total taxable income lands.
Not checking the primary residence exclusion. Two of the last five years in the home can qualify sellers for the $250,000/$500,000 exclusion — often wiping out the gain entirely.
Quick Reference: 2026 Long-Term Capital Gains Brackets
For easy lookup, here are the 2026 thresholds:
Single filers:
- 0% rate: taxable income up to $49,450
- 15% rate: taxable income from $49,451 to $545,500
- 20% rate: taxable income above $545,500
Married filing jointly:
- 0% rate: taxable income up to $66,200
- 15% rate: taxable income from $66,201 to $579,200
- 20% rate: taxable income above $579,200
NIIT thresholds:
- Single: MAGI above $200,000
- MFJ: MAGI above $250,000
Short-term gains always use ordinary income brackets, ranging from 10% to 37%.
Bottom Line
Estimating your capital gains tax before you sell is not optional — it's basic financial planning. The numbers change based on your filing status, income level, holding period, and state. Running the calculation ahead of time lets you time your sales, harvest losses, and avoid nasty surprises in April.
Use our capital gains tax calculator to run your numbers in seconds. Then compare short-term versus long-term scenarios, check your state impact, and see whether NIIT applies. A few minutes of math can save you thousands of dollars — and that's money better kept in your pocket than sent to the IRS.
Fact-Checked & Reviewed
This article was written and fact-checked by Wasim Akram, Founder & Lead Researcher at TaxGainsCalc. Every rate, threshold, and rule referenced is verified against IRS publications and current tax law as of the date published. Tax laws change frequently — always consult a qualified tax professional for advice specific to your situation.
Disclaimer: This article is for informational purposes only and does not constitute tax, legal, or financial advice. Tax laws and regulations change frequently, and the information presented here may not reflect the most current updates. You should consult with a qualified CPA, tax attorney, or financial advisor before making any tax-related decisions. TaxGainsCalc is not responsible for any actions taken based on the information provided in this article.
Continue Reading
Wasim Akram
Wasim researches and writes every article on TaxGainsCalc, covering capital gains tax for everyday investors. Every figure is checked against primary IRS sources before it goes live.


