★ MONEY · CAPITAL GAINS ON A HOME SALE · GUIDE

How to Calculate Capital Gains on a Home Sale

An $850,000.00 sale, a $400,000.00 purchase, $50,000.00 of improvements, $51,000.00 of selling costs, single, qualified, and a 15% rate gives an adjusted basis of $450,000.00, a gain of $349,000.00, a taxable gain of $99,000.00, and a tax of $14,850.00. Here is how to work it out in six steps.

What capital gains on a home sale is

Capital gains on a home sale is the tax on the profit you made selling your house — not on the price, but on the gain: the sale price minus what the home cost you, improvements included, minus what selling cost you. On the worked example here — an $850,000.00 sale, a $400,000.00 purchase, $50,000.00 of improvements, and $51,000.00 of selling costs — the gain is $349,000.00. Then the exclusion takes $250,000.00 off the top for a single filer, or $500,000.00 married filing jointly, if you pass the ownership-and-use test. What is left is the taxable gain, and the tax is that times your rate. Every figure here is checked against the home sale capital gains calculator.

The home sale capital gains formula

Adjusted basis = purchase price + improvements. Gain = sale price − adjusted basis − selling costs. Taxable gain = gain − exclusion, when the test is met — otherwise the full gain, never below $0. Tax = taxable gain × rate. The exclusion is $250,000.00 single and $500,000.00 married filing jointly; the rate is a percent — 15% is 0.15.

Step 1: Write down the sale price, purchase price, improvements, and selling costs

Write down the four numbers the formula needs. The sale price is what the buyer paid you — $850,000.00 here. The purchase price is what you paid — $400,000.00. The improvements are the capital improvements you made — $50,000.00 here, a new roof or an addition, not a coat of paint. The selling costs are what selling cost you — $51,000.00 here, mostly commission and closing costs.

Step 2: Work out the adjusted basis

Add the improvements to the purchase price for the adjusted basis: $400,000.00 + $50,000.00 = $450,000.00. The basis is what the home cost you in the tax sense — every dollar of improvements raises it, and every dollar of basis is a dollar that never gets taxed.

Step 3: Subtract the basis and the selling costs for the gain

Subtract the basis and the selling costs from the sale price: $850,000.00 − $450,000.00 − $51,000.00 = $349,000.00. This is the profit the tax is about — not the sale price, and not the price minus the purchase price alone. If the sale price exactly covers the basis and the costs, the gain is $0.00: a $501,000.00 sale here leaves no gain at all.

Step 4: Apply the exclusion

Subtract the exclusion for the taxable gain. The exclusion is $250,000.00 single and $500,000.00 married filing jointly, and it needs the ownership-and-use test: you must have owned and lived in the home at least 2 of the last 5 years. Single and qualified, that is $349,000.00 − $250,000.00 = $99,000.00. A married couple selling the same house subtracts $500,000.00 instead, and the taxable gain is $0.00. If the test is not met there is no exclusion, and the taxable gain is the full $349,000.00. The taxable gain is never below $0.00.

Step 5: Multiply the taxable gain by the rate

Multiply the taxable gain by the capital-gains rate: $99,000.00 × 15% = $14,850.00. The rate depends on your income and filing status — 0%, 15%, or 20% for most sellers — and it is the rate on the taxable gain only, not on the sale price. At 20% the same sale gives a $19,800.00 tax, and at 0% it gives $0.00. Check the 2026 capital gains tax brackets for your income before you sell.

Step 6: Reverse it when you need a target

Reverse it when you need a target. The sale price for a $0.00 taxable gain, single and qualified, is $751,000.00: at $751,000.00 the gain is $250,000.00, exactly the single exclusion, so the taxable gain is $0.00 — the first price at which the taxable gain is $0.00. The improvements for a $10,000.00 tax are $82,333.33: at $82,333.33 the tax is $10,000.00. The rate for a $20,000.00 tax is 20.20%: at 20.20% the tax is $19,998.00, $2.00 under the target, because the rate is rounded. And the sale price for a $25,000.00 tax is $917,666.67: at $917,666.67 the tax is $25,000.00.

Worked example

Put the six steps together for an $850,000.00 sale, a $400,000.00 purchase, $50,000.00 of improvements, $51,000.00 of selling costs, single, qualified, and a 15% rate. The basis is $450,000.00. The gain is $349,000.00. The taxable gain is $99,000.00. The tax is $14,850.00. A married couple pays $0.00 on the same sale, and at a 20% rate the tax is $19,800.00.

How the numbers change

A $1,000,000.00 sale lifts the gain to $499,000.00 and the tax to $37,350.00. Improvements of $100,000.00 lift the basis to $500,000.00 and cut the tax to $7,350.00. A $300,000.00 purchase cuts the basis to $350,000.00 and lifts the tax to $29,850.00. Selling costs of $400,000.00 eat the whole gain, and $500,000.00 of costs give a −$100,000.00 loss — not deductible on a personal residence.

Working backwards

It also runs in reverse. The selling costs for a $12,000.00 tax are $70,000.00: at $70,000.00 the tax is $12,000.00. The purchase price for a $300,000.00 gain is $449,000.00. The sale price for a $0.00 taxable gain is $751,000.00, and for a $25,000.00 tax it is $917,666.67.

What the calculation leaves out

Three things are left out. First, this is the standard exclusion rule, not tax advice — the exclusion needs the 2-of-5-years test, and a partial exclusion can apply in some cases. Second, it does not model state tax, the 3.8% net investment income tax, or depreciation recapture if the home was ever rented out. Third, a loss on a personal residence is not deductible, so a sale below the basis and costs gives $0.00 of tax, not a refund. For the commission, see the real estate commission calculator, and for the next home, see the loan affordability calculator.

What to do next

Run your own numbers through the home sale capital gains calculator — and if the tax is more than you expected, check the two levers that move it most: the exclusion, which needs the 2-of-5-years test, and the improvements, which raise the basis dollar for dollar.

Cite this guideBright Side Kit. “How to Calculate Capital Gains on a Home Sale” brightoolbox.com, 2026. Method: adjusted basis = purchase price + improvements; gain = sale price − adjusted basis − selling costs; taxable gain = gain − exclusion ($250,000 single / $500,000 married filing jointly) when the ownership-and-use test is met, otherwise the full gain, never below $0; tax = taxable gain × capital-gains rate. Worked example: $850,000.00 sale, $400,000.00 purchase, $50,000.00 improvements, $51,000.00 selling costs, single, qualified, 15% → adjusted basis $450,000.00, gain $349,000.00, taxable gain $99,000.00, tax $14,850.00. The first sale price at which the taxable gain is $0.00 for a single filer is $751,000.00 (gain $250,000.00 = the full exclusion). Contrasts: married filing jointly → tax $0.00 on the same sale; 20% rate → tax $19,800.00. Bright Side Kit. "How to Calculate Capital Gains on a Home Sale" https://brightoolbox.com/guides/how-to-calculate-capital-gains-on-a-home-sale/ Accessed October 26, 2026.

Frequently asked questions

How much tax do I owe when I sell my home for $850,000?

$14,850.00. On the worked example — an $850,000.00 sale, a $400,000.00 purchase, $50,000.00 of improvements, $51,000.00 of selling costs, single, qualified, and a 15% rate — the basis is $450,000.00, the gain is $349,000.00, the taxable gain is $99,000.00, and the tax is $14,850.00.

What is the $250,000 home sale exclusion?

$250,000.00 of gain is tax-free for a single filer who meets the test — $500,000.00 married filing jointly. You must have owned and lived in the home at least 2 of the last 5 years. On the worked example the $250,000.00 exclusion cuts a $349,000.00 gain to a $99,000.00 taxable gain.

What sale price gives zero taxable gain?

$751,000.00 for a single filer. At a $751,000.00 sale the gain is $250,000.00 — exactly the single exclusion — so the taxable gain is $0.00 and the tax is $0.00. It is the first price at which the taxable gain is $0.00.

Does being married change the tax on a home sale?

Yes — on the same $850,000.00 sale the tax is $0.00. The married exclusion is $500,000.00, and the $349,000.00 gain fits inside it entirely. On a $1,000,000.00 sale the married taxable gain is still $0.00.

What if I did not live in the home for 2 years?

The tax is $52,350.00. Without the exclusion the whole $349,000.00 gain is taxable at 15%. At a 20% rate with the test not met, the tax is $69,800.00.

Can I deduct a loss on my home sale?

No. Selling costs of $500,000.00 give a −$100,000.00 loss and a $0.00 taxable gain — but the loss is not deductible on a personal residence.