What capital gains tax is and when you owe it
Capital gains tax is what you pay on the profit when you sell real estate for more than you paid for it. If you bought a house for $300,000 and sold it for $500,000, your gain is $200,000. The federal government taxes that $200,000 at either 0%, 15%, or 20% depending on your income level — separate from your regular income tax rate.
You do not owe capital gains tax on the full sale price. You owe it only on the difference between what you paid (your "basis") and what you sold it for (your "amount realized"). The longer you own the property, the more strategies become available to you, because tax law treats long-term gains — property held over one year — much more favorably than short-term gains.
State and local taxes add another layer. Some states tax capital gains as regular income; others do not tax them at all. New York, California, and Illinois all tax capital gains, while states like Florida, Texas, and Nevada do not. Where you live when you sell matters significantly to your total tax bill.
Key Takeaways
- The primary residence exclusion lets you exclude up to $250,000 of gain ($500,000 if married filing jointly) if you owned and lived in the home for at least two of the last five years before sale.
- A stepped-up basis at death means heirs inherit property at its market value on the date of death, erasing all capital gains tax on appreciation during the original owner's lifetime.
- 1031 exchanges allow you to defer capital gains tax indefinitely by selling one investment property and buying another of equal or greater value within strict timelines.
- Installment sales spread the gain across multiple years, potentially keeping you in lower tax brackets and reducing your total federal tax.
- Charitable donations of appreciated property let you avoid capital gains tax entirely while receiving a charitable deduction for the full market value.
The primary residence exclusion: your biggest opportunity
If you sell your main home, you can exclude up to $250,000 of capital gain from federal tax ($500,000 if you are married filing jointly). This is the single most powerful tool most homeowners have. You do not need to reinvest the money or meet any income requirement — you just need to have owned the home and lived in it as your primary residence for at least two of the five years before you sell.
The two years do not have to be consecutive. If you owned a house for six years but lived in it for only two of those years, you still may have access to. If you lived in it for three years, you still may have access to. The IRS is checking whether you spent enough time there to call it your home, not whether you lived there the entire time you owned it.
You can use this exclusion once every two years. If you sold a home in 2022 and used the exclusion, you cannot use it again until 2024. This rule exists to prevent people from flipping homes and treating each sale as a primary residence.
State taxes do not follow the federal rule. Some states offer their own primary residence exclusion; others do not. California, for example, does not exclude capital gains on primary residences from state tax, so you would owe federal tax (possibly zero) but still owe California tax on the gain.
Stepped-up basis: the inheritance advantage
When you inherit real estate, the property's tax basis "steps up" to its market value on the date of the owner's death. If your parent bought a rental property for $150,000 and it was worth $400,000 when they died, your basis becomes $400,000. If you sell it immediately for $400,000, you owe zero capital gains tax because you have zero gain.
This is not a strategy you control — it is automatic. But it is why holding appreciated property until death can be more tax-efficient than selling it during your lifetime. The $250,000 of appreciation during your parent's ownership vanishes from the tax system entirely.
Stepped-up basis applies to all inherited property: homes, rental buildings, vacant land, commercial real estate. It applies regardless of how long the deceased owned the property or how much it appreciated. The only requirement is that you inherit it through a will, trust, or intestacy — not through a gift during the owner's lifetime.
This advantage may change. Congress has proposed eliminating or limiting stepped-up basis for high-value estates, but as of now it remains law. If you are planning a large real estate transfer to heirs, consult a tax professional about the current rules and any pending changes.
1031 exchanges: deferring tax on investment property
A 1031 exchange (named after the tax code section) lets you sell one investment property and buy another without paying capital gains tax on the sale — as long as you follow strict rules. You can defer the tax indefinitely by doing another 1031 exchange when you sell the replacement property.
The replacement property must be of equal or greater value. If you sell a rental house for $500,000, you must buy a replacement property for at least $500,000. If you buy one for $450,000, you owe capital gains tax on the $50,000 difference. The properties must also be "like-kind" — real estate for real estate. You cannot exchange a house for a car or a stock portfolio.
Timing is rigid. You have 45 days from the sale to identify the replacement property and 180 days to close on it. You cannot hold the money yourself; a may have access to intermediary must hold it during the exchange. If you touch the cash, the exchange fails and you owe the tax immediately.
1031 exchanges work only for investment property and property held for business use. Your primary residence does not may have access to. If you own a rental house, a commercial building, or vacant land you plan to develop, a 1031 exchange is available to you. If you own your home, it is not.
Installment sales: spreading gains across years
An installment sale means you sell the property but the buyer pays you over time instead of all at once. You report the gain proportionally as you receive payments, which can keep you in lower tax brackets across multiple years instead of pushing all the gain into one year.
If you sell a property with a $300,000 gain and receive the payment over five years, you report $60,000 of gain each year. Depending on your other income, this might keep you in the 15% capital gains bracket instead of pushing you into the 20% bracket. Over five years, the tax savings can be substantial.
Installment sales require a promissory note and a mortgage or deed of trust on the property. You are essentially becoming the lender. The buyer makes monthly payments to you, and you report the income as you receive it. If the buyer defaults, you can foreclose.
This strategy works best when you do not need all the cash immediately and when you expect your income to be lower in future years. It also works well if you are near a tax bracket threshold and want to avoid crossing it in a single year.
Charitable donations of appreciated property
If you donate appreciated real estate to a may have access to charity, you avoid capital gains tax entirely and receive a charitable deduction for the full market value of the property. If you own land worth $500,000 that you bought for $200,000, you can donate it, deduct $500,000, and owe zero capital gains tax on the $300,000 gain.
The property must go to a may have access to organization — typically a nonprofit with 501(c)(3) status. The charity must use the property for its charitable mission. You cannot donate a rental house to a charity and have them rent it out; the property must further the charity's actual work.
You need a may have access to appraisal and must file Form 8283 with your tax return. The deduction is limited to 30% of your adjusted gross income in the year of donation, though unused deductions can carry forward to future years.
This strategy works best when you have appreciated property you do not need, a high income that makes the deduction valuable, and a charity whose mission aligns with your values. It is particularly useful for vacant land or commercial property that is difficult to sell.
Timing the sale and managing your income
The year you sell matters because capital gains tax is based on your total income. Long-term capital gains are taxed at 0%, 15%, or 20% depending on your tax bracket. If you are in the 12% ordinary income bracket, your long-term gains are taxed at 0%. If you are in the 22% bracket, your gains are taxed at 15%.
You can sometimes reduce your tax by timing the sale to a year when your income is lower. If you are retiring, selling in the year you retire (when your income drops) instead of the year before can save you thousands. If you have a large deductible expense coming — a business loss, charitable donation, or medical expense — timing the sale for that year can offset some of the gain.
Married couples filing jointly have wider tax brackets than single filers, so the same gain may be taxed at a lower rate. If you are unmarried and selling a high-value property, getting married before the sale could reduce your tax, though this is rarely the primary reason to marry.
State taxes do not follow federal brackets. Selling in a low-tax state instead of a high-tax state can save significantly. Some people move before selling for this reason, though you must genuinely establish residency — not just claim it on paper.
Working with a tax professional on your specific situation
Capital gains tax rules interact with your other income, deductions, state taxes, and long-term financial plans in ways that are difficult to predict without detailed analysis. A tax professional or CPA can model different scenarios: selling this year versus next year, using a 1031 exchange versus a charitable donation, timing the sale around retirement or a business event.
Real estate transactions often involve multiple tax issues at once. If you are selling an investment property, you may owe capital gains tax, depreciation recapture tax (a separate 25% tax on the depreciation you claimed), and state tax. A professional can show you the total bill and whether strategies like a 1031 exchange or installment sale actually save money after all taxes.
If you are inheriting property, a professional can advise on stepped-up basis, whether to sell immediately or hold, and how to structure the inheritance to minimize taxes for your heirs. If you are donating property, they can ensure the appraisal and documentation meet IRS standards so the deduction holds up if audited.
Frequently Asked Questions
Can I use the primary residence exclusion if I rent out part of my home?
You can use the exclusion on the portion you lived in, but not on the portion you rented out. If you rented out 20% of the home, you exclude 80% of the gain. The IRS looks at square footage or rooms used for rental versus personal use.
What happens to capital gains tax if I sell to my child?
You still owe capital gains tax on the gain, even if the buyer is your child. The relationship does not change the tax. However, you could gift the property to your child before selling (using your lifetime gift tax exemption), and then your child would have a stepped-up basis if you die before the sale, or they could sell and owe tax on only the gain after they received it.
Do I owe capital gains tax if I sell at a loss?
No. If you sell for less than you paid, you have a capital loss, not a gain. You cannot deduct the loss against capital gains from real estate, but you can use it to offset other capital gains (from stocks, for example) or up to $3,000 of ordinary income per year. Unused losses carry forward indefinitely.
Can I do a 1031 exchange if I own the property with someone else?
Yes, but both owners must participate in the exchange. If you own a rental house with your sibling and want to do a 1031 exchange, you both must agree and both must receive replacement property. You cannot exchange your half while your sibling keeps theirs.
What if I inherited property and want to sell it quickly — do I still get stepped-up basis?
Yes. Stepped-up basis happens automatically when you inherit, regardless of when you sell. You could inherit property on Monday and sell it on Tuesday and owe zero capital gains tax. The basis is stepped up to the date-of-death value, not the sale price.