Bitcoin US$ 83,370Ethereum US$ 2,450EUR/USD 1.123GBP/USD 1.340USD/BRL 5.02Bitcoin US$ 83,370Ethereum US$ 2,450EUR/USD 1.123GBP/USD 1.340USD/BRL 5.02
Investing BasicsUpdated 2026-10-219 min read

Capital Gains Tax When Selling Index Funds in Retirement

Michael Chen
Michael Chen writes about personal finance fundamentals. Bay Area-based · finance enthusiast for 15 years.
Visual representation of the voice · not a photographic portrait
Share𝕏✆f
Selling index funds in retirement? See how capital gains tax is calculated, how the 0% bracket works, and six steps…
Quick answer: When you sell index funds in a regular brokerage account, you owe capital gains tax only on the profit, not the whole sale. Hold the shares for more than one year and the gain is taxed at the long-term rate of 0%, 15%, or 20%, depending on your income. Shares inside a 401(k) or IRA follow different rules and are not taxed as capital gains at all.↗ Share on X

If you sell index funds in a regular brokerage account, you pay capital gains tax only on the profit. That is the sale price minus what you paid. If you held the shares for more than one year, the profit is taxed at the long-term rate: 0%, 15%, or 20%, depending on your taxable income. If you held them one year or less, the profit is taxed like your paycheck. And if the index funds sit inside a 401(k) or an IRA, capital gains tax does not apply at all. Those accounts follow their own rules, which we cover below.

This matters because many retirees can sell index funds and pay 0% tax, if they plan the sale carefully. Here is how the math works and the steps that keep the bill low.

What counts as a capital gain when you sell an index fund?

READ ALSORetirement Savings Target: Start From Your Monthly Expenses →How Much Should You Have Saved for Retirement at Your Age? →Investment Fees: How to Add Them Up and See the 30-Year Cost →

A capital gain is the difference between two numbers:

1. Your cost basis. This is what you paid for the shares, including any dividends you reinvested. Reinvested dividends count because you already paid tax on them the year you received them.

2. Your sale price. This is what you receive when you sell, minus any fees.

Example: You bought 100 shares of an S&P 500 index fund for $200 each. Your cost basis is $20,000. Years later you sell all 100 shares for $350 each. You receive $35,000. Your capital gain is $15,000. Only that $15,000 is taxed. The $20,000 you put in comes back to you tax-free.

If you sell for less than you paid, you have a capital loss. Losses are useful. They cancel out gains, and up to $3,000 of leftover loss can reduce your regular income each year. Anything beyond that carries forward to future years.

Clear money tips in your inbox. No hype.

Short-term or long-term: why one year makes a big difference

RECOMMENDEDUltimate Dynamic Personal Budget in Google Sheets (FinSavvyDesigns) → — A fully dynamic budget planner in Google Sheets to track income, expenses, and savings with an interactive dashboard.

Affiliate link. We may earn a commission on purchases, at no extra cost to you.

This content is informational and is not investment advice or financial consulting.

The holding period decides your tax rate.

Holding periodType of gainTax rate
One year or lessShort-termSame as your ordinary income bracket (10% to 37%)
More than one yearLong-term0%, 15%, or 20%

The long-term rates are much lower. For retirees who bought index funds decades ago, nearly every share is long-term. If you bought some shares recently, say within the last 11 months, waiting a few extra weeks before selling those can cut the tax rate roughly in half.

The 0%, 15%, and 20% brackets depend on your taxable income for the year. The IRS raises the thresholds a little every year for inflation. For the 2025 tax year, the 0% rate applied to taxable income up to about $48,350 for single filers and $96,700 for married couples filing jointly. Check the current year's table on irs.gov before you sell, because the numbers move.

Taxable income means your income after the standard deduction. In 2025 the standard deduction was $15,000 for singles and $30,000 for married couples filing jointly, with an extra amount for people 65 and older. So a married couple with $40,000 of pension and taxable Social Security income, plus $50,000 of long-term gains, could still land inside the 0% bracket after the deduction. Not every dollar of Social Security is taxable either, which helps.

Which shares did you sell? The cost basis method changes your bill

READ ALSOInvesting $500 a Month in Index Funds: A Simple Setup →How Much to Save for Retirement When Prices Keep Rising →Mutual Funds vs ETFs for Retirement: How to Pick in 4 Steps →

If you bought shares at different times and prices, the broker needs to know which ones you sold. There are three common methods:

Specific identification is the best tool for retirees. Most brokers let you choose the method in the account settings or at the moment of the trade. You must choose before the trade settles. You cannot change it afterward.

A step-by-step plan to sell index funds and pay less tax

Follow these steps once a year, ideally in November or December, when you know roughly what your income will be.

1. Estimate your taxable income for the year. Add pensions, the taxable part of Social Security, part-time work, interest, dividends, and any IRA withdrawals. Subtract the standard deduction.

2. Find the gap to the top of the 0% bracket. If the 0% bracket ends at $96,700 for your filing status and your taxable income is $60,000, you have $36,700 of room.

3. Sell enough shares to fill the gap, not more. In the example, you could realize up to $36,700 of long-term gains and pay 0% on them. If you need more cash than that, sell high-basis lots, which produce little gain per dollar.

4. Use specific identification. Pick the lots with the highest cost basis when you want cash with little gain. Pick low-basis lots when you have room in the 0% bracket and want to reset your basis.

5. Check for losses. If any lot is below what you paid, selling it creates a loss that cancels gains. Just do not buy the same fund back within 30 days, or the wash sale rule cancels the loss.

6. Keep the confirmation. Save the trade confirmation showing the lots sold. Your broker sends a Form 1099-B in January, and you want your records to match it.

This approach is sometimes called gain harvesting. You sell shares, pay 0%, and buy the same fund back right away. There is no wash sale rule for gains, only for losses. Your new cost basis is the higher price, so future gains are smaller.

Watch for these three traps

Trap 1: Social Security taxation. Capital gains raise your combined income, which decides how much of your Social Security is taxable. A big sale can make up to 85% of your benefit taxable, even if the gain itself is taxed at 0%. Run the numbers for both before you sell.

Trap 2: Medicare premiums. Medicare Part B and Part D premiums go up when your income passes certain levels. This surcharge is called IRMAA. It looks at your tax return from two years earlier. A large gain in one year can raise your premiums two years later. Spreading sales across several years often avoids it.

Trap 3: The extra 3.8% tax. The Net Investment Income Tax adds 3.8% on investment income for singles with modified adjusted gross income above $200,000 and married couples above $250,000. These thresholds are not adjusted for inflation. Most retirees stay below them, but a large one-time sale can push you over.

What if the index funds are inside a 401(k) or IRA?

The rules above are only for taxable brokerage accounts. Retirement accounts work differently:

This creates a planning opportunity. Many retirees withdraw from the taxable account first, using the 0% capital gains bracket, while letting the Roth grow. Traditional IRA withdrawals fill in the gaps. The right order depends on your situation, so this is a good question for a tax professional.

Do you need help from a professional?

A CPA or an enrolled agent earns their fee when any of these apply to you:

One meeting before a large sale can save far more than it costs. Nothing in this article replaces advice from someone who knows your full tax picture.

Your next step

Log in to your brokerage account this week and find the cost basis report for each index fund you own. Note which lots are short-term and which are long-term, and which have the highest basis. Then write down your expected taxable income for this year. With those two numbers in hand, you can decide exactly how many shares to sell before December 31 and keep most of the gain in the 0% bracket.

FAQ

Do I pay capital gains tax on index funds inside my 401(k)?

No. Sales inside a 401(k), traditional IRA, or Roth IRA are not taxed as capital gains. Traditional accounts are taxed as ordinary income when you withdraw. Qualified Roth withdrawals are tax-free.

Do reinvested dividends count toward my cost basis?

Yes. Every reinvested dividend bought shares at a price, and that price is added to your basis. You already paid tax on those dividends, so forgetting them means paying tax twice.

Can I sell index funds and buy them right back to use the 0% rate?

Yes. The wash sale rule only applies to losses. If you sell at a gain inside the 0% bracket and buy the same fund back, the gain is taxed at 0% and your new, higher cost basis reduces future gains.

Clear money tips in your inbox. No hype.

Share𝕏✆f

Educational content, not personalized financial advice. Sources cited where applicable.

Clear money tips in your inbox. No hype.