Capital Gains Tax Shelter: 1031 Exchanges, QOFs, and More

Capital gains tax shelters are legal strategies that defer, reduce, or permanently eliminate the tax you owe when you sell an asset for more than you paid. Some are simple timing moves anyone can use; others are structured transactions that need a tax advisor and years of planning. The right choice depends on what you’re selling, how long you’ve held it, and what you want to do with the proceeds.

The stakes vary with your bracket. Long-term capital gains are taxed at 0%, 15%, or 20% depending on your income, but high earners owe an extra 3.8% surtax on top, and gains on anything held a year or less are taxed as ordinary income at rates up to 37%.1Internal Revenue Service. Topic No. 409 Capital Gains and Losses

Hold Assets Longer Than One Year

The simplest shelter is patience. Sell within a year of buying and the profit is a short-term gain, taxed at your ordinary income rate. Hold past the one-year mark and the same profit becomes a long-term capital gain, taxed at the preferential 0%, 15%, or 20% rate.1Internal Revenue Service. Topic No. 409 Capital Gains and Losses

For someone in the top bracket, that gap is 37% versus 20%. A high-income investor who delays a sale by even a few weeks to cross the one-year line can save 17 or more percentage points on the same profit. The 2026 thresholds are inflation-adjusted, with single filers paying 0% on long-term gains if taxable income stays below roughly $49,450 and the 20% rate applying above approximately $545,500.

Offset Gains With Losses

Tax-loss harvesting uses losing investments to cancel out winning ones. You sell an asset that has dropped in value, lock in the loss, and apply it against capital gains realized during the same year. Losses offset gains of the same type first (short-term against short-term, long-term against long-term).1Internal Revenue Service. Topic No. 409 Capital Gains and Losses

If losses exceed gains for the year, you can deduct up to $3,000 of the remaining net loss against ordinary income like wages ($1,500 if married filing separately). Any leftover loss carries forward indefinitely to shelter future gains.1Internal Revenue Service. Topic No. 409 Capital Gains and Losses

The trap is the wash sale rule. Buy the same security, or a substantially identical one, within 30 days before or after the sale and the IRS disallows the loss.2Office of the Law Revision Counsel. 26 USC 1091 – Losses From Wash Sales of Stock or Securities The disallowed amount is added to the basis of the replacement shares, so the loss isn’t gone forever, but the immediate benefit disappears. Many investors keep their market exposure during the 61-day window by buying a different fund in the same sector. Harvested gains and losses are reported on Form 8949 and totaled on Schedule D.3Internal Revenue Service. About Form 8949, Sales and Other Dispositions of Capital Assets

The Home Sale Exclusion

Selling your primary residence comes with the most generous shelter in the tax code. If you owned and lived in the property as your principal residence for at least two of the five years before the sale, you can exclude up to $250,000 of gain from federal tax. Married couples filing jointly can exclude up to $500,000, provided both spouses meet the use requirement and at least one meets the ownership requirement.4Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence

The two years don’t need to be consecutive. You need 730 total days of residence inside the five-year window.5Internal Revenue Service. Publication 523 – Selling Your Home The excluded gain is permanently tax-free, not deferred, and you can generally use the exclusion once every two years. For most families, this is the only capital gains shelter they’ll ever need.

Shelter Investments Inside Retirement and 529 Accounts

Money invested inside tax-advantaged accounts is protected from capital gains tax on trades made within the account. The trade-off is restricted access, but the compounding effect over decades is significant.

Traditional 401(k) and IRA

Contributions go in pre-tax. Buying and selling inside the account triggers no capital gains tax. Everything is taxed as ordinary income when you withdraw it, typically in retirement when your bracket may be lower. For 2026, the employee 401(k) contribution limit is $24,500, with an additional $8,000 catch-up for those 50 and older and $11,250 for those aged 60 through 63.6Internal Revenue Service. Retirement Topics – 401(k) and Profit-Sharing Plan Contribution Limits

Roth 401(k) and Roth IRA

Contributions are made with after-tax dollars, but all growth and qualified withdrawals after age 59½ come out completely tax-free.7Internal Revenue Service. Retirement Topics – Exceptions to Tax on Early Distributions Capital gains earned inside a Roth are permanently excluded from taxation. Roths are the stronger shelter for investors who expect to be in a higher bracket in retirement.

529 Education Savings Plans

A 529 works like a Roth for education costs. Growth is tax-deferred, and withdrawals for qualified expenses like tuition, fees, and room and board are tax-free. Starting in 2024, unused 529 funds can be rolled into a Roth IRA for the beneficiary, subject to a $35,000 lifetime cap and a requirement that the 529 has been open at least 15 years. The annual rollover is limited to that year’s Roth IRA contribution limit ($7,000 in 2026).

Defer Real Estate Gains With a 1031 Exchange

Investors who sell an investment property can reinvest the proceeds into a replacement property without paying capital gains tax at the time of sale. The gain isn’t forgiven; it rolls into the replacement property through a reduced cost basis. But the tax bill can be pushed forward through multiple exchanges across an entire investing career.8Office of the Law Revision Counsel. 26 U.S. Code 1031 – Exchange of Real Property Held for Productive Use or Investment

Two deadlines control whether the exchange qualifies. You must identify the replacement property within 45 calendar days of closing on the original property, and you must close on the replacement within 180 days of that sale or by your tax return’s due date, whichever comes first.8Office of the Law Revision Counsel. 26 U.S. Code 1031 – Exchange of Real Property Held for Productive Use or Investment Miss either deadline and the full gain becomes taxable. The 45-day identification window is where most exchanges fall apart, especially in competitive markets.

The replacement property must be equal or greater in value and equity to preserve the full deferral. Cash pulled out of the transaction or debt relief received (called “boot”) is taxable up to the amount of the realized gain. You must also use a Qualified Intermediary to hold the sale proceeds; touching the money yourself triggers constructive receipt and kills the deferral. QI fees for a standard exchange typically run $600 to $1,800.

The real power of a 1031 shows up at the end of the investor’s life. If the last replacement property passes to heirs, it receives a stepped-up basis, and all the gains deferred through years of exchanges are permanently wiped out.

Spread the Gain With an Installment Sale

An installment sale lets you report a capital gain across multiple tax years rather than all at once. If the buyer makes at least one payment after the tax year closes, you generally recognize only the portion of the gain that corresponds to each payment received.9Office of the Law Revision Counsel. 26 U.S. Code 453 – Installment Method This is the default method; you don’t have to elect into it, though you can opt out.

The math runs through a gross profit percentage: divide total profit by total contract price, then apply that percentage to each payment received (interest is taxed separately as ordinary income).10Internal Revenue Service. Publication 537 – Installment Sales Sell a rental property for $400,000 with $150,000 of gain paid over five years, and roughly $30,000 of gain flows onto your return each year instead of $150,000 all at once. Spreading the gain can keep you in lower brackets and may keep you under the threshold for the 3.8% net investment income tax.

Installment sales work well for high-value assets like businesses and real estate, especially when the seller is approaching retirement and expects lower income later. A seller who doesn’t qualify for a 1031 exchange can still get meaningful deferral through seller financing.

Reinvest in a Qualified Opportunity Fund

The Qualified Opportunity Zone program lets you defer capital gains by reinvesting them into a Qualified Opportunity Fund within 180 days. The gain can come from any source: stocks, real estate, a business sale.11Internal Revenue Service. Invest in a Qualified Opportunity Fund The QOF must invest at least 90% of its assets in qualified property within a designated Opportunity Zone.

The critical date is December 31, 2026. All deferred gains become taxable then, whether or not the investor sells the QOF interest.12Internal Revenue Service. Opportunity Zones Frequently Asked Questions The gain retains its original character and is taxed at the applicable 2026 rate. Basis step-ups of 10% and 15% for five- and seven-year holds are only available to investors who entered by the end of 2021 or 2019 respectively. New investors in 2025 or 2026 get the deferral but not the step-up.11Internal Revenue Service. Invest in a Qualified Opportunity Fund

The program’s most powerful benefit remains available to new investors: hold your QOF investment for at least 10 years and the basis is adjusted to fair market value on the date you sell it. All appreciation on the QOF investment itself is permanently excluded from tax.12Internal Revenue Service. Opportunity Zones Frequently Asked Questions The 10-year exclusion covers only the QOF’s own growth, not the original deferred gain, which still comes due in 2026.

Give Appreciated Assets to Charity

Donating an appreciated asset directly to a qualified charity eliminates the capital gains tax on that appreciation entirely. Bought stock for $20,000, worth $100,000 today? Donating the shares avoids tax on $80,000 of gain, and you claim a charitable deduction for the full fair market value, subject to AGI limits (generally 30% for appreciated property donated to public charities).

Donor-Advised Funds

A Donor-Advised Fund is a charitable investment account. You transfer appreciated assets in, take the deduction immediately, and permanently eliminate the capital gains tax on the transferred property. Assets inside the DAF grow tax-free, and you direct grants to charities on your own schedule. The advantage is the split between the deduction year and the grant year: you claim the full benefit in a high-income year while distributing the money to charities over time.

Charitable Remainder Trusts

A Charitable Remainder Trust converts a highly appreciated asset into an income stream without an immediate tax hit. You transfer the asset irrevocably into the trust, which is tax-exempt and can sell it without paying capital gains tax. The proceeds are reinvested and the trust pays you income for a set number of years or for life, either as fixed payments (annuity trust) or as payments that fluctuate with the trust’s value (unitrust). You also receive an up-front income tax deduction based on the present value of what will eventually pass to the charity. CRTs are most practical for assets worth several hundred thousand dollars or more, since legal and administrative costs have to be justified by the tax savings.

Qualified Small Business Stock Exclusion

For investors in early-stage companies, Section 1202 is one of the most valuable provisions in the tax code. Hold qualifying stock for more than five years and you can exclude 100% of the gain from federal capital gains tax, up to the greater of $10 million or 10 times your adjusted basis in the stock.13Office of the Law Revision Counsel. 26 U.S. Code 1202 – Partial Exclusion for Gain From Certain Small Business Stock The 100% exclusion applies to stock acquired after September 27, 2010. Earlier stock qualifies for reduced 50% or 75% exclusions.

The qualification rules are strict:

  • The issuing company must be a domestic C corporation. S corporations and LLCs don’t qualify.
  • You must acquire the stock directly from the company (original issuance), not on a secondary market.
  • The corporation’s total gross assets cannot exceed $75 million at the time your stock is issued. If the company crosses that threshold before your shares are issued, those shares are permanently disqualified.13Office of the Law Revision Counsel. 26 U.S. Code 1202 – Partial Exclusion for Gain From Certain Small Business Stock
  • You must hold the stock for more than five years. Selling one day early voids the entire exclusion.
  • At least 80% of the corporation’s assets must be used in an active business. Companies primarily in finance, insurance, consulting, or real estate generally don’t qualify.

The $10 million cap is per taxpayer, per issuing company, so multiple investors can each claim the full exclusion on stock from the same corporation. For founders and early employees, the savings can be extraordinary: $10 million of gain at the 23.8% combined top rate would otherwise cost nearly $2.4 million in federal tax.

Stepped-Up Basis at Death

This is less a strategy than a feature of the tax code that shapes how every other strategy should be used. When someone dies, the cost basis of their property is adjusted to fair market value on the date of death.14Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired From a Decedent All unrealized gains accumulated during the owner’s lifetime are permanently erased.

Buy stock for $50,000, hold it until it’s worth $500,000 at death, and your heirs inherit it with a $500,000 basis. They can sell immediately and owe no capital gains tax. This interacts powerfully with everything else on this list. An investor who executes repeated 1031 exchanges over decades, deferring millions in gains, can pass the final property to heirs and convert a huge deferred tax bill into nothing. For investors holding highly appreciated assets who don’t need the cash during their lifetime, the stepped-up basis is often the reason not to sell.

Don’t Forget the 3.8% Net Investment Income Tax

High earners owe an additional 3.8% surtax on capital gains that plenty of people miss when planning. The Net Investment Income Tax applies to the lesser of your net investment income or the amount by which your modified adjusted gross income exceeds $200,000 (single), $250,000 (married filing jointly), or $125,000 (married filing separately).15Internal Revenue Service. Net Investment Income Tax These thresholds aren’t indexed for inflation, so more taxpayers cross them each year.

The NIIT applies to interest, dividends, capital gains, rental income, and royalties. It does not apply to wages, Social Security benefits, or gain excluded under the primary residence exclusion.15Internal Revenue Service. Net Investment Income Tax The effective top federal rate on long-term capital gains is therefore 23.8%, not 20%. Several of the strategies above (loss harvesting, installment sales, charitable donations) can drop your MAGI enough to reduce or eliminate the surtax in a given year, which is worth factoring in before you sell.