Bitcoin US$ 86,614Ethereum US$ 2,733EUR/USD 1.122GBP/USD 1.320USD/BRL 5.22Bitcoin US$ 86,614Ethereum US$ 2,733EUR/USD 1.122GBP/USD 1.320USD/BRL 5.22
Investing BasicsUpdated 2026-10-049 min read

Selling Index Funds? How Capital Gains Tax Is Calculated

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
Step-by-step math for capital gains tax on index fund sales: cost basis, reinvested dividends, short vs long-term…
Quick answer: Subtract your cost basis, including reinvested dividends, from the sale amount. Shares held over one year get long-term federal rates of 0%, 15%, or 20% based on income; shares held one year or less are taxed as ordinary income. Sales inside a 401(k) or IRA owe no capital gains tax.↗ Share on X

To calculate capital gains tax on an index fund sale, subtract your cost basis (what you paid, including reinvested dividends) from the sale amount, then apply the right tax rate based on how long you held the shares. Shares held more than one year get long-term rates of 0%, 15%, or 20% at the federal level, depending on your taxable income. Shares held one year or less are taxed as ordinary income, at your regular tax bracket. If you sell inside a 401(k) or IRA, there is no capital gains tax on the sale at all.

Below is the step-by-step math, a worked example, and the mistakes that make people pay more than they owe.

This article is general education, not tax advice. Your situation may have details that change the answer, so check with a tax professional or CPA before a large sale.

What is a capital gain, in plain words?

READ ALSOHow to Calculate Dividend Yield on Index Funds, Step by Step →Invest $100 a Month in Index Funds: A Stress-Free Setup →What Savings Rate Do You Need for Retirement at Age 30? →

A capital gain is the profit you make when you sell something for more than you paid. For an index fund, the "something" is your fund shares.

You only owe tax on a gain when you sell (this is called "realizing" the gain). If the fund goes up and you keep holding, there is no capital gains tax on the sale yet.

Clear money tips in your inbox. No hype.

How do I calculate my gain step by step?

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.

Follow these six steps for each sale.

1. Find the sale amount. Look at your brokerage confirmation or Form 1099-B. Use the net amount after any fees.

2. Find the cost basis of the exact shares sold. Your broker usually reports this on Form 1099-B for shares bought in recent years. For very old shares, you may need your own records.

3. Check which cost basis method was used. This decides *which* shares were sold (more on this below).

4. Split the shares by holding period. Shares held more than one year are long-term. Shares held one year or less are short-term. One sale can include both.

5. Subtract basis from sale amount for each group. You now have a short-term gain or loss and a long-term gain or loss.

6. Net them together. Short-term losses offset short-term gains first, long-term losses offset long-term gains first, then any leftover loss can offset the other type.

What tax rate applies to my gain?

READ ALSOHow Much to Save for Retirement: 6-Step Do-It-Yourself Math →How to Read a Brokerage Statement: The 4 Parts That Matter →How to Calculate Retirement Savings Before Quitting →
Holding periodTypeFederal rate
One year or lessShort-termYour ordinary income tax bracket
More than one yearLong-term0%, 15%, or 20%, based on taxable income

The income cutoffs for 0%, 15%, and 20% change every year with inflation and depend on your filing status (single, married filing jointly, and so on). Look up the current year's thresholds on IRS.gov or in your tax software rather than relying on an old chart.

Two extra layers can apply:

Can you show me a worked example?

Here is a simple example with round numbers. These are made-up figures, used only to show the math.

Maria bought index fund shares over time in a regular taxable brokerage account:

PurchaseSharesCost
Original purchase, 3 years ago100$10,000
Reinvested dividends over 3 years6$650
Purchase 8 months ago20$2,600
Total126$13,250

She sells all 126 shares today for $16,380 total.

If Maria is in the 15% long-term bracket, her federal capital gains tax on this sale is about $3,130 × 15% = $469.50, plus any state tax and NIIT if they apply to her.

Notice what happens if she forgets the reinvested dividends: her basis drops from $10,650 to $10,000, and her reported gain grows by $650. At 15%, she would pay about $97.50 extra in tax on money that was already taxed when the dividends were paid.

Why do reinvested dividends matter so much?

Every year your index fund pays dividends. If you reinvest them, you pay tax on those dividends in that year, and they buy more shares. Those new shares have a cost basis equal to the reinvested amount.

If you leave them out of your basis when you sell, you pay tax on the same money twice. Over 10 or 20 years of reinvesting, this can add up to a large number. Most brokers track this for you, but check your 1099-B, especially for shares moved between brokers.

Which cost basis method should I use?

When you sell only part of your shares, the method decides which shares you sold. That changes your gain and your holding period.

MethodHow it worksGood for
FIFO (first in, first out)Oldest shares sold firstSimple; often gives long-term treatment, but oldest shares may have the biggest gains
Specific identificationYou pick the exact lots to sellMost control; can pick high-basis shares to lower the gain
Average costBasis is the average price of all sharesAllowed for mutual fund shares; easy, but less control

Most brokers let you set a default method in your account settings. Choose the method before you place the sale. Changing it after the trade settles is usually not possible.

A common strategy is to sell the lots with the highest cost basis that have also been held more than one year. That keeps the gain small and the rate low.

What if I sold at a loss?

A loss can lower your taxes.

Watch out for the wash sale rule. If you buy the same or a "substantially identical" fund within 30 days before or after selling at a loss, you can't claim the loss right away. It gets added to the basis of the new shares instead. Automatic dividend reinvestment can trigger this by accident, so consider pausing it before selling at a loss. Whether two different index funds that track the same index count as substantially identical is not fully settled, so ask a tax professional before relying on a swap.

What about capital gain distributions I didn't sell?

Index mutual funds sometimes pay capital gain distributions at year-end, even if you never sold a share. These show up on Form 1099-DIV and are taxed as long-term gains no matter how long you held the fund.

Index ETFs tend to pay these less often because of how they are built, but it can still happen. If you hold index funds in a taxable account, check your 1099-DIV every year.

Which tax forms will I see?

Tax software usually imports the 1099-B directly. Still, compare the cost basis it shows against your own records before you file.

What mistakes cost people the most?

When should I talk to a professional?

Talk to a CPA or enrolled agent if your sale is large, if you have shares inherited from someone (inherited shares usually get a new basis), if shares were gifted to you, if your broker shows "basis not reported," or if you are close to the NIIT income line. A one-hour consultation can cost far less than a filing mistake.

Your next step

Log in to your brokerage account today, open the "cost basis" or "unrealized gains" page for your index fund, and look at each lot: purchase date, basis, and current gain. Before you sell anything, confirm your cost basis method in account settings and note which lots will pass the one-year mark soon. If the sale is large, bring that page to a tax professional before you click "sell."

FAQ

Do reinvested dividends count in my cost basis?

Yes. Each reinvested dividend bought new shares, and you already paid tax on it that year. Adding it to your cost basis keeps you from paying tax on the same money twice when you sell.

How long must I hold an index fund to get long-term rates?

More than one year from the purchase date of each lot. Shares bought at different times, including reinvested dividend shares, each have their own holding period.

Can I deduct a loss from selling an index fund?

Losses offset capital gains first, then up to $3,000 a year of ordinary income ($1,500 if married filing separately), with the rest carried forward. Buying the same fund within 30 days before or after the sale can trigger the wash sale rule and delay the loss.

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.