You can legally pay 0% capital gains tax on investment profits by using one of several provisions in the federal tax code: keeping your taxable income under the 0% long-term capital gains bracket, using the home sale exclusion, holding investments in a Roth IRA or HSA, offsetting gains with losses, donating appreciated assets, or qualifying for targeted exclusions on small business stock, real estate exchanges, Opportunity Zone investments, or inherited property. For 2026, the 0% long-term rate covers taxable income up to $49,450 for single filers and $98,900 for married couples filing jointly.1Internal Revenue Service. Revenue Procedure 2025-32 Which strategy fits depends on what you’re selling, how long you’ve held it, and what the rest of your income looks like that year.
Stay Inside the 0% Long-Term Capital Gains Bracket
The cleanest path to zero is having taxable income low enough that the 0% rate applies to your gain automatically. The rate covers gains on assets held longer than one year. For 2026:
- Single filers: $49,450
- Married filing jointly: $98,900
- Head of household: $66,200
- Married filing separately: $49,450
Above these thresholds, the rate jumps to 15%, and eventually to 20% at higher income levels.1Internal Revenue Service. Revenue Procedure 2025-32
The catch is that the capital gain itself counts toward taxable income. Say you earn $35,000 in wages and sell stock for a $20,000 long-term gain. Your income before deductions is $55,000. Subtract the 2026 standard deduction of $16,100 for a single filer, and taxable income comes to $38,900, which sits entirely inside the 0% bracket.2Internal Revenue Service. IRS Releases Tax Inflation Adjustments for Tax Year 2026 Change the wage number a little and part of the gain spills into the 15% zone. Only the piece that stays below the threshold gets the 0% rate.
This works best for retirees, people between jobs, or anyone with a lower-income year on the horizon. If you have flexibility in when to sell, waiting for a low-income year can keep the whole gain untaxed. Married couples filing jointly have the most room: the $98,900 ceiling stacked with a $32,200 standard deduction means roughly $131,100 of gross income before any gain gets taxed.1Internal Revenue Service. Revenue Procedure 2025-32
Exclude Up to $500,000 on the Sale of Your Home
Homeowners get one of the largest exclusions in the code. You can exclude up to $250,000 of profit from selling your main home, or $500,000 if you’re married filing jointly.3Office of the Law Revision Counsel. 26 USC 121 – Exclusion of Gain From Sale of Principal Residence Most home sales produce a gain well under $250,000, so most sellers owe nothing.
Two tests apply. You must have owned the home and used it as your primary residence for at least two of the five years before the sale. The two years don’t have to run consecutively, so a temporary rental in the middle doesn’t disqualify you as long as personal use adds up to 24 months inside that five-year window.4eCFR. 26 CFR 1.121-1 – Exclusion of Gain From Sale or Exchange of a Principal Residence For the full $500,000 joint exclusion, both spouses need to meet the use test and at least one must meet the ownership test.
If you sell early, a partial exclusion is possible when the move was driven by a job relocation, a health condition, or certain unforeseen events like the home being condemned or a spouse’s death.5Internal Revenue Service. Publication 523 – Selling Your Home The prorated amount equals the full exclusion multiplied by the fraction of the two-year requirement you actually completed. Living in the home 18 months and moving for a new job, a single filer could exclude up to $187,500.
Hold Investments Inside a Roth IRA or HSA
Some accounts don’t just defer capital gains. They erase them.
A Roth IRA is the clearest example. You contribute after-tax money, and all growth comes out tax-free provided you’re at least 59½ and it’s been at least five years since your first Roth contribution.6Office of the Law Revision Counsel. 26 USC 408A – Roth IRAs A stock that quintuples inside a Roth generates zero capital gains tax when you withdraw.
For 2026, the Roth IRA contribution limit is $7,500, with an extra $1,000 catch-up at age 50 or older. Eligibility phases out at modified adjusted gross income between $153,000 and $168,000 for single filers, and between $242,000 and $252,000 for married couples filing jointly.7Internal Revenue Service. 401(k) Limit Increases to $24,500 for 2026; IRA Limit Increases to $7,500
Health Savings Accounts work the same way for people on high-deductible health plans. You can invest HSA balances in stocks or mutual funds, and withdrawals for qualified medical expenses are entirely tax-free, including any investment gains.8Internal Revenue Service. Publication 969 – Health Savings Accounts and Other Tax-Favored Health Plans The 2026 contribution limits are $4,400 for self-only coverage and $8,750 for family coverage.9Internal Revenue Service. Notice 26-05 – HSA Contribution Limits After 65, non-medical withdrawals are still allowed without penalty, though those amounts are taxed as ordinary income.
Traditional 401(k)s and Traditional IRAs work differently. They defer tax rather than eliminate it. Withdrawals come out as ordinary income, often at higher rates than the long-term capital gains rate would have been.
Offset Gains With Losses You Realize the Same Year
Selling a losing investment creates a capital loss that cancels gains on your winners, dollar for dollar. Ten thousand dollars in realized losses wipes out $10,000 in realized gains.10Office of the Law Revision Counsel. 26 USC 1211 – Limitation on Capital Losses Short-term losses match short-term gains first, and long-term losses match long-term gains; anything left over crosses categories.
If losses exceed gains for the year, you can deduct up to $3,000 of the remainder against ordinary income ($1,500 if married filing separately). Anything above that carries forward indefinitely.10Office of the Law Revision Counsel. 26 USC 1211 – Limitation on Capital Losses Transactions get reported on Form 8949, which feeds Schedule D.11Internal Revenue Service. Instructions for Form 8949
Watch the Wash Sale Rule
If you sell a security at a loss and buy the same or a substantially identical security within 30 days before or after that sale, the IRS disallows the loss.12Internal Revenue Service. IRS Courseware – Wash Sales The disallowed amount gets added to the cost basis of the replacement shares, so it isn’t gone forever, but it can’t offset gains right now.
The rule crosses account lines, including IRAs. Selling a stock at a loss in your brokerage account and buying it the same day in your IRA triggers a wash sale. A workable approach is to swap into a similar but not identical investment during the 61-day window. Selling one S&P 500 index fund and buying a total market fund from a different provider generally keeps your exposure close without triggering the rule.
Donate Appreciated Stock Instead of Cash
If a charitable gift is already in your plans, giving appreciated stock beats writing a check. Transfer long-term appreciated securities directly to a qualified charity and you never realize the gain, which means no capital gains tax. You also get a charitable deduction for the full fair market value, subject to a limit of 30% of adjusted gross income for the year.13Office of the Law Revision Counsel. 26 U.S. Code 170 – Charitable Contributions and Gifts Unused deduction carries forward for up to five additional tax years.
The holding period requirement matters. If you’ve held the asset a year or less, the deduction is limited to your cost basis, which defeats most of the strategy. Donor-advised funds are a common vehicle here: you contribute stock in a high-income year, take the deduction immediately, and direct grants to charities over time while the fund sells the stock internally without tax.
Swap Investment Real Estate Under Section 1031
Real estate investors can push capital gains forward indefinitely by exchanging one investment property for another. The rule covers real property held for business or investment use, not your personal residence and not stocks or bonds.14Office of the Law Revision Counsel. 26 U.S. Code 1031 – Exchange of Real Property Held for Productive Use in a Trade or Business or for Investment Reinvest into qualifying replacement property and no gain is recognized at the time of the exchange.
Timing is strict. You have 45 days after selling the original property to identify replacement properties in writing, and 180 days to close. These deadlines don’t move except after a presidentially declared disaster.15Internal Revenue Service. Like-Kind Exchanges Under IRC Section 1031 A qualified intermediary usually holds the proceeds between sales; touching the money yourself breaks the deferral.
Technically this is deferral, not exclusion, because the old basis carries into the new property. But investors who keep exchanging can push gains for decades, and if the final property passes through an estate, the stepped-up basis rule below wipes the accumulated gain out entirely.
Qualified Small Business Stock Under Section 1202
Founders, early employees, and angel investors may qualify for a 100% exclusion on gains from selling stock in a qualifying small business. If you acquired the stock after September 27, 2010, at original issuance from a C corporation, and held it for at least five years, the gain is completely excluded from federal income tax.16Office of the Law Revision Counsel. 26 USC 1202 – Partial Exclusion for Gain From Certain Small Business Stock The exclusion is capped at the greater of $10 million or ten times your basis in the stock, per issuing company.
The corporation has to be a domestic C corp with gross assets never exceeding $75 million before and immediately after your shares were issued, and at least 80% of its assets must be actively used in a qualified trade or business during substantially all of your holding period. Certain industries are excluded, including finance, hospitality, and professional services like law and accounting. When it applies, the exclusion is enormous, but the eligibility rules are narrow.
Opportunity Zone Investments and the 2026 Deadline
Qualified Opportunity Funds let you permanently exclude new appreciation if you hold the investment for at least ten years. Invest capital gains into a fund that targets designated Opportunity Zones, and you can elect to treat the basis at sale as equal to fair market value, meaning growth during the holding period comes out tax-free.17Internal Revenue Service. Invest in a Qualified Opportunity Fund
A deadline matters here. The statute originally let investors defer the initial capital gain rolled into the fund, but that deferral ends December 31, 2026: any gain you deferred becomes taxable by that date whether or not you’ve sold the fund investment.18Office of the Law Revision Counsel. 26 U.S. Code 1400Z-2 – Special Rules for Capital Gains Invested in Opportunity Zones The ten-year exclusion on post-investment appreciation still applies to existing investments, but the window for new deferral elections closes at the end of 2026.
Stepped-Up Basis on Inherited Assets
You can’t use this one on yourself, but it’s the most complete gain eraser in the code, and it changes how to think about selling late in life. When you inherit an asset, your cost basis resets to fair market value at the previous owner’s date of death.19Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired From a Decedent A stock originally bought for $5,000 that was worth $100,000 the day the owner died gives you a $100,000 basis. Sell it the next day for $100,000, and taxable gain is zero.
The rule applies to stocks, real estate, and most capital assets passed through an estate. It’s why many planners advise against selling highly appreciated assets late in life: passing them through the estate wipes out the accumulated gain. For anyone rolling investment real estate through 1031 exchanges for decades, the step-up at death is what turns serial deferral into permanent savings.
Two Things That Can Undo a Zero Tax Plan
Qualifying for the 0% federal rate on a sale doesn’t always mean nothing is owed.
The Net Investment Income Tax adds 3.8% on top of your capital gains rate when modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married couples filing jointly.20Internal Revenue Service. Topic No. 559 – Net Investment Income Tax These thresholds are not indexed to inflation, so more taxpayers cross them each year.21Congressional Research Service. The 3.8% Net Investment Income Tax – Overview, Data It’s possible in unusual years to have MAGI above the NIIT threshold and taxable income below the 0% capital gains threshold, in which case you’d owe 3.8% instead of nothing. The NIIT reaches capital gains, dividends, and rental income, so factor it into any strategy aimed at a zero bill.
State tax is the other layer. Most states tax capital gains as ordinary income, with rates ranging from nothing in states without an income tax to more than 13% at the top. A few offer partial exclusions or preferential rates for long-term gains, but treatment varies widely. Paying 0% federal doesn’t necessarily mean owing nothing overall, so check how your state handles the sale before assuming any transaction is entirely tax-free.