Selling a house

Capital Gains Tax on the Sale of a House: Calculator With the Hidden Costs

Short answer: you owe capital gains tax on the profit above your exclusion. If you lived in the house as your main home for 2 of the last 5 years, the first $250,000 of profit ($500,000 for a married couple) is tax-free. Anything above that is taxed at 0%, 15% or 20% federally, plus 3.8% on high incomes and your state.

Then comes the part other house sale calculators skip. A taxable gain is a one-year income spike, and that spike can raise Medicare premiums two years later and tax more of your Social Security. Enter your numbers and see the tax and the full cost.

By Hans Goldstein, EA, Enrolled Agent, enrolled to practice before the IRS. Updated December 2026.

2027 federal brackets (IRS Rev. Proc. 2026-35), SSA Section 86 thresholds, CMS 2027 Medicare premiums and IRMAA tiers, state rates as of December 2026. Estimates, not tax advice.

Worked example

A single homeowner, age 64, sells a house for $1,250,000. They paid $350,000, spent $60,000 on improvements and pay $75,000 in selling costs. They have $70,000 of other income and do not collect Social Security yet.

Worked exampleAmount
Taxable gain (after the $250,000 home-sale exclusion)$515,000
Federal tax on the gain$77,510
Net investment income tax (3.8%)$14,630
California tax on the gain$50,882
Tax most calculators show$143,022
Extra tax on Social Security the sale makes taxable ($0 more taxable)$0
Medicare Part B + D surcharge two years later$7,186
Real cost$150,208

How capital gains on a house sale are calculated

Your taxable gain is the sale price, minus selling costs, minus your adjusted basis. Adjusted basis is what you paid, plus closing costs from the purchase, plus capital improvements. If you owned the home for more than a year the gain is long-term.

Sale priceAmount the buyer pays
minus selling costsAgent commissions, title and escrow, transfer taxes, legal
minus adjusted basisPurchase price + closing costs + improvements
minus Section 121 exclusionUp to $250,000 single, $500,000 married filing jointly
= taxable gainTaxed at 0/15/20%, plus 3.8% NIIT when income is high, plus state

The 2027 federal rates on a taxable house gain

For 2027 the long-term rate is 0% on taxable income up to $51,050 (single) or $102,100 (married), 15% above that up to $563,200 (single) or $633,600 (married), and 20% beyond. The 3.8% net investment income tax adds to gain when income passes $200,000 (single) or $250,000 (married). Your state tax comes on top; California taxes the gain as ordinary income at up to 13.3% with its mental health surcharge, while Texas, Florida, Nevada and a handful of other states have no income tax at all.

These are the numbers every calculator shows. The calculator above adds the two that depend on your age and benefits: the extra federal tax on Social Security that the gain makes taxable, and the Medicare Part B and D surcharge two years later.

What if I sell a house I have rented out or used for business?

Depreciation you claimed (or were allowed to claim) after May 6, 1997 comes back as unrecaptured Section 1250 gain, taxed at up to 25%, even if the rest of the gain falls inside the exclusion. If the house was a rental for years before it became your home, a portion of the gain can also fall outside the exclusion. For a house that is a pure rental, use the rental property calculator instead.

Frequently asked questions

How much is capital gains tax on the sale of a house?

Federal long-term capital gains tax is 0%, 15% or 20% in 2027, plus 3.8% on high incomes, plus your state tax. For a main home, the first $250,000 of gain ($500,000 married filing jointly) is excluded. Enter your numbers above for the exact estimate.

Do I pay capital gains tax if I sell my house and buy another?

Buying another home does not defer the gain on a personal residence; the rollover rule was repealed in 1997. You owe tax only on gain above the Section 121 exclusion, whether or not you buy again.

How long do I have to live in a house to avoid capital gains?

You need to have owned it and used it as your main home for at least 2 of the 5 years before the sale. The two years do not have to be consecutive. You can claim the exclusion once every two years.

How do I calculate the capital gain on my house?

Take the sale price, subtract selling costs, then subtract your adjusted basis (what you paid, plus closing costs and capital improvements). Subtract the Section 121 exclusion if you qualify. What is left is the taxable gain.

Does selling a house raise my Medicare premiums?

A taxable gain raises your modified adjusted gross income for the year. Medicare uses income from two years ago to set Part B and Part D surcharges, so a 2027 sale can raise your 2029 premiums if you cross an IRMAA tier. Anyone 63 or older at the sale is within range.

Is the house sale tax different in California?

California taxes capital gains as ordinary income at rates up to 12.3% plus a 1% mental health surcharge over $1 million. It has no separate break for home sellers, but it follows the federal Section 121 exclusion.

Run it on your real return

A free 15-minute call with Hans Goldstein: which levers fit your sale, what the Social Security and Medicare effects look like on your actual numbers, and what to ask your CPA.

Book 15 minutes 213-414-2808

Educational estimate, not tax, legal or financial advice. Figures use 2027 federal brackets and thresholds (IRS Rev. Proc. 2026-35), the Social Security benefit-taxation rules in IRC Section 86, CMS 2027 Medicare premiums and IRMAA tiers, and state rates as of December 2026 (California uses the FTB 2026 schedule until the 2027 schedule is published). Later Medicare years hold the 2027 tiers flat. Your CPA should confirm any figure before you act. By Hans Goldstein, EA, Enrolled Agent (enrolled to practice before the IRS), reviewed December 2026.

Run my numbers Book 15 min Call

Hans Goldstein is an Enrolled Agent, enrolled to practice before the Internal Revenue Service. Not affiliated with or endorsed by the IRS. General education, not tax or legal advice for your situation.