Capital gains tax shelters are legal strategies that defer, reduce, or permanently eliminate the tax owed when you sell an asset for more than you paid. The federal rate on long-term gains tops out at 20%, and high earners pay an additional 3.8% surtax, so the combined bite can reach 23.8% before state tax. Short-term gains are worse: they’re taxed as ordinary income at rates up to 37%. The strategies below range from timing decisions any investor can use to structures that need professional guidance and years of planning.
Hold Assets for More Than a Year
The simplest shelter is patience. Sell within a year of purchase and your profit is a short-term capital gain, taxed at your ordinary income rate.1Internal Revenue Service. Topic No. 409 Capital Gains and Losses For someone in the top bracket, that’s 37% of the profit.
Cross the one-year mark and the same profit becomes a long-term capital gain, taxed at 0%, 15%, or 20% depending on your taxable income.1Internal Revenue Service. Topic No. 409 Capital Gains and Losses Delaying a sale by even a few weeks to clear that threshold can save 17 percentage points or more on the same dollar of gain.
Offset Gains With Losses
Tax-loss harvesting uses your losing investments to cancel out your winners. You sell a position that’s down, lock in the loss, and apply it against gains you’ve realized the same year. Losses offset gains dollar-for-dollar, starting with the same type: short-term losses against short-term gains, long-term against long-term.1Internal Revenue Service. Topic No. 409 Capital Gains and Losses
If your losses exceed your gains for the year, you can deduct up to $3,000 of the net loss against ordinary income like wages ($1,500 if married filing separately). Anything left carries forward indefinitely to shelter future gains.1Internal Revenue Service. Topic No. 409 Capital Gains and Losses
Watch the wash sale rule. If you buy back the same security, or one substantially identical to it, within 30 days before or after the sale, 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 gets added to the basis of the replacement shares, so it isn’t gone forever, but the immediate benefit disappears. Many investors buy a different fund in the same sector to keep market exposure during the 61-day window.
Harvested trades go on Form 8949, with totals flowing to Schedule D.3Internal Revenue Service. About Form 8949, Sales and Other Dispositions of Capital Assets Your Form 1099-B supplies most of the numbers, but keep your own records for wash sale adjustments and basis corrections.
Exclude Gain on the Sale of Your Home
The home sale exclusion is the most generous capital gains shelter in the tax code, and it’s the one most Americans will ever use. If you owned and lived in the property as your principal residence for at least two of the five years before selling, you can exclude up to $250,000 of gain from federal tax. Married couples filing jointly can exclude up to $500,000 if both spouses meet the use test and at least one meets the ownership test.4Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence
The two years don’t have to be consecutive. What you need is 730 days of residence inside the five-year window.5Internal Revenue Service. Publication 523 – Selling Your Home Because this is an exclusion rather than a deferral, the sheltered gain is permanently tax-free, and you can generally claim it again every two years.
Use Tax-Advantaged Accounts
Retirement and education accounts shield everything that happens inside them from capital gains tax. The trade-off is limited access to the money, but over decades the compounding advantage is significant.
Traditional 401(k)s and IRAs
Contributions go in pre-tax. Trades inside the account trigger no capital gains tax no matter how often you buy or sell. Withdrawals in retirement are taxed as ordinary income, ideally in a year when your rate is lower than it is now. For 2026, the employee 401(k) contribution limit is $24,500, with an $8,000 catch-up at age 50 and $11,250 for ages 60 through 63.6Internal Revenue Service. Retirement Topics – 401(k) and Profit-Sharing Plan Contribution Limits
Roth 401(k)s and Roth IRAs
Roth accounts flip the timing. You contribute after-tax dollars, 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. If you expect to be in a higher bracket in retirement, or you just want certainty, the Roth is the stronger shelter.
529 Education Savings Plans
A 529 plan works like a Roth for education costs. Gains grow tax-deferred, and withdrawals used 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, a 15-year account age requirement, and an annual limit equal to that year’s Roth IRA contribution cap ($7,000 in 2026).
Defer Real Estate Gains With a 1031 Exchange
A 1031 exchange lets a real estate investor sell an investment property and roll the proceeds into a replacement property without paying capital gains tax at the time of sale. The gain isn’t forgiven; it moves to the new property through a reduced basis. Done repeatedly, this can push the tax bill forward over an entire career.8Office of the Law Revision Counsel. 26 U.S. Code 1031 – Exchange of Real Property Held for Productive Use or Investment
Two deadlines decide whether the exchange qualifies. You must identify the replacement property within 45 calendar days of closing on the sale, and you must close on the replacement within 180 days of the sale or by the due date of your tax return, whichever is earlier.8Office of the Law Revision Counsel. 26 U.S. Code 1031 – Exchange of Real Property Held for Productive Use or Investment Miss either one and the full gain becomes taxable. The 45-day identification window is where most exchanges fall apart, especially in competitive markets.
The replacement must equal or exceed the old property in value and equity to preserve the full deferral. Any cash you pull out or debt relief you receive (called “boot”) is taxable up to the amount of the realized gain. You also must use a Qualified Intermediary to hold the sale proceeds. Touching the money yourself triggers constructive receipt and kills the deferral. QI fees typically run $600 to $1,800.
The strategy’s payoff shows up at death. If the final replacement property passes to heirs, they take it at a stepped-up basis and every deferred gain accumulated over decades of exchanges is wiped out.
Spread the Gain With an Installment Sale
An installment sale reports gain across multiple tax years instead of piling it into one. If the buyer makes at least one payment after the year of sale closes, you generally recognize gain only as each payment comes in.9Office of the Law Revision Counsel. 26 U.S. Code 453 – Installment Method It’s the default method; you don’t have to elect it, though you can opt out if reporting everything up front works better.
Each payment is split into return of basis, capital gain, and interest (the interest is taxed separately as ordinary income).10Internal Revenue Service. Publication 537 – Installment Sales Spreading a gain this way can keep you in lower brackets and, in some years, keep your income below the threshold for the 3.8% net investment income tax. Installment sales work well for businesses and real estate, particularly when the seller is approaching retirement and expects lower income ahead. They can also complement other strategies: a seller who can’t structure a 1031 exchange may still get meaningful deferral through seller financing.
Reinvest Through a Qualified Opportunity Fund
The Qualified Opportunity Zone program lets you defer capital gains by reinvesting them into a Qualified Opportunity Fund that puts money to work in designated low-income communities. The gain can come from any source (stocks, real estate, a business sale) as long as you reinvest within 180 days.11Internal Revenue Service. Invest in a Qualified Opportunity Fund The QOF must hold at least 90% of its assets in qualified Opportunity Zone property.
The date to know is December 31, 2026. All deferred gains become taxable then, whether or not you’ve sold your QOF interest.12Internal Revenue Service. Opportunity Zones Frequently Asked Questions The gain keeps its original character and is taxed at the 2026 rate. The earlier basis step-ups (10% at five years, 15% at seven) are effectively closed to investors coming in now, because reaching those holding periods before the recognition date is no longer possible.
The program’s remaining power is the 10-year rule: hold your QOF investment for at least 10 years and, when you sell, the investment’s basis is adjusted to fair market value. All appreciation on the QOF investment itself is permanently excluded from tax.12Internal Revenue Service. Opportunity Zones Frequently Asked Questions That exclusion applies only to the QOF’s growth, not to the original deferred gain that comes due in 2026.
Give Appreciated Assets to Charity
Donating appreciated property directly to a qualified charity eliminates the capital gains tax on the built-in gain. Bought stock for $20,000 that’s now worth $100,000? Giving the shares avoids tax on the $80,000 of appreciation, and you claim a charitable deduction for the full fair market value, subject to AGI limits (generally 30% of AGI 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 full deduction immediately, and permanently sidestep capital gains tax on the transferred property. The assets grow tax-free inside the fund, and you recommend grants to charities on your own schedule. That separation between the deduction year and the granting years is the appeal: claim the deduction in a high-income year, then support charities gradually.
Charitable Remainder Trusts
A charitable remainder trust converts a highly appreciated asset into an income stream without an immediate tax hit. You irrevocably transfer the asset to 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. Annuity trusts pay a fixed amount each year; unitrusts pay a percentage of the trust’s value. You also receive an up-front income tax deduction based on the present value of what will eventually pass to charity. Setup and administration costs mean CRTs generally make sense only for assets worth several hundred thousand dollars or more.
Claim the Small Business Stock Exclusion
For investors in early-stage companies, Section 1202 is one of the most valuable provisions in the code. Hold qualifying stock for more than five years and you can exclude 100% of the gain from federal tax, up to the greater of $10 million or 10 times your 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 a 50% or 75% exclusion depending on the acquisition date.
The qualification rules are strict:
- The issuer must be a domestic C corporation. S corporations and LLCs don’t qualify.
- You must acquire the stock directly from the company at original issuance, not from another shareholder.
- The corporation’s gross assets can’t exceed $75 million when the stock is issued. Once the company crosses that line, later 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 for more than five years. Selling a day early voids the exclusion entirely.13Office of the Law Revision Counsel. 26 U.S. Code 1202 – Partial Exclusion for Gain From Certain Small Business Stock
- At least 80% of the corporation’s assets must be used in an active business. Finance, insurance, consulting, and real estate companies generally don’t qualify.
The $10 million cap is per taxpayer, per issuing company, so multiple investors in the same company can each claim their own exclusion. At the combined 23.8% top rate, sheltering $10 million of gain saves nearly $2.4 million in federal tax.
Sold before five years but held at least six months? Section 1045 lets you defer the gain by rolling the proceeds into replacement QSBS within 60 days. The holding period of the original stock carries over, which can help you reach the five-year mark.
Pass Appreciated Assets to Heirs
This is less a strategy than a feature of the code, and it shapes how every other shelter should be used. When someone dies, the 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 Every unrealized gain built up during the owner’s lifetime is erased.
Bought stock for $50,000 that’s worth $500,000 at your death? Your heirs inherit it with a $500,000 basis and can sell without owing capital gains tax. That interacts with everything above. A landlord who runs decades of 1031 exchanges, deferring millions, can leave the final property to heirs and turn a huge deferred tax bill into nothing. For older investors holding highly appreciated assets they don’t need to spend, holding on until death is often the cleanest shelter available.
Don’t Forget the 3.8% Surtax
The Net Investment Income Tax adds 3.8% on top of the capital gains rate for higher-income filers. It 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 Those thresholds are not indexed for inflation, so each year more taxpayers cross them.
The surtax hits interest, dividends, capital gains, rental income, and royalties. It doesn’t hit wages, Social Security, or gain excluded under the home sale exclusion.15Internal Revenue Service. Net Investment Income Tax So the real top federal rate on long-term capital gains is 23.8%, not 20%. Loss harvesting, installment sales, and charitable donations can each reduce your MAGI enough to lower or avoid the NIIT in a given year, which is worth building into any plan that involves a large gain.