IRS Tax Code Guide

Section 121: The Law That Lets Many Homeowners Exclude Capital Gains on the Sale of a Primary Residence

A plain-English walkthrough of IRC §121 — the 2-out-of-5-year rule, the $250K / $500K exclusion limits, and the exceptions and traps that catch homeowners by surprise.

What Section 121 Is

Internal Revenue Code Section 121 — formally titled "Exclusion of gain from sale of principal residence" — lets a qualifying homeowner exclude a substantial amount of capital gain on the sale of their primary home from federal taxable income.

Single Filer
$250,000
Maximum gain exclusion
Married Filing Jointly
$500,000
Maximum gain exclusion

To qualify for the full exclusion, you generally must have owned and used the home as your principal residence for periods totaling at least 2 years out of the 5-year window ending on the sale date. The exclusion is also generally limited to once every 2 years.

This is sometimes loosely called "the home sale capital gains exemption," but that label oversells it. Section 121 is an exclusion up to a cap, not a blanket exemption — gain above the cap, depreciation recapture, and certain disqualifying use periods can still create a tax bill.

Authoritative source: IRS Topic No. 701 — irs.gov/taxtopics/tc701. The detailed rules, worksheets, and examples live in IRS Publication 523, "Selling Your Home."

A Quick History — Why the Rule Looks the Way It Does Today

Section 121 was originally added to the Internal Revenue Code in 1964, but the version most homeowners know today was substantially rewritten by the Taxpayer Relief Act of 1997.

Before 1997, the federal rules looked very different:

The 1997 rewrite scrapped both of those and replaced them with the modern $250K / $500K recurring exclusion tied to ownership and use of a principal residence — no requirement to buy a replacement home, and no age requirement.

Why this history matters: Many sellers still vaguely remember being told they have to "buy another house to avoid the tax." That has not been the federal rule since 1997. Today's Section 121 is about ownership, use, and the 2-year look-back — not about reinvesting the proceeds.

The 2-Out-of-5-Year Rule, Broken Down

To claim the maximum Section 121 exclusion, you generally need to satisfy three tests in the 5-year period ending on the date of sale:

1. Ownership Test

You must have owned the home for at least 24 months (in total) during the 5-year period.

2. Use Test

You must have used the home as your main home for at least 24 months (in total) during the same 5-year period.

3. Look-Back / Frequency Test

You must not have excluded gain from the sale of another principal residence during the 2-year period ending on the date of this sale.

The 24 months of ownership and 24 months of use do not have to be the same 24 months, and they do not have to be continuous. Short, temporary absences (vacations, work travel) generally still count as use.

For married couples filing jointly to get the full $500,000 exclusion, additional joint-return conditions apply — at least one spouse must meet the ownership test, both spouses must meet the use test, and neither spouse can have excluded gain on another home in the prior 2 years.

What the IRS Considers a "Main Home"

If you only own one home and live in it, this is straightforward. If you own more than one residence — say a primary plus a vacation home, or a primary and a snowbird condo — the IRS treats the "main home" question as a facts-and-circumstances analysis.

Factors the IRS looks at include:

If you split time between two homes, only one can be your principal residence at any given time. Your records should be internally consistent — you do not want your tax return saying one home and your driver's license saying another.

Important Exceptions and Common Traps

Section 121 is generous, but it is not a blanket "no tax on home sales" rule. The most common ways homeowners get tripped up:

Depreciation Recapture (post–May 6, 1997)

If you ever rented the home out, used part of it as a home office, or otherwise took depreciation deductions on the property, the gain attributable to depreciation taken after May 6, 1997 is generally not excluded under Section 121. That portion of the gain is typically taxed as unrecaptured Section 1250 gain, currently capped at a 25% federal rate.

Periods of "Nonqualified Use"

For sales after January 1, 2009, gain attributable to periods when the home was not being used as a principal residence (for example, years when it was a rental) generally does not qualify for the exclusion. The gain has to be allocated between qualifying and nonqualifying use periods.

Like-Kind Exchange Lookback

If you acquired the home in a Section 1031 like-kind exchange, you generally cannot use Section 121 on the sale unless you have owned the property for at least 5 years after the exchange. This is meant to stop investors from converting investment property into a primary residence and immediately washing the gain through Section 121.

Other Common Traps

Special Rules That Can Help

The statute and IRS guidance also provide specific accommodations for:

Partial Exclusions — When You Don't Quite Meet the Tests

A homeowner who fails the full 2-out-of-5-year test may still qualify for a reduced (partial) exclusion if the sale was primarily because of one of three IRS-recognized reasons:

1. Work-Related Move

A change in place of employment that meets specific distance and timing tests — generally, the new job has to be at least 50 miles farther from the old home than the old job was.

2. Health

A move to obtain, provide, or facilitate the diagnosis, cure, mitigation, or treatment of a disease, illness, or injury — for the homeowner, a spouse, a co-owner, or another qualifying family member.

3. Unforeseeable Events

Specific events the IRS treats as qualifying — such as natural or man-made disasters, certain involuntary conversions, multiple births from a single pregnancy, divorce or legal separation, death, change in employment status that leaves the household unable to pay basic expenses, and other facts-and-circumstances events.

A partial exclusion is calculated by taking the maximum exclusion ($250K or $500K) and multiplying by a fraction — the shorter of (a) time you owned the home, (b) time you used the home as a main home, or (c) time since your last excluded sale — over 2 years (730 days).

Worked example: A married couple lived in their home for 12 months before a job-related relocation forced a sale. Their maximum partial exclusion would be $500,000 × (12 / 24) = $250,000 of gain potentially excludable, even though they did not meet the full 2-year use test.

Partial-exclusion math is sensitive to facts and dates. Run the actual numbers with a CPA before relying on a partial exclusion in any sale plan.

Frequently Asked Questions

Do I have to buy another home to avoid the tax?
No. That was the old Section 1034 rollover rule, which Congress repealed in 1997. Today's Section 121 does not require you to buy a replacement home.
How often can I use the Section 121 exclusion?
Generally once every 2 years. You cannot have excluded gain on another principal residence sale during the 2-year period ending on the date of the new sale.
Does the exclusion apply to state taxes?
Section 121 is a federal rule. Most states with an income tax conform to it, but conformity is not automatic. Florida (no state income tax) is a non-issue; if you live in or sell in another state, confirm the state rule.
What counts as the "gain" — sale price minus original purchase price?
Not exactly. The taxable gain is generally the amount realized (sale price minus selling costs) minus your adjusted basis (original cost plus qualifying capital improvements minus depreciation taken). Improvements like a new roof, HVAC, or addition can raise your basis and reduce gain — keep records.
What if my gain is more than $250K / $500K?
The excess is generally taxed as long-term capital gain (assuming you owned the home more than a year). Federal long-term capital gains rates are 0%, 15%, or 20% depending on taxable income, plus the 3.8% Net Investment Income Tax for some higher earners.
I rented the house out for a few years — does Section 121 still apply?
Possibly, but with two reductions: (1) gain attributable to depreciation taken after May 6, 1997 is recaptured and not excludable, and (2) gain allocated to nonqualified-use periods (years it was not your principal residence) generally does not qualify for the exclusion.
Does refinancing or taking out a HELOC affect Section 121?
No. Section 121 is about gain on sale, not about debt. Refinancing, HELOCs, and reverse mortgages do not reduce the exclusion. They can affect your net cash at closing, but not your taxable gain calculation.
How is gain reported on my tax return?
If all of the gain is excluded, you generally do not have to report the sale at all (unless you received a Form 1099-S). If any portion is taxable — because of an excess over the cap, depreciation recapture, or a partial exclusion — the sale is reported on Form 8949 and Schedule D.

Related Tool: Florida Net Seller Calculator

Section 121 tells you what the IRS will (and won't) tax. The next question every Florida seller asks is "how much do I actually walk away with at the closing table?" Run the numbers on commissions, doc stamps, prorations, and payoff with our Florida Net Seller calculator.

Open the Florida Net Seller Calculator →

Thinking About Selling? Talk to Todd Before You Do.

Section 121 is one of the largest single tax breaks in the federal code — and one of the easiest to accidentally disqualify yourself from. Before you list, let's run the actual numbers, look at the timing, and coordinate with your CPA.

Compliance & Sources

This is general educational information about IRC §121, not tax or legal advice. Tax outcomes depend on your specific facts, filing status, basis history, prior depreciation, and state of residence. Before relying on any rule discussed here, consult a CPA, Enrolled Agent, or tax attorney about your situation. Todd Hanley and the Todd Hanley Mortgage Team do not provide tax or legal advice.

Primary sources referenced on this page:

Schedule Your Free Strategy Session

Select a date and time that works for you

Loading available times...

Sun
Mon
Tue
Wed
Thu
Fri
Sat
Available times:
Your Selected Time

You're All Set!

Your strategy session has been scheduled. You'll receive a confirmation email shortly.

Date & Time
Duration30 minutes
WithTodd Hanley, RICP®