Info from IRS.gov

It’s important for taxpayers to understand how selling their home may affect their tax return. When filing their taxes, they may qualify to exclude all or part of any gain from the sale from their income.

Here are some key things homeowners should consider when selling a home:

Ownership and use
To claim the exclusion, the taxpayer must meet ownership and use tests. During a five-year period ending on the date of the sale, the homeowner must have owned the home and lived in it as their main home for at least two years.

Gains
Taxpayers who sell their main home and have a gain from the sale may be able to exclude up to $250,000 of that gain from their income. Taxpayers who file a joint return with their spouse may be able to exclude up to $500,000. Homeowners excluding all the gain do not need to report the sale on their tax return.

Losses
Some taxpayers experience a loss when their main home sells for less than what they paid for it. This loss is not deductible.

Multiple homes
Taxpayers who own more than one home can only exclude the gain on the sale of their main home. They must pay taxes on the gain from selling any other home.

Reported sale
Taxpayers who don’t qualify to exclude all the taxable gain from their income must report the gain from the sale of their home when they file their tax return. Anyone who chooses not to claim the exclusion must report the taxable gain on their tax return. Taxpayers who receive Form 1099-S, Proceeds from Real Estate Transactions must report the sale on their tax return even if they have no taxable gain.

Possible exceptions
There are exceptions to these rules for some individuals, including persons with a disability, certain members of the military, intelligence community and Peace Corps workers.