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.
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.