Tax Calculator Guides14 min read

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.

Capital Gains Tax Calculator: How to Estimate What You Will Owe Before You Sell
SM

Written by

Sarah Mitchell

Certified Public Accountant (CPA)

DC

Reviewed by

David Chen

Tax Attorney & Legal Editor

Published on

July 24, 2026

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 hhow 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 and fees also count. The commission you paid when you bought the asset and the commission you paid when you sold it both get factored in. That means if you paid a $500 broker fee to buy stock and another $500 to sell it, your cost basis goes up by $1,000 — and your taxable gain drops 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.

Now the long-term gain stacks on top. Total taxable income becomes $34,300 + $30,000 = $64,300.

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.

If Alex had sold the stock after holding it just 11 months, that same $30,000 would be a short-term gain. It would stack on top of her salary and get taxed at her ordinary rate. With $34,300 in ordinary income plus $30,000, she'd be in the 22% bracket for most of that gain.

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

Now let's look at a bigger scenario. Jamie and Mark file jointly. Jamie earns $110,000 from her job. Mark earns $40,000 from freelance work. Their combined W-2 and self-employment income is $150,000.

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

That's a clean $30,000 bill. But what if they had held the stock for only nine months? The $200,000 short-term gain would stack on top of their $118,600 ordinary income. Total ordinary income: $318,600. They'd land in the 24% bracket for most of that gain, with some spilling into the 32% bracket.

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. People often use just the purchase price as their cost basis, skipping improvements and commissions. On a big real estate sale, that oversight can overstate your gain by tens of thousands of dollars — and overstate your tax by thousands.

Forgetting the holding period cutoff. The difference between 364 days and 366 days can mean thousands in tax. Mark your purchase date clearly and check it before you sell. If you're close to the one-year mark, a short delay can be worth real money.

Not accounting for NIIT. If your income is near the $200K or $250K threshold, a capital gain can push you over it. The 3.8% surcharge applies on top of your regular capital gains rate, and many calculators — including some paid tax software — don't flag it clearly until the end.

Mixing up taxable income and total income. The long-term brackets apply to taxable income, not gross income. You need to subtract your standard deduction first. Skipping that step shifts you into a higher bracket in your calculation.

Overlooking state tax. Federal estimates alone don't tell the full story. If you live in a state with high income tax rates, your real bill can be 30-40% higher than the federal number alone. Always factor in your state rate.

Selling without checking offsets. If you have unrealized losses in other positions, you can sell those first to offset your gains. Up to $3,000 in net losses can also offset ordinary income. This strategy — tax-loss harvesting — can wipe out or dramatically reduce your capital gains tax. For more ideas along these lines, see our guide on hhow to avoid capital gains legally.

Assuming the 15% flat rate applies. Many people hear "15% capital gains rate" and assume it applies to all long-term gains at all income levels. The reality is tiered — part of your gain might fall at 0%, part at 15%, and part at 20% if your income is high enough. The effective rate you actually pay depends on where your total taxable income lands.

Not checking the primary residence exclusion. Home sellers often assume they owe tax on the full gain. If you lived in the home for at least two of the five years before selling, you may qualify for a $250,000 or $500,000 exclusion. That can wipe out your 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 by Sarah Mitchell (CPA, MST (Master of Science in Taxation)) and reviewed for accuracy by David Chen (JD, LLM in Taxation (New York University)). All tax rates, thresholds, and rules referenced are based on 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.

capital gains tax calculatorestimate capital gains taxcost basis calculationshort-term vs long-term ratesNIIT calculatorstate capital gains taxtax estimation tool

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.