Skip to main content
Taxes & Financing

How Do I Avoid Capital Gains Tax When Selling My Home?

Answered by John Smart, AI-Certified Agent™ Philadelphia Metro Published September 29, 2026 · Updated September 29, 2026 855 words
Short Answer

Most homeowners avoid capital gains tax by using the primary residence exclusion, up to $250,000 for a single filer and $500,000 for a married couple. Pennsylvania also excludes the gain on a principal residence you owned and lived in for 2 of 5 years.

The Primary Residence Exclusion Is the Big One

The most powerful way to avoid capital gains tax on a home sale is the primary residence exclusion. If you have owned and lived in the home as your primary residence for at least two of the five years before the sale, you can exclude up to $250,000 of gain from your taxable income if you are single, or up to $500,000 if you are married filing jointly.

Because this exclusion covers the gain, not the sale price, most homeowners in the Philadelphia area owe no capital gains tax at all when they sell. The median home in most of our markets has not appreciated enough to exceed the exclusion, especially for a couple. The exclusion is available once every two years, so it resets if you keep buying and selling.

What Pennsylvania Does Differently

Pennsylvania handles this with its own rule. Pennsylvania excludes the gain on the sale of your principal residence if you owned and used it as your home for at least two of the five years before the sale, and the state exclusion has no dollar cap. That is different from the federal rule, which has the $250,000 and $500,000 limits.

Pennsylvania also generally will not let you claim the exclusion if you already excluded gain on another principal residence within the prior two years, except for unforeseen circumstances like a job change or a health issue. And if part of your home was used for rental or business and you claimed depreciation, that portion of the gain does not qualify for the exclusion.

When You Might Still Owe Tax

You can still owe capital gains tax if your gain exceeds the exclusion, or if you do not meet the two-of-five-year rule. Gain above the exclusion is taxable, and it is taxed at capital gains rates, which are generally lower than ordinary income rates.

If you sell before owning and living in the home for two years, you may qualify for a partial exclusion if the sale is due to an unforeseen circumstance like a job relocation, a health issue, divorce, or a death in the family. Otherwise the full gain is taxable. Keeping records of your purchase price, improvements, and selling costs is what lets you calculate the true gain accurately.

Improvements Reduce Your Gain

Capital gains are calculated as sale price minus your cost basis, and your basis includes what you paid plus the cost of qualifying home improvements. Repairs that simply maintain the home do not count, but a new roof, a kitchen remodel, or a finished basement can add to your basis and lower your taxable gain.

This is why it pays to keep receipts for major improvements. A home bought for $300,000, improved with $60,000 of qualifying work, and sold for $500,000 has a gain of only $140,000, well within the exclusion. Without the improvement records, you might assume a larger gain than you actually have.

Selling Costs Count Too

Your selling costs, like real estate commissions, closing costs, and some transfer taxes, reduce your proceeds and therefore reduce your gain. Lower proceeds means a lower gain, which makes it easier to stay within the exclusion.

Your settlement statement from the sale records these costs. Keep it with your purchase documents and improvement receipts, because together they form the paper trail that shows your true gain if the IRS or Pennsylvania ever asks.

Smarty's Advice

For the overwhelming majority of my clients, capital gains tax on a home sale is a non-issue because the primary residence exclusion covers the gain. Do not let a fear of capital gains tax talk you out of selling a home you are ready to leave.

Keep records of what you paid, what you improved, and what you spent to sell, and confirm you meet the two-of-five-year rule before you close. If you are selling sooner than two years for a job or health reason, ask a tax professional about the partial exclusion, because you may still qualify.

Call 215-598-6848 or schedule a free consultation, and I will help you plan a sale that keeps your gain inside the exclusion.

John Smart

Smarty's Advice Expert Insight

John Smart (Smarty) · Smarty Home Solutions / eXp Realty Agent, AI Certified Agent

Let me make the exclusion concrete. Suppose a married couple bought a home for $350,000, lived in it for six years, and sell it for $600,000. Their gain is $250,000, before counting improvements and selling costs. Because they are married and meet the two-of-five-year rule, they can exclude up to $500,000. Their entire gain is covered, and they owe no federal capital gains tax.

Now suppose they sell for $900,000 instead. Their gain is $550,000, before improvements and costs. If they spent $50,000 on qualifying improvements, their gain drops to $500,000, still fully excluded. This is why keeping improvement receipts matters: it can be the difference between owing nothing and owing tax on the excess.

If their gain were $600,000, the extra $100,000 above the exclusion would be taxable at capital gains rates. In that case, Pennsylvania would also tax its share of the excess gain at its flat personal income tax rate, since the state exclusion has no dollar cap but only covers the excluded amount. Most sellers in our market never get close to these numbers, but the example shows why records and planning pay off.

John Smart

Answered by John Smart

AI-Certified Agent™ with eXp Realty | PA License RS348332

Serving Philadelphia, Montgomery, Bucks, Chester, Delaware & Berks Counties

Have Another Question?

Contact John Smart for personalized answers about your real estate situation. No obligation, just honest advice.

John Smart | AI-Certified Agent™ | License RS348332 | eXp Realty