⚖️ Capital Gains Tax Calculator
A capital gains tax calculator for stocks and for a house sale: 2026 IRS brackets, the $250k/$500k home exclusion, depreciation recapture and the 3.8% NIIT.
What Capital Gains Tax Calculator Does
Capital gains tax depends on three things: how long you held the asset, what your other taxable income is, and what kind of asset it was. Hold something more than a year and the gain is long-term, taxed at 0%, 15% or 20%. A year or less and it is short-term, taxed as ordinary income — which for most people is a materially higher rate.
The detail people miss is that a gain stacks on top of your ordinary income rather than being taxed in isolation. A single gain can therefore be partly untaxed and partly taxed at 15%, because it straddles a threshold. A calculator that applies one flat rate to the whole gain gets this wrong in both directions.
The other thing generic calculators omit is that the asset type often matters more than the rate table. Inherited property usually gets a stepped-up basis that wipes out decades of gain. A primary residence has a large exclusion. A rental has depreciation recapture taxed at up to 25%. Those rules routinely change the answer by more than the bracket does.
How to Use Capital Gains Tax Calculator
- Choose whether you are selling securities or a home or rental property
- Enter original purchase price and final selling price
- For property, add capital improvements, selling costs and any depreciation claimed while it was rented
- Select holding period (Long-term over 1 year or Short-term under 1 year)
- Choose tax filing status and annual taxable income bracket
- For a main home, confirm the 24-of-60-month ownership and use test to apply the Section 121 exclusion
- View estimated tax owed, net profit after tax, and true after-tax ROI %
Formula Used by Capital Gains Tax Calculator
Capital gain
gain = sale_price − selling_costs − adjusted_basis
- adjusted_basis
- Usually what you paid, plus capital improvements, minus any depreciation claimed
- selling_costs
- Commission, closing costs, transfer taxes — these reduce the gain
Worked example
Stock bought for $15,000, sold for $32,000, $50 in fees.
- 32,000 − 50 − 15,000 = 16,950
Result: A $16,950 capital gain. Long-term if held more than one year.
Long-term tax — the gain stacks on your income
tax = Σ (portion of gain falling in each rate band × that band's rate)
- stacking
- The gain sits above ordinary taxable income, so the bands are measured from your income upward, not from zero
Worked example
A single filer with $45,000 taxable income realizes a $10,000 long-term gain in 2026. The 0% band runs to $49,450.
- Room left in the 0% band: 49,450 − 45,000 = 4,450
- That first $4,450 of gain is taxed at 0% = $0
- The remaining $5,550 falls in the 15% band = $832.50
Result: $832.50, a blended 8.3% — not the $1,500 a flat 15% calculation would produce. Straddling matters.
Net Investment Income Tax
NIIT = 3.8% × min(net investment income, MAGI − threshold)
- threshold
- $200,000 single, $250,000 married filing jointly. Set by statute and never indexed for inflation
Worked example
A single filer with $190,000 income and a $30,000 long-term gain, so MAGI is $220,000.
- Excess over threshold: 220,000 − 200,000 = 20,000
- Lesser of gain and excess: 20,000
- 20,000 × 3.8% = 760
Result: An extra $760 on top of the ordinary capital gains tax. Because the threshold is not indexed, this catches more people every year.
Long-Term Capital Gains Rates — Tax Year 2026
Thresholds are measured against total taxable income including the gain. From IRS Revenue Procedure 2025-32, section .03.
| Filing status | 0% up to | 15% up to | 20% above |
|---|---|---|---|
| Single | $49,450 | $545,500 | $545,500 |
| Married filing jointly | $98,900 | $613,700 | $613,700 |
| Married filing separately | $49,450 | $306,850 | $306,850 |
| Head of household | $66,200 | $579,600 | $579,600 |
| Estates and trusts | $3,300 | $16,250 | $16,250 |
Source: IRS Revenue Procedure 2025-32 (PDF), §.03 Maximum Capital Gains Rate
Rates Above 20% — the Exceptions
Not every long-term gain gets the headline rates. These three exceptions catch people out, particularly on rental property.
| Asset | Maximum rate | Applies to |
|---|---|---|
| Collectibles (art, coins, metals) | 28% | Long-term gains on collectible assets |
| Qualified small business stock (§1202) | 28% | The taxable portion of a §1202 gain |
| Unrecaptured §1250 gain | 25% | Depreciation previously claimed on real property |
| Short-term gains | Up to 37% | Anything held one year or less — ordinary rates |
Selling a Main Home — Three Sales of the Same House
Bought for $300,000. Joint filers with $150,000 of other income, except the rental case which is a single filer with $100,000. Every figure computed by the calculator and re-derived by hand in scripts/verify-capital-gains-property.mjs.
| Case | Total gain | §121 exclusion | Taxable | Federal tax |
|---|---|---|---|---|
| Sold $700,000, $50,000 improvements, $42,000 costs | $308,000 | $308,000 | $0 | $0 |
| Sold $1,000,000, $50,000 improvements, $60,000 costs | $590,000 | $500,000 | $90,000 | $13,500 |
| Rental sold $400,000, $60,000 depreciation, no exclusion | $236,000 | $0 | $236,000 | $45,854 |
What Moves the Gain on a Property Sale
Publication 523 is specific about which of these count. A repair is not an improvement, however much it cost.
| Item | Effect | Examples |
|---|---|---|
| Capital improvements | Added to basis — reduces gain 1:1 | New roof, added bathroom, kitchen modernization, heating system, storm windows |
| Repairs and maintenance | No effect at all | Repainting, fixing a leak, replacing a broken pane |
| Selling expenses | Reduce the amount realized 1:1 | Sales commission, advertising, legal fees, points paid for the buyer |
| Depreciation while rented | Reduces basis — raises gain, and is taxed first at up to 25% | Any amount allowed OR allowable after 6 May 1997, claimed or not |
Rules That Change the Answer More Than the Rate Does
For the asset types people actually search for, these provisions usually dominate the bracket calculation.
| Situation | Rule | Effect |
|---|---|---|
| Inherited property | Stepped-up basis | Basis resets to fair market value at the date of death, so gain accrued during the deceased's lifetime is never taxed |
| Primary residence | §121 exclusion | Exclude up to $250,000 of gain ($500,000 filing jointly), if you owned and lived in it 2 of the last 5 years |
| Rental property | §1250 recapture | Depreciation you claimed is recaptured at up to 25%, even though it lowered your tax in earlier years |
| Gifted property | Carryover basis | You inherit the giver's original basis — no step-up, so the built-in gain comes with it |
| Losses | §1211 limit | Net losses offset gains fully, then up to $3,000 of ordinary income a year ($1,500 if filing separately); the rest carries forward |
How to Read Your Result
The one-year line is worth planning around
The difference between day 365 and day 366 can be the difference between a 22% ordinary rate and a 15% long-term rate. On a $50,000 gain that is $3,500. The holding period counts from the day after acquisition through the day of disposal, so check the actual dates rather than assuming.
Inherited property is the biggest misunderstanding
People routinely assume they owe tax on decades of appreciation when they sell a parent's house. Usually they do not. The basis steps up to the fair market value on the date of death, so only appreciation after that date is taxable — which, if you sell soon after, is often close to nothing. Get a dated valuation at the time of death; reconstructing it later is much harder.
Selling a house is a different calculation, not the same one with bigger numbers
Four things change. Capital improvements are added to your basis, so a $50,000 kitchen and roof reduce the gain by $50,000 — repairs and maintenance do not count. Selling costs come off the sale price, so a 6% commission on a $1,000,000 sale reduces the gain by $60,000 before anything else happens. Any depreciation you claimed while it was a rental comes off your basis, raising the gain. And then §121 can erase up to $250,000 of what is left, or $500,000 on a joint return. On a home bought for $300,000, improved by $50,000 and sold for $700,000 with $42,000 of costs, the gain is $308,000 and the federal tax is zero.
The exclusion has a hard ceiling, and it has not moved since 1997
$250,000 and $500,000 are statutory amounts, not inflation-adjusted ones. They were set in 1997 and the median US house has more than tripled since. That is why long-held homes in expensive markets now generate taxable gains that would have been fully covered a generation ago. On the same house sold for $1,000,000 with $60,000 of costs, the gain is $590,000, $500,000 is excluded, and $90,000 is taxable — $13,500 at the 15% rate for a joint filer with $150,000 of other income. The tests are mechanical: own it for 24 of the last 60 months, live in it as your main home for 24 of the previous 60.
Renting it out changes the answer permanently
Depreciation is recaptured before the exclusion is applied, and the exclusion cannot touch it. Worse, the recapture is on depreciation "allowed or allowable" — so it applies even if you never claimed the deduction. A $250,000 house with $40,000 of depreciation sold for $800,000 has a $542,000 gain: $40,000 is unrecaptured §1250 gain taxed at up to 25%, the remaining $502,000 gets the $500,000 joint exclusion, and $2,000 stays taxable. The bill is about $9,000 on a sale that would otherwise have been tax free.
Depreciation recapture surprises landlords
Depreciation on a rental reduces your taxable income each year, but it also reduces your basis. When you sell, that accumulated depreciation is recaptured at up to 25% — and the IRS applies recapture on depreciation you were *allowed* to claim, whether or not you actually claimed it. Not taking the deduction does not avoid the recapture.
The 0% band is a genuine planning opportunity
In a low-income year — a career break, early retirement before pensions start, a year between jobs — a long-term gain can be realized entirely at 0%. Some people deliberately sell and immediately repurchase to reset basis upward at no tax cost. The wash sale rule blocks this for losses, not for gains.
Limitations & Accuracy Notes
- The property mode models adjusted basis, the §121 exclusion and §1250 depreciation recapture. It does not model stepped-up basis on inherited assets, §1031 like-kind exchanges, a partial exclusion under the unforeseen-circumstances rules, non-qualified use after 2008, wash sales, or carried-forward losses from prior years.
- Unrecaptured §1250 gain is taxed here by stacking it on your ordinary income and capping each layer at 25%, then stacking the 0/15/20 gain above it. That reproduces the effect of the Schedule D worksheet in ordinary cases; the worksheet itself is longer and can differ where other rate-specific gains are also present.
- State capital gains tax is excluded. Most states tax gains as ordinary income; a few have no income tax at all; Washington taxes capital gains despite having no wage tax.
- The collectibles and §1202 rates of 28% are not applied — the security mode assumes ordinary capital assets such as stocks or funds.
- Tax year 2026 thresholds are used, from IRS Rev. Proc. 2025-32. These are adjusted annually. If you are reading this in a later tax year, verify against IRS.gov before relying on the figures.
- The NIIT calculation uses your entered income as a proxy for modified adjusted gross income, which is a simplification.
- This is an estimate for planning, not tax advice. Capital gains on property, inherited assets or business interests routinely involve rules this tool does not model — speak to a qualified tax professional before acting.
Frequently Asked Questions
What is the difference between short-term and long-term capital gains?
How do capital losses offset capital gains?
What is the Net Investment Income Tax (NIIT)?
Do I owe capital gains tax on selling my primary home?
Which country's rules does this use?
How do I calculate capital gains tax on the sale of a house?
How much can I exclude when I sell my primary residence?
What happens to the exclusion if I rented the house out?
Do home improvements reduce capital gains tax?
Is capital gains tax calculated after the standard deduction?
What is the difference between short-term and long-term gains?
What is a cost basis?
Can losses offset gains?
Do I owe tax if I have not sold?
Is this tax advice?
References & Further Reading
- IRS Topic no. 409 — Capital gains and losses — Holding periods, the rate structure, the 28%/25% exceptions and the $3,000 loss limit
- IRS Revenue Procedure 2025-32 (PDF) — Primary source for the tax year 2026 zero-rate and 15% rate amounts used here
- IRS Topic no. 701 — Sale of your home — The $250,000/$500,000 exclusion and the ownership and use tests
- IRS Topic no. 559 — Net investment income tax — The 3.8% surtax and its unindexed thresholds
- IRS Publication 523 — Selling Your Home — Which improvements add to basis, which selling expenses reduce the amount realized, and the rule that gain equal to depreciation allowed or allowable after 6 May 1997 "must be recaptured" and cannot be excluded