Various tax benefits may be available when you sell your principal residence. However, the rules can be complex, and careful planning is important to make the most of any applicable exclusions and deductions.
Under U.S. federal tax law, eligible homeowners may be able to exclude some or all of the gain from selling their main home. The amount you can exclude depends on factors such as how long you owned and lived in the property, whether you previously claimed the exclusion, and whether the property was used for business or rental purposes.
This guide explains the principal rules for calculating gain, determining your home’s tax basis, understanding the main-home exclusion, and identifying situations that may require additional tax planning.
Important: This article concerns U.S. federal tax law. Some provisions and examples in the original source are historical. Verify current IRS guidance and consult a qualified tax professional before making decisions about a home sale.
Table of Contents
- Principal Residence
- How to Figure Gain or Loss
- Non-Traditional Sales
- Basis
- Basis Other Than Cost
- Adjusted Basis
- Exclusion for Sales After May 6, 1997
- Recapture of Federal Subsidy
- Glossary
1. Principal Residence
For U.S. federal tax purposes, your main home is generally the home you live in most of the time. It may be a traditional house, condominium, cooperative apartment, mobile home, or houseboat.
For example, if you own a house in town where you live most of the year and also own a beach property used for summer holidays, the town property will generally be your main home.
Similarly, if you own one property but primarily live in a home you rent, the rented property may qualify as your main home for purposes of the home-sale exclusion.
If you own a second residence that has increased significantly in value, moving into it may not automatically make the gain eligible for exclusion. The ownership, use, and other eligibility requirements must still be satisfied. Obtain professional advice before making a decision based on potential tax benefits.
The federal home-sale exclusion is generally up to $250,000 of eligible gain for an individual taxpayer or up to $500,000 for qualifying married taxpayers filing jointly, subject to the applicable rules.
If you sell your home at a loss, the loss is generally considered a nondeductible personal loss. If your gain exceeds the available exclusion, you do not qualify for the exclusion, or special rules apply because of business or rental use, some or all of the gain may be taxable.
Taxable sales may need to be reported on IRS Form 8949 and Schedule D, depending on the circumstances and applicable reporting requirements.
2. How to Figure Gain or Loss
To determine whether you have a taxable gain or loss when selling your home, you generally need to calculate two amounts: the amount realized from the sale and the home’s adjusted basis.
Amount Realized
The amount realized generally starts with the selling price. This may include cash received, notes or other obligations, debts assumed by the buyer as part of the transaction, and the fair market value of property or services received.
Eligible selling expenses are then subtracted. Depending on the transaction, these may include real estate commissions, advertising expenses, legal fees, and certain other costs directly related to the sale.
Amounts received for personal property sold separately with the home, such as furniture or lawn equipment, generally need to be considered separately from the real estate sale.
Gain or Loss Calculation
The general calculation is:
- Amount realized: Selling price less eligible selling expenses.
- Adjusted basis: The home’s original or other basis, adjusted for qualifying increases and decreases.
- Gain or loss: Amount realized minus adjusted basis.
If the amount realized exceeds your adjusted basis, you generally have a gain. If it is lower, you generally have a loss, which is normally not deductible when the property is held for personal use.
Once the gain is calculated, determine whether you qualify for the principal residence exclusion and whether any portion of the gain remains taxable.
3. Non-Traditional Sales
Not every home transfer is a straightforward cash sale. Different rules may apply when you exchange one home for another, experience foreclosure, transfer a jointly owned property, or transfer a home to a spouse or former spouse.
Jointly Owned Homes
When spouses sell a jointly owned home and file a joint federal income tax return, they generally report the transaction together. If they file separate returns, each spouse may need to calculate and report their share according to their ownership interest and the applicable rules.
When a home is jointly owned by people who are not spouses, each owner generally calculates their own gain or loss based on their ownership interest and separately determines whether they qualify for the exclusion.
Trading One Home for Another
If you exchange an old home for another property, the transaction is generally treated as a sale of the old home and a purchase of the new one. You may therefore need to calculate any gain or loss on the property transferred.
For example, if a dealer accepts your old home as a trade-in toward a new property, the value credited for the old home may form part of its selling price. An outstanding mortgage assumed by the dealer may also affect the calculation.
Foreclosure or Repossession
If your home is foreclosed on or repossessed, the transfer is generally treated as a disposition of the property. You may need to determine whether the transaction results in a gain or loss and whether any canceled debt creates potential taxable income.
The calculation can depend on whether you were personally liable for the debt and whether the outstanding loan balance exceeded the property’s fair market value. The rules for recourse and nonrecourse debt differ.
In certain situations, canceled debt may be excluded from income under an applicable exception, such as qualifying insolvency or bankruptcy provisions. Eligibility depends on the facts and the law applicable to the year of cancellation.
Transfers to a Spouse or Former Spouse
A transfer of property between spouses, or between former spouses incident to divorce, generally does not result in immediate gain or loss under U.S. federal tax rules. The receiving spouse generally takes a carryover basis, subject to the applicable requirements.
These transfers can affect the basis and eventual tax consequences when the property is later sold. Obtain advice before transferring a home as part of a divorce or other family arrangement.
4. Basis
Your home’s basis is the starting point for determining gain or loss when you sell it. How you acquired the property generally determines the initial basis.
If you bought the home, the starting basis is generally its cost. If you built it, the basis generally includes the cost of the land and qualifying construction costs. If you received the property as a gift, inheritance, or transfer from another person, special basis rules may apply.
Your basis may change during the period you own the property. The adjusted basis is used to calculate gain or loss when the home is sold.
Cost as Basis
When you purchase a home, the initial basis generally includes the purchase price and certain qualifying settlement or closing costs. The purchase price may include cash paid, a down payment, and qualifying debt assumed or given to the seller as part of the purchase.
Some closing costs may be added to basis, while others are excluded. Costs that relate to obtaining a mortgage loan generally are not included in the home’s basis merely because they were paid at closing.
Examples of qualifying acquisition costs may include:
- Abstract or title search fees.
- Legal fees related to the purchase and preparation of the deed.
- Recording fees and surveys.
- Transfer taxes.
- Owner’s title insurance.
- Certain amounts owed by the seller that you agree to pay as part of the purchase.
- Qualifying costs for installing utility services.
Costs that generally do not increase basis include certain mortgage financing charges, mortgage refinancing fees, insurance premiums, and expenses related to occupying the property before closing. Escrow deposits for future taxes or insurance also require separate treatment.
Seller-Paid Points and Real Estate Taxes
Seller-paid mortgage points and real estate taxes paid around the time of purchase may affect basis depending on the transaction and the applicable tax rules. The treatment can depend on who paid the amount, what period it relates to, and whether the buyer reimbursed the seller.
Review the settlement statement and purchase records with your tax advisor to determine which amounts should be included in basis.
Building Your Own Home
If you build a home on land you own, basis generally includes the cost of the land, construction materials, paid labor, contractor charges, architect fees, building permits, qualifying utility connection charges, and certain related legal and closing costs.
You generally cannot include the value of your own unpaid labor in the property’s basis.
Condominiums and Cooperative Apartments
The basis of a condominium is generally determined using rules similar to those for other homes. For a cooperative apartment, basis is generally based on the cost of the stock or ownership interest in the cooperative housing corporation, subject to the applicable rules.
5. Basis Other Than Cost
If you did not acquire your home through a standard purchase, its basis may be determined using a different rule. The result can depend on whether the property was received as a gift, inherited, acquired through an exchange, or transferred from a spouse.
Home Received as a Gift
For a gifted home, the recipient’s basis for calculating gain is generally linked to the donor’s adjusted basis. Special rules may apply when the property’s fair market value at the time of the gift was lower than the donor’s basis, particularly when calculating a loss.
Gift-tax rules may also affect basis in certain circumstances. Because the calculations can be complex, retain records of the donor’s original cost, adjusted basis, and the property’s value at the time of the gift.
Home Received from a Spouse or Former Spouse
A transfer of a home between spouses, or between former spouses incident to divorce, generally does not trigger immediate gain or loss. The recipient’s basis is generally carried over from the transferring spouse, subject to the applicable rules.
If one spouse transfers their interest in jointly owned property to the other, the recipient generally combines the basis of the interest already owned with the basis of the transferred interest.
Home Acquired by Inheritance
Inherited property generally receives a basis determined by reference to its fair market value at the decedent’s date of death, or an applicable alternate valuation date when permitted and elected. Special rules and exceptions can apply depending on the estate and the circumstances.
For jointly owned property, the basis adjustment may depend on the type of ownership, state law, and whether the property is community property. The surviving spouse’s basis may therefore differ from the basis of the entire property before the other spouse’s death.
Home Acquired in a Trade
If you acquire a home by exchanging other property, the basis calculation depends on the nature of the transaction and the applicable tax rules. A trade of one home for another may be treated as a sale and a purchase, potentially resulting in a gain or loss.
Keep the transaction documents and consult a tax professional to determine the correct basis.
6. Adjusted Basis
Adjusted basis is the original or other basis of your home, increased or decreased by certain qualifying amounts during ownership.
Items That May Increase Basis
Qualifying capital improvements generally increase basis. These are changes that add value, extend the property’s useful life, or adapt it to a new use.
Examples may include:
- Adding a bedroom, bathroom, deck, garage, porch, or patio.
- Installing a new roof or upgrading electrical wiring.
- Adding central air conditioning or a new heating system.
- Modernizing a kitchen or installing built-in appliances.
- Installing a swimming pool, fence, driveway, or qualifying landscaping.
- Adding qualifying plumbing, insulation, or utility systems.
- Restoring property damaged by a casualty, where the costs qualify.
Improvements that have been removed or replaced generally cannot continue to be included in the home’s adjusted basis. For example, the cost of old carpeting that was replaced generally does not remain in basis after the replacement.
Items That May Decrease Basis
Certain payments, reimbursements, credits, and deductions may reduce basis. Examples can include:
- Depreciation allowed or allowable for business or rental use.
- Insurance payments or other reimbursements for casualty damage.
- Certain casualty-loss deductions.
- Payments received for granting an easement or right-of-way.
- Certain excluded debt-cancellation amounts related to the principal residence.
- Specific credits or subsidies that applicable tax rules require to reduce basis.
The original source includes several historical energy-related credits and other provisions. Their applicability depends on the year the credit or benefit was claimed and the rules that applied at that time. Do not reduce or increase basis based on an old list without verifying the specific provision.
Improvements Versus Repairs
Ordinary repairs generally maintain a home in good condition and do not increase basis. Examples include repainting, repairing leaks, fixing gutters, or replacing a broken windowpane.
However, repairs carried out as part of a larger renovation or restoration may be treated as part of the overall improvement, depending on the circumstances.
Recordkeeping
Keep records that support your original basis and every adjustment made during ownership. These may include:
- The purchase contract and settlement statement.
- Receipts for capital improvements and additions.
- Records of insurance reimbursements and relevant tax credits.
- Depreciation schedules if the property was used for business or rental purposes.
- Calculations of adjusted basis and gain or loss.
- Relevant tax forms and documents from previous property transactions.
Retain these records for as long as they may be needed to establish the property’s basis and to support the tax return for the sale. The necessary retention period can depend on the circumstances, so seek advice if a previous home’s basis affects the basis of a later property.
7. Exclusion for Sales After May 6, 1997
Under U.S. federal law, qualifying homeowners may generally exclude up to $250,000 of gain from the sale of a main home. Eligible married couples filing jointly may qualify for an exclusion of up to $500,000, provided the applicable requirements are met.
Ownership and Use Tests
To qualify for the full exclusion, you generally must meet these requirements during the five-year period ending on the sale date:
- Ownership test: You owned the home for at least two years.
- Use test: You used the home as your main residence for at least two years.
- Previous-sale rule: You generally did not exclude gain from the sale of another home during the two-year period ending on the current sale date.
The ownership and use periods do not necessarily have to be continuous, but both tests must be met within the applicable five-year period. Special rules can apply to temporary absences, disability, military or qualifying government service, divorce, and other circumstances.
Reduced Exclusion
If you sell your home before satisfying the full two-year ownership or use requirement, you may still qualify for a reduced exclusion in certain situations. Examples can include a qualifying change in employment location, health-related circumstances, or unforeseen events.
The amount of the reduced exclusion depends on the applicable rules and the circumstances leading to the sale. A preference to move to a different home or an improvement in your finances does not automatically qualify as an unforeseen circumstance.
More Than One Home
If you own more than one residence, generally only the property that qualifies as your main home is eligible for the exclusion. Your main home is usually the property where you live most of the time, based on the relevant facts and circumstances.
Selling vacant land separately from the home generally does not qualify for the principal residence exclusion on the land’s gain, even if the land is associated with the residence. The treatment can depend on the transaction and the applicable rules.
Married Taxpayers
Married taxpayers filing jointly may qualify for the larger exclusion if the applicable requirements are met. Generally, one spouse must meet the ownership test, both spouses must meet the use test, and neither spouse may be disqualified by certain prior home-sale exclusions.
If the spouses do not meet all the requirements for the joint exclusion, a different limit may apply. The result depends on each spouse’s ownership, use, and prior-sale history.
Special Situations
Additional rules may apply when:
- A spouse dies before the home is sold.
- The home is transferred between spouses or former spouses.
- The property is destroyed or condemned.
- The owner has certain qualifying military, Foreign Service, intelligence-community, or Peace Corps service.
- The taxpayer previously postponed gain under older home-sale rules.
- The home was used for business or rental purposes.
- The taxpayer sells another home within the relevant two-year period.
These situations can affect the ownership and use tests, the available exclusion, and the reporting requirements. Special rules may also apply when depreciation was allowed or allowable for business or rental use. In many cases, the portion of gain attributable to depreciation after May 6, 1997, cannot be excluded under the principal residence exclusion.
Because these rules depend heavily on the facts, review the transaction with a qualified tax professional before assuming the full exclusion is available.
8. Recapture of Federal Subsidy
If you financed your home through certain federally subsidized mortgage programs, such as a qualifying mortgage credit certificate or tax-exempt mortgage bond program, you may have to repay some or all of the federal tax benefit when you sell or otherwise dispose of the home.
This is sometimes referred to as recapture tax. It is separate from the tax calculation on the gain from selling the property, and it may apply even when some or all of the gain qualifies for the principal residence exclusion.
The recapture rules depend on the type of assistance received, when the property is sold, the amount of gain, and other statutory requirements. Review the original loan documents and consult your tax advisor to determine whether recapture applies.
9. Glossary
- Adjusted basis: The property’s basis after increases and decreases required by tax rules.
- Amount realized: Generally, the selling price minus eligible selling expenses.
- Basis: The amount used as the starting point for calculating gain or loss, determined by how the property was acquired.
- Date of sale: Generally, the date title transfers or the economic benefits and burdens of ownership shift to the buyer, depending on the transaction.
- Fair market value: The price property would reasonably command between a willing buyer and willing seller, with both parties having relevant knowledge and neither being compelled to transact.
- Fixing-up expenses: Certain expenses incurred to prepare a property for sale. Their tax treatment depends on the specific expense and applicable rules.
- Gain: Generally, the amount realized from the sale minus the adjusted basis.
- Improvements: Qualifying changes that add value, extend useful life, or adapt the property to a new use. They generally increase basis.
- Main home: The residence where a taxpayer lives most of the time, based on the relevant facts and circumstances.
- Repairs: Work that maintains the property in good condition without generally adding significant value or extending its useful life.
- Seller-financed mortgage: An arrangement in which the buyer makes mortgage payments to the seller rather than to a separate lender.
- Selling expenses: Qualifying costs directly associated with selling a property, such as certain commissions and legal fees.
- Settlement fees or closing costs: Charges associated with completing a property purchase or sale. Their treatment depends on the nature of each charge.
Final Thoughts
Minimizing tax on the sale of a home starts with understanding the principal residence exclusion, calculating the property’s adjusted basis accurately, and keeping complete records of purchase costs, improvements, and selling expenses.
Before selling, review whether you meet the ownership and use tests, whether prior home sales affect your eligibility, and whether business use, rental activity, debt cancellation, or mortgage assistance could change the tax outcome.
Important: This guide covers U.S. federal tax concepts. Some rules in the original source refer to historical legislation and may no longer apply in the same way. Confirm current IRS requirements and consult a qualified tax professional about your specific transaction.


