What's my home worth?Get a cash offerHow it worksStatesSelling guidesFor agents

Selling guides

Capital gains tax on a home sale

How federal capital gains tax works when you sell your home, including the $250,000 and $500,000 exclusion, how to figure your gain, and the cases where part of it can still be taxed. Every rule links to the IRS, and the dollar example is an estimate.

Last updated September 30, 2026

By Daniel Mac Sweeney

Capital gains on a home sale: guide cover

Take this guide with you

A printable PDF of this guide, with every source listed. Free, no email needed.

Download the PDF

Many homeowners owe no federal tax at all when they sell their main home, thanks to the home sale exclusion in Section 121 of the tax code. Others owe tax on part of the gain, usually because the gain is large, they did not live there long enough, or they rented the home or claimed depreciation at some point. This guide explains the rules in plain English, based on IRS Publication 523, Selling Your Home and IRS Topic 701.

This is general information, not tax or legal advice. Tax rules change and personal details matter, so check your own situation with a tax professional or the IRS before you rely on it.

The home sale exclusion: $250,000 or $500,000

If you qualify, you can exclude up to $250,000 of gain from your income, or up to $500,000 if you are married and file a joint return (IRS Topic 701). Excluded gain is simply not taxed. It is also not counted for the 3.8% net investment income tax (IRS Topic 559).

To qualify you generally need to pass three tests (IRS Publication 523):

  • Ownership. You owned the home for at least 24 months (2 years) during the 5 years before the sale.
  • Use. You lived in it as your main home for at least 24 months during those same 5 years. The two periods do not have to overlap, and the months do not have to be in a row (IRS Topic 701).
  • Look-back. You did not exclude gain from another home sale in the 2 years before this one.

For the full $500,000 on a joint return, both spouses must meet the use and look-back tests, and at least one must meet the ownership test (IRS Publication 523). Members of the military, Foreign Service and intelligence community on qualified extended duty can choose to suspend the 5 year period for up to 10 years (IRS Topic 701).

How to figure your gain

Your gain is not the sale price minus what you paid. It is your amount realized minus your adjusted basis (IRS Publication 523).

Amount realized is the sale price minus your selling expenses. Publication 523 lists selling expenses such as sales commissions, advertising fees and legal fees. Many of the costs in our closing costs by state guide count here, so keep your final settlement statement.

Adjusted basis usually starts with what you paid for the home, including the down payment and any amount you borrowed. Then you add certain settlement fees from your purchase, the cost of improvements, and some special assessments (IRS Publication 523).

The difference between an improvement and a repair matters:

  • Improvements add to basis. Publication 523 gives examples such as a bedroom addition, a new roof, a central air conditioning system and a modernized kitchen.
  • Repairs generally do not. Examples include painting inside or out, fixing leaks, filling holes or cracks and replacing broken hardware.

Keep receipts for improvements for as long as you own the home, and for several years after you sell. Without records, proving a higher basis is hard.

If the result is a loss, you cannot deduct it, but you also owe no tax on the sale (IRS Publication 523).

An example, clearly an estimate

If you do not meet the 2 year tests

You may still get a partial exclusion if the main reason you sold was a change in work location, a health reason, or certain unforeseeable events (IRS Publication 523). Publication 523 describes these as:

  • Work. For example, you took or were transferred to a new job at least 50 miles farther from the home than your old work location.
  • Health. You moved to obtain or provide medical care for yourself or a family member.
  • Unforeseeable events. Examples include the home being destroyed or condemned, a casualty loss, a death, a divorce or legal separation, or losing a job.

The partial exclusion is based on time. In broad terms you take the shortest of your time living there, your time owning it, and the time since you last used the exclusion, divide by 24 months, and multiply by $250,000 (or apply it per spouse on a joint return). Publication 523 has a worksheet for this.

Rentals, home offices and depreciation

If you ever rented out the home or used part of it for business, two extra rules can apply (IRS Publication 523):

  • Depreciation is not excluded. Any depreciation you claimed, or could have claimed, after May 6, 1997 for business or rental use cannot be covered by the exclusion. That part of the gain is taxable. Unrecaptured section 1250 gain from real property is taxed at a maximum rate of 25% (IRS Topic 409).
  • Nonqualified use. Periods after 2008 when the home was not your main home, such as years you rented it out before moving in, can reduce the share of gain you may exclude. There are exceptions, and Publication 523 walks through how to apply them.

A home office inside your house is treated more simply. If the business part is within your home, you generally do not need to split the gain between business and personal use, but you still cannot exclude the depreciation you took on it (IRS Publication 523). A separate building, such as a rented guest house, can be treated differently.

Inherited homes, Form 1099-S and state tax

Inherited homes. If you inherited the home, your basis is generally its fair market value on the date the previous owner died, or a later alternate valuation date if the estate used one (IRS Publication 523). This is often called a stepped-up basis. If you sell soon after inheriting, the gain may be small. You would usually not qualify for the $250,000 exclusion unless you also owned and lived in the home for 2 of the last 5 years.

Form 1099-S. The closing agent may report the sale to the IRS on Form 1099-S. The filer does not have to file one for a main home if the seller certifies in writing that the price was $250,000 or less ($500,000 or less for a married seller), that the full gain is excludable and that there was no nonqualified use after 2008 (IRS Instructions for Form 1099-S). You must report the sale on your return if you received a Form 1099-S, even if all the gain is excludable, or if you cannot exclude all of the gain. The sale goes on Form 8949 and Schedule D when required (IRS Topic 701).

State income tax. The federal exclusion is only half the picture. If your state has a personal income tax, any taxable part of your gain may be taxed there too, and rules differ by state. Some states have no personal income tax; Texas, for example, prohibits one in its constitution (Texas Constitution, Art. 8, Sec. 24-a). Check with your state's tax agency or a tax professional.

Your next step

Before you estimate your tax, estimate what the sale could bring. Gather your purchase closing statement and improvement receipts, then use the net proceeds calculator to see what you might keep after costs. For a local view of the market, you can request a free market report from one licensed local agent, or ask for a cash offer from one local cash buyer. See how it works and the transfer tax and closing rules on your state page.

Frequently asked questions

Do I pay capital gains tax when I sell my house?

Often not. If you owned and lived in the home for at least 2 of the last 5 years and have not used the exclusion in the past 2 years, you may exclude up to $250,000 of gain, or $500,000 on a joint return (IRS Topic 701). Gain above that may be taxed.

What if I have to sell before I have lived there 2 years?

You may qualify for a partial exclusion if the main reason for the sale was a job move, a health reason or certain unforeseeable events such as divorce, a death or losing a job. The amount is based on how long you owned and lived in the home (IRS Publication 523).

Can I deduct a loss on the sale of my home?

No. A loss on selling your personal home is not deductible, but you also owe no tax on the sale (IRS Publication 523).

Do I need to report the sale if all of my gain is excluded?

You must report it if you received a Form 1099-S, even when the whole gain is excludable (IRS Topic 701). If you did not receive one and you can exclude all of the gain, Topic 701 lists no reporting requirement, but check with a tax professional.

What counts as a home improvement for basis?

Things that add value or extend the home's life, such as an addition, a new roof, central air or a kitchen remodel. Routine repairs like painting or fixing leaks generally do not count (IRS Publication 523).

Thinking about selling?

Ask one licensed local agent for a free market report, or ask one local cash buyer for an offer. Free to ask, and you're not committing to anything.

Home valueCash offer