How to Avoid Capital Gains Tax on Index Funds: ETFs, IRAs & Charity

You can legally avoid or reduce capital gains tax on index funds by choosing ETF versions over mutual funds, holding shares more than a year, keeping them inside a 401(k) or IRA, harvesting losses to offset gains, donating appreciated shares to charity, or passing them to heirs who receive a stepped-up basis. For 2026, the long-term capital gains rate is 0% for single filers with taxable income up to $49,450 and married couples filing jointly up to $98,900, so many investors can sell appreciated shares and owe nothing at the federal level.1Internal Revenue Service. Revenue Procedure 2025-32 Some of these strategies erase the tax permanently; others defer or shift it.

Choose ETF Index Funds Over Mutual Fund Index Funds

The structure of your index fund affects your tax bill even in years you never place a trade. Traditional mutual fund index funds sell holdings inside the fund and distribute the resulting gains to every shareholder. Those capital gain distributions land on your Form 1099-DIV as long-term gains regardless of how long you’ve personally owned the fund.2Internal Revenue Service. Mutual Funds (Costs, Distributions, Etc.) You owe tax on distributions you never asked for.

ETFs tracking the same index rarely distribute capital gains. They use an in-kind creation and redemption process that lets institutional participants swap baskets of stock for ETF shares without triggering taxable sales inside the fund. If you hold index funds in a taxable brokerage account, switching from a mutual fund to an ETF version of the same index is one of the simplest moves available. Inside a tax-advantaged retirement account the distinction doesn’t matter, because gains aren’t taxed until withdrawal anyway.

Hold Shares More Than One Year

Federal law draws a hard line at one year. Sell index fund shares you’ve held for one year or less, and the profit is taxed as ordinary income at rates up to 37% for 2026.3Office of the Law Revision Counsel. 26 USC 1222 – Other Terms Relating to Capital Gains and Losses Hold the same shares more than one year, and the gain qualifies for long-term rates.4Office of the Law Revision Counsel. 26 USC 1 – Tax Imposed

The 2026 long-term brackets:

  • 0% on taxable income up to $49,450 (single), $98,900 (married filing jointly), or $66,200 (head of household).
  • 15% on taxable income above those thresholds up to $545,500 (single), $613,700 (married filing jointly), or $579,600 (head of household).
  • 20% on taxable income above the 15% ceiling.

These figures are adjusted annually for inflation.1Internal Revenue Service. Revenue Procedure 2025-32

Tax Gain Harvesting in the 0% Bracket

If your taxable income falls below the 0% threshold in a given year, you can intentionally sell appreciated index fund shares, pay zero federal capital gains tax, and immediately repurchase the same fund. This resets your cost basis to the higher current price, shrinking the taxable gain on any future sale. The wash sale rule does not apply to gains, so you can buy back the identical fund the same day.

Consider the math. A single filer in 2026 with $30,000 in wages takes the $16,100 standard deduction, leaving $13,900 in taxable income.5Internal Revenue Service. IRS Releases Tax Inflation Adjustments for Tax Year 2026 That leaves $35,550 of room before hitting the $49,450 ceiling. The investor could realize up to $35,550 in long-term gains and owe no federal capital gains tax.1Internal Revenue Service. Revenue Procedure 2025-32 Retirees on modest income and anyone in a gap year between jobs are the most common candidates.

Invest Through Tax-Advantaged Accounts

Inside a 401(k), IRA, or similar retirement account, you can buy and sell index funds as often as you want without creating a taxable event. No capital gains tax applies at the time of sale. The trade-off is how and when you eventually pay tax on the money.

401(k) Plans

For 2026, 401(k) employee contributions are capped at $24,500. Workers aged 50 and older can add an $8,000 catch-up, and those aged 60 through 63 get a higher catch-up of $11,250.6Internal Revenue Service. 401(k) Limit Increases to $24,500 for 2026, IRA Limit Increases to $7,500 Traditional 401(k) contributions reduce taxable income in the year you make them, but every dollar you withdraw in retirement is taxed as ordinary income. Roth 401(k) contributions give no upfront deduction, and qualified withdrawals come out entirely tax-free.

Traditional and Roth IRAs

IRAs allow contributions of up to $7,500 for 2026, with an additional $1,100 for those aged 50 and over.6Internal Revenue Service. 401(k) Limit Increases to $24,500 for 2026, IRA Limit Increases to $7,500 Traditional IRAs follow the same tax-now-or-later logic as 401(k)s. Roth IRAs are the most complete tool for eliminating capital gains tax on index fund growth: contributions go in after tax, and qualified withdrawals of both contributions and earnings are tax-free.7Office of the Law Revision Counsel. 26 USC 408A – Roth IRAs

Roth IRA contributions phase out for single filers with modified adjusted gross income between $153,000 and $168,000, and for married couples filing jointly between $242,000 and $252,000.6Internal Revenue Service. 401(k) Limit Increases to $24,500 for 2026, IRA Limit Increases to $7,500 Withdrawals from any of these accounts before age 59½ generally trigger a 10% early withdrawal penalty on top of regular income tax, so the strategy works best for money you won’t need until retirement.8Office of the Law Revision Counsel. 26 USC 408 – Individual Retirement Accounts

Offset Gains With Tax-Loss Harvesting

When some of your investments are down, you can sell them at a loss and use that loss to cancel out gains from index funds sold at a profit. Capital losses offset capital gains dollar for dollar. If your total losses exceed your total gains in a year, you can deduct up to $3,000 of the remaining net loss against ordinary income such as wages or interest ($1,500 if married filing separately).9Office of the Law Revision Counsel. 26 USC 1211 – Limitation on Capital Losses Unused losses carry forward indefinitely.

Capital losses cannot directly offset qualified dividends, even though qualified dividends are taxed at capital gains rates. The $3,000 ordinary income deduction can include dividend income, but you can’t net losses against dividends the way you net them against capital gains.

The Wash Sale Rule

You cannot sell a security at a loss and buy a “substantially identical” security within 30 days before or after the sale. If you do, the loss is disallowed for the current year, and the disallowed amount gets added to the cost basis of the replacement shares.10Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities The loss isn’t permanently gone, but it’s deferred into the new position’s basis.

The workaround: sell your S&P 500 index fund at a loss and immediately buy a total stock market fund or a large-cap fund tracking a different index. These track different benchmarks and are generally not considered substantially identical. You stay invested in a similar slice of the market while locking in the tax loss. After 31 days, you can switch back if you prefer the original fund.

Choosing Which Shares to Sell

If you’ve bought index fund shares at different times and prices, you don’t have to sell them in the order you bought them. The specific identification method lets you tell your broker exactly which tax lots to sell, so you can target the highest-cost shares to generate the largest loss or the smallest gain. You must designate the specific shares before the sale executes and receive written confirmation. Without a specification, your broker defaults to first-in, first-out, which may not produce the best tax outcome.

Donate Appreciated Shares to Charity

Donating long-term appreciated index fund shares directly to a qualified charity is one of the few strategies that eliminates the capital gains tax and produces a separate deduction. You never sell the shares, so no gain is realized. The charity receives the full value of the investment, and you can deduct the fair market value on your return.11Office of the Law Revision Counsel. 26 USC 170 – Charitable, Etc., Contributions and Gifts The shares must have been held more than one year, and the organization must be a qualified 501(c)(3).

The deduction for appreciated property is capped at 30% of your adjusted gross income for the year. Anything above the cap carries forward for up to five years. An investor with $200,000 in AGI can deduct up to $60,000 of donated stock in a single year; a $90,000 gift would generate a $60,000 deduction now and a $30,000 carryforward.

Starting in 2026, the One Big Beautiful Bill added a 0.5% AGI floor for itemized charitable deductions. Only the portion of your total charitable contributions above 0.5% of AGI is deductible. For a taxpayer with $300,000 in AGI donating $50,000 of appreciated stock, the first $1,500 produces no deduction. The same law caps the tax benefit of itemized deductions at 35% for taxpayers in the top bracket, down from 37%.

Noncash charitable contributions over $500 require Form 8283.12Internal Revenue Service. Instructions for Form 8283 Publicly traded securities, including index fund shares, go in Section A and are exempt from the formal appraisal requirement that applies to other property donations above $5,000. You still need a written acknowledgment from the charity.

Gift Shares or Pass Them at Death

The tax code treats lifetime gifts and transfers at death very differently. Both can reduce capital gains tax on appreciated index funds, but inheritance is far more powerful.

Gifting During Your Lifetime

You can give up to $19,000 per recipient in 2026 without filing a gift tax return or reducing your lifetime exemption.13Internal Revenue Service. What’s New — Estate and Gift Tax14Internal Revenue Service. Property (Basis, Sale of Home, Etc.)15Office of the Law Revision Counsel. 26 USC 1223 – Holding Period of Property This works when the recipient is in a lower tax bracket than you. A parent in the 20% capital gains bracket who gifts shares to an adult child with modest income could see those gains taxed at 0% or 15%. If the child’s taxable income falls below the 0% threshold, the federal tax disappears entirely. The kiddie tax applies to children under 19 (or full-time students under 24), so the strategy works best for gifts to adults with their own earned income.

Step-Up in Basis at Death

When you inherit index fund shares, the cost basis resets to fair market value on the date of the original owner’s death.16Office of the Law Revision Counsel. 26 USC 1014 – Basis of Property Acquired From a Decedent Every dollar of gain that accumulated during the decedent’s lifetime is permanently erased. If the heir sells shortly after inheriting, the taxable gain is close to zero.

This is the most complete form of capital gains elimination in the code, and it requires no advance planning from the heir. From the decedent’s perspective, holding appreciated index funds until death rather than selling them during retirement can be a deliberate wealth-transfer choice. With the 2026 federal estate tax exemption at $15,000,000 per individual and $30,000,000 for a married couple, the vast majority of estates pass without owing any federal estate tax while still delivering the full basis reset to heirs.13Internal Revenue Service. What’s New — Estate and Gift Tax

The 3.8% Net Investment Income Tax

Higher-income investors face an extra layer on top of the standard rates. A 3.8% surtax applies to net investment income, including index fund gains, when modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married couples filing jointly.17Office of the Law Revision Counsel. 26 USC 1411 – Imposition of Tax The tax is calculated on the lesser of your net investment income or the amount by which your MAGI exceeds the threshold.18Internal Revenue Service. Topic No. 559, Net Investment Income Tax

These MAGI thresholds are not indexed for inflation, so more taxpayers cross them each year. An investor who owes the 15% long-term rate plus the 3.8% surtax effectively pays 18.8%. Someone in the 20% bracket faces a combined 23.8% federal rate. Distributions from 401(k) plans, traditional IRAs, and Roth IRAs are specifically excluded from net investment income, making the tax-advantaged account strategies the most direct defense.17Office of the Law Revision Counsel. 26 USC 1411 – Imposition of Tax Tax-loss harvesting also helps by reducing net investment income in the year you claim the losses.

State Taxes Are a Separate Matter

Federal rates are only part of the picture. Most states tax capital gains as ordinary income, with rates ranging from 0% in states without an income tax to over 13% in the highest-tax states. A handful of states have no income tax at all, so index fund gains face only the federal rates covered above. Every strategy on this page reduces or eliminates the federal tax; the state impact depends entirely on where you live. Relocating to a no-income-tax state before a large sale is a real option some retirees use, though the logistics go well beyond tax planning.