The basic Section 121 exclusion rule
IRS Code Section 121 allows a homeowner to exclude up to $250,000 of gain from the sale of a principal residence ($500,000 for married couples filing jointly) if they owned and used the home as their principal residence for at least 2 of the 5 years before the sale. The two years do not need to be consecutive, and a taxpayer can generally claim the exclusion only once every two years.
The exclusion applies only to gain — the amount realized over the property's adjusted basis. Depreciation taken on any portion of the home used for business or rental purposes reduces the adjusted basis and creates depreciation recapture that survives the exclusion. For most homeowners who never rented or used their home for business, the full exclusion is straightforward. The complexity arises when the property has a rental or business history.
Converting a rental back to a primary residence: the nonqualified use rule
The nonqualified use rule, enacted as part of the Housing Assistance Tax Act of 2008 (effective for sales after December 31, 2008), limits the exclusion when a home was used for purposes other than as a principal residence during part of the ownership period. Specifically, gain attributable to periods of nonqualified use cannot be excluded.
Nonqualified use generally means any period the home was not used as your principal residence, with exceptions for temporary absences (up to two years for certain qualified reasons), periods before May 6, 1997, and periods when the home was used as a principal residence at some point in the ownership period. Under the look-back rule: if you owned a property for 10 years, rented it for 3 years, then lived in it for 2 years, the 3 years of rental use (if it occurred after January 1, 2009) constitutes nonqualified use that proportionally reduces the exclusion.
The exclusion reduction is proportional: the nonqualified-use percentage equals the period of nonqualified use divided by the total ownership period. In the example above, 3 years out of 10 = 30% of the gain cannot be excluded. If total gain is $200,000, $60,000 is taxable and $140,000 is excluded (subject to the dollar cap). Note: rental use before the home was first used as a principal residence is treated differently than rental use after, and the post-residence rental period is disregarded in the nonqualified-use calculation.
When you rented a room: partial business use in a primary residence
Some homeowners rent out a room or portion of their home while still living there. For Section 121 purposes, the treatment depends on whether the rental was part of the same dwelling unit or a separate structure.
If the rental was a portion of the same dwelling unit (a bedroom, a basement apartment that shares walls and utilities), the IRS generally allows the full exclusion on gain attributable to that portion, as long as the home was used as a principal residence for the required two years and any depreciation is recaptured. If the rental was in a separate structure (a detached garage apartment, a separate dwelling unit on the property), the Section 121 exclusion does not apply to the separate structure, and the gain on that portion is fully taxable capital gain.
Depreciation claimed on the room-rental portion reduces your adjusted basis and must always be recaptured — the Section 121 exclusion cannot shelter depreciation recapture, only appreciation.
Depreciation recapture always survives the Section 121 exclusion
This is the most important rule: depreciation taken on any portion of the property (for a home office, a rental room, or a period when the whole property was a rental) is never excluded under Section 121. IRC Section 121(d)(6) specifically provides that the exclusion does not apply to gain equal to the depreciation adjustments attributable to periods after May 6, 1997.
What this means in practice: if you rented your home for five years and took $50,000 of depreciation, and then lived in it for three years before selling, the entire $50,000 of depreciation is recaptured as unrecaptured Section 1250 gain at up to 25%, regardless of how much other gain is excluded under Section 121. You might exclude $200,000 of appreciation from the sale but still owe tax on all $50,000 of accumulated depreciation.
The recaptured depreciation is reported on Form 4797 Part III and flows to the Unrecaptured Section 1250 Gain Worksheet on Schedule D. The amount is the total straight-line depreciation allowed or allowable during the rental periods, including any years where no depreciation was actually claimed.
Computing the gain and exclusion on a converted property: step-by-step
Here is the computation framework for a home that was rented and then converted back to a primary residence before sale.
Step 1: Determine selling price and adjusted basis. Adjusted basis = original cost + improvements minus depreciation allowed or allowable. Step 2: Compute total gain (selling price minus adjusted basis). Step 3: Identify the nonqualified-use percentage (total rental/business period after January 1, 2009 divided by total ownership period). Step 4: Compute excluded gain = total gain times (1 minus nonqualified-use percentage), capped at the Section 121 exclusion limit. Step 5: Subtract depreciation recapture from excluded gain — depreciation is never excluded regardless of the ratio. Step 6: Remaining gain after exclusion and separate from depreciation = taxable long-term capital gain at 0%/15%/20% rates.
The math can be complex when ownership periods are long and the home shifted between rental and personal use multiple times. A tax advisor or the capital gains calculator can walk through the scenario with actual numbers.
Partial exclusion: reduced maximum for certain life events
Even if you do not meet the full two-year ownership-and-use test, you may be eligible for a partial exclusion if the sale was triggered by a qualifying event: a change in place of employment, health reasons, or unforeseen circumstances (divorce, death, multiple births from the same pregnancy, a natural disaster, and similar hardships recognized by the IRS).
The partial exclusion is computed by multiplying the maximum exclusion ($250,000 or $500,000) by a fraction: the number of qualifying days of ownership and use divided by 730 (two years). So someone who owned and used the home for 14 months before a qualifying job relocation could exclude up to 14/24 times $250,000 = approximately $145,833 of gain. Depreciation recapture still applies even to the partial exclusion scenario.
Section 121 and a 1031 exchange: can you combine them?
Some homeowners with mixed-use properties (partly personal residence, partly investment) have asked whether they can use Section 121 on the residential portion and a 1031 exchange on the investment portion of the same sale. The IRS addressed this in Rev. Proc. 2005-14 and generally permits a bifurcated treatment: the personal-use portion of the gain is potentially excluded under Section 121 (subject to the nonqualified-use limitation), and the investment-use portion is potentially deferrable under Section 1031, as long as the taxpayer properly allocates the sale price and basis between the two portions.
This bifurcation requires careful documentation of the allocation, separate treatment on the tax return, and compliance with both the Section 121 eligibility requirements and the Section 1031 exchange mechanics (including a qualified intermediary for the exchange portion). It is most commonly used for a duplex where the owner occupies one unit and rents the other, and is selling both units in a single transaction.
A worked example: a rental converted back to a home
Suppose a married couple bought a home in 2014 for $300,000, rented it from 2016 through 2020 (five years), taking $45,000 of depreciation, then moved back in and used it as their principal residence from 2021 until selling in 2025 for $700,000. Total ownership is about 11 years. Their adjusted basis is $300,000 minus $45,000 of depreciation, or $255,000, so total gain is $445,000.
First, the $45,000 of depreciation is recaptured as unrecaptured Section 1250 gain at up to 25%; Section 121 can never shelter it. Of the remaining $400,000 of gain, the nonqualified-use fraction is the post-2008 rental period over total ownership, roughly five years out of eleven, or about 45%, so approximately $180,000 of gain is taxable and cannot be excluded. The balance, about $220,000, falls within the couple's $500,000 joint exclusion. The couple excludes about $220,000, pays long-term capital gains tax on roughly $180,000, and pays up to 25% on the $45,000 of recaptured depreciation.
Common mistakes with Section 121 and rental history
The most common misconception is that living in a former rental for two years wipes out all the tax. It does not: depreciation recapture always survives, and the nonqualified-use rule taxes the share of gain tied to the rental years. A second mistake is miscounting the nonqualified-use period, because rental use after the home was last a principal residence, and periods before 2009, are treated under special rules, so the fraction is not simply every non-residence day.
A third error is failing to report the sale when depreciation was taken. Even if the gain is fully excluded, a sale involving prior depreciation generally must be reported on Form 8949, Schedule D, and Form 4797, with the depreciation recapture flowing through the Unrecaptured Section 1250 Gain Worksheet. Skipping the reporting because the gain is excluded can draw an IRS notice when the prior depreciation deductions are already on record.
The military and Foreign Service suspension of the five-year test
Members of the uniformed services, the Foreign Service, and the intelligence community can elect to suspend the five-year ownership-and-use testing period for up to ten years during qualified official extended duty, under IRC Section 121(d)(9). This lets a service member who was stationed away from home for years still meet the two-of-five-years test and claim the exclusion on a home that was rented out during the assignment.
The suspension does not change the depreciation-recapture rule: any depreciation taken while the home was rented during the assignment is still recaptured. But it can preserve the exclusion on appreciation that would otherwise be lost to the nonqualified-use or two-year tests. Eligible taxpayers should document the dates of qualified extended duty and make the election on the return for the year of sale.
Section 121 and home offices: depreciation recapture on business use portions
If you claimed a home office deduction at any point during ownership — whether for self-employment under Section 280A or as a trade-or-business space — you reduced your adjusted basis by the depreciation claimed on that portion. That depreciation is recaptured under Section 121(d)(6) and is taxable even if the rest of the gain is fully excluded.
The recapture amount equals the total depreciation allowed or allowable on the home office or business portion after May 6, 1997. The recaptured amount is unrecaptured Section 1250 gain, taxed at up to 25%. A homeowner who claimed a $1,200 annual home office depreciation deduction for 10 years has $12,000 of recapture exposure at sale, regardless of how much other gain is excluded. If you ever claimed a home office, locate the Form 8829 filings from those years to identify the cumulative depreciation before you sell, so there are no surprises on Form 4797. Stopping home office deductions several years before a sale does not eliminate prior recapture — the 'allowed or allowable' standard applies regardless of when you stopped claiming.
Basis planning before you sell: steps to maximize the Section 121 exclusion
Because the Section 121 exclusion is capped at $250,000 (single) or $500,000 (joint), sellers of highly appreciated homes sometimes take targeted steps to reduce the taxable gain above the exclusion. The most straightforward is documenting all capital improvements: a new roof, kitchen renovation, HVAC replacement, addition, or landscaping project all increase adjusted basis dollar-for-dollar, reducing the gain recognized. For a home held 20+ years, documented improvements can add $100,000–$200,000 or more to basis.
Other considerations: if the home was used partly for rental and partly as a primary residence (a duplex situation), confirm you are correctly allocating the exclusion and gain between the two portions under Rev. Proc. 2005-14. If you have suspended passive losses from the rental period, those losses release when the rental activity is fully disposed of in a taxable sale — which may offset some taxable gain above the exclusion. And if the gain above the exclusion is very large (for example, a long-held property in a high-appreciation market), consider the installment sale method to spread the taxable portion across years, potentially keeping it at the 15% long-term capital gains rate rather than the 20%/23.8% rate that applies at higher incomes.
Inherited or co-owned homes: Section 121 eligibility
When you inherit a home and sell it, the Section 121 exclusion is generally unavailable because you almost certainly have not lived there for two of the last five years. Instead, inherited property gets a step-up in basis to fair market value at the date of the decedent's death under Section 1014, so most heirs owe little or no capital-gains tax regardless of the exclusion. If you inherit and then move into the home and live there for at least two years before selling, you can then claim the Section 121 exclusion on appreciation above the stepped-up basis.
For co-owned homes — a home held jointly with someone other than a spouse — each co-owner applies the Section 121 exclusion independently based on their own ownership and use. On a jointly owned home where both owners have lived there for two of the last five years, each can potentially exclude up to $250,000 of their own share of the gain, for a combined effective exclusion of $500,000 on a tenancy-in-common. If only one co-owner qualifies, only that owner's share of the gain is eligible for exclusion. Unmarried joint owners cannot 'pool' their exclusions the way a married couple filing jointly does.
Frequently asked questions
What is IRS Code Section 121?
Section 121 of the Internal Revenue Code allows a homeowner to exclude up to $250,000 ($500,000 MFJ) of gain from the sale of their principal residence if they owned and used it as their primary home for at least 2 of the 5 years before the sale.
Does Section 121 exclude depreciation recapture?
No. IRC Section 121(d)(6) explicitly provides that the exclusion does not apply to gain equal to depreciation adjustments attributable to periods after May 6, 1997. All depreciation taken on a rental or home-office portion is recaptured as ordinary income even if other gain is excluded.
What is the nonqualified use rule for Section 121?
Gain attributable to periods when the home was not used as a principal residence (after January 1, 2009) cannot be excluded. The nonqualified-use percentage equals the non-residence period divided by the total ownership period, and that fraction of the gain remains taxable.
Can I get a partial Section 121 exclusion if I don't meet the two-year test?
Yes, if the sale was forced by a qualifying event: change of employment, health reasons, or other IRS-recognized unforeseen circumstances. The partial exclusion equals the maximum exclusion times the fraction of two years you actually owned and used the home as your primary residence.
How do I report the Section 121 exclusion on my tax return?
Generally on Form 8949 and Schedule D. If the full gain is excluded and no depreciation recapture applies, you may not need to report the sale at all. If depreciation is involved or only a partial exclusion applies, report the sale on Form 8949 and any depreciation recapture on Form 4797 and the Unrecaptured Section 1250 Gain Worksheet.
If I live in my former rental for two years, do I avoid all tax when I sell?
No. Depreciation recapture always survives the Section 121 exclusion, and the nonqualified-use rule taxes the portion of gain attributable to the years the property was rented after 2008. Living in the home for two of the last five years can exclude the qualified-use portion of appreciation up to the dollar cap, but not the recaptured depreciation or the nonqualified-use share.
Can a service member stationed away still claim the Section 121 exclusion?
Yes. Under IRC Section 121(d)(9), members of the uniformed services, Foreign Service, and intelligence community can elect to suspend the five-year test for up to ten years of qualified official extended duty, allowing them to meet the two-year use requirement even if the home was rented out during the assignment. Depreciation taken during the rental period is still recaptured.
Sources
- IRS Topic No. 409 — Capital Gains and Losses
- IRS Publication 544 — Sales and Other Dispositions of Assets
- IRS Publication 946 — How to Depreciate Property
Educational information and estimates only. Not tax advice. Tax rules change and vary by situation; consult a qualified tax professional before acting.
