How do I calculate the gain/loss on my home for the IRS?

The details of how to calculate the gain or loss on the sale of a primary residence.

EVERYONE

Karianne Connor

3/13/20253 min read

home sales mean money and taxes
home sales mean money and taxes

Detailed IRS Rules for Calculating Gains and Losses on the Sale of a Primary Residence

It's not easy, and you need good records!

When selling a primary residence, you must calculate your capital gain or loss and determine how much, if any, qualifies for exclusion under Section 121. Below is a detailed breakdown of the necessary tests and calculations.

Step 1: Determine the Capital Gain or Loss

The capital gain or loss is determined using the following formula:

Capital Gain/Loss = Selling Price - Selling Expenses - Adjusted Basis

1. Selling Price

This is the total amount received for the home, including cash, property, or any assumed debt.

2. Selling Expenses

These include:

  • Real estate agent commissions

  • Title and escrow fees

  • Advertising costs

  • Legal fees

  • Home staging costs

3. Adjusted Basis

The adjusted basis is your original purchase price plus certain improvements minus depreciation (if applicable).

Adjusted Basis = Purchase Price + Improvements - Depreciation

Increase Basis for major improvements (e.g., additions, new roof, HVAC)

Decrease Basis for depreciation claimed for a home office or rental use

Step 2: Determine Eligibility for the Section 121 Exclusion

The $250,000/$500,000 capital gains exclusion applies if you meet the ownership and use tests:

1. Ownership Test

You must have owned the home for at least two years within the last five years before the sale.

2. Use Test

You must have lived in the home as your primary residence for at least two years (730 days) within the last five years.

3. Lookback Rule

You cannot have used the capital gains exclusion for another home sale within the last two years.

Example of Passing All Tests:

  • Bought a home in 2019 and lived in it full-time.

  • Sold the home in 2024.

  • No other homes were sold with an exclusion in the last two years. Full $250,000 ($500,000 for joint filers) exclusion applies.

Example of Failing the Use Test:

  • Bought a home in 2021 but rented it until 2023.

  • Lived in it for less than two years. No exclusion (unless a partial exclusion applies for special circumstances like job relocation or health issues).

Step 3: Business or Rental Use of the Home

If you used a portion of your home for business or rental, you must determine how much of the gain is taxable.

Scenario 1: Home Office (No Separate Structure)

  • If your home office was in the same dwelling and you did not claim depreciation, full gain is eligible for exclusion.

  • If you claimed depreciation, you must recapture depreciation as ordinary income.

Example Calculation for Depreciation Recapture:

  • Home office used 10% of the house.

  • Depreciation claimed over years: $5,000.

  • Home sold for a gain.

  • $5,000 is taxable as ordinary income, but the rest of the gain may be excluded.

Scenario 2: Separate Structure (e.g., Detached Garage)

A portion of the home used exclusively for business (like a detached office) does not qualify for the exclusion.

Gain on that portion is taxable as a capital gain, and depreciation must also be recaptured.

Example:

  • 20% of property was used for business in a detached structure.

  • Gain on home: $100,000.

  • 20% (or $20,000) is subject to capital gains tax.

  • Any depreciation claimed must be recaptured.

Step 4: Partial Exclusion for Unforeseen Circumstances

If you don’t meet the full two-year use requirement, you may still qualify for a partial exclusion if the sale was due to:

  • Job relocation (moving at least 50 miles away)

  • Health reasons

  • Unforeseen circumstances (e.g., divorce, natural disaster)

Example:

  • Lived in the home for 1 year (instead of 2).

  • Sold due to a job relocation.

  • You may be eligible for half of the exclusion:

  • $125,000 (single filer)

  • $250,000 (married filing jointly)

Step 5: Tax Treatment of a Loss

If you sell your home at a loss (i.e., adjusted basis > selling price), the loss is not deductible under IRS rules for personal-use property.

Would you like Coker Financial Services to help with a customized calculation for your specific situation?