When you sell an investment for more than you paid, the profit is a capital gain โ€” and it is taxable. Understanding how capital gains are taxed is essential for any investor, because the difference between short-term and long-term rates can be enormous, and strategies like tax-loss harvesting can save thousands. This guide covers the basics.

What Is a Capital Gain?

A capital gain is the profit from selling an investment (or other asset) for more than its purchase price (cost basis).

Capital Gain = Sale Price - Cost Basis

If you buy 100 shares of a stock at $50 ($5,000 total) and sell them at $80 ($8,000 total), your capital gain is $3,000.

Capital gains apply to:

  • Stocks, bonds, and ETFs
  • Mutual funds
  • Real estate (with special exclusions for primary homes)
  • Cryptocurrency
  • Collectibles and other assets

Capital losses (selling for less than you paid) can offset capital gains. See the tax-loss harvesting section below.

Short-Term vs Long-Term Capital Gains

The holding period determines the tax rate:

Short-term capital gains: Investments held one year or less before selling. Taxed at your ordinary income tax rate (10%โ€“37%), the same as wages.

Long-term capital gains: Investments held more than one year before selling. Taxed at preferential rates: 0%, 15%, or 20% depending on your income.

The difference is dramatic. A worker in the 22% ordinary bracket pays:

  • 22% on short-term gains
  • 15% on long-term gains

On a $10,000 gain, that is $2,200 (short-term) vs $1,500 (long-term) โ€” a $700 difference from holding one extra day past the one-year mark.

2024 Long-Term Capital Gains Rates

Taxable Income (Single)Taxable Income (Married Joint)Long-Term Rate
$0 โ€“ $47,025$0 โ€“ $94,0500%
$47,026 โ€“ $518,900$94,051 โ€“ $583,75015%
Over $518,900Over $583,75020%

Most investors pay 15% on long-term gains. Those with lower incomes pay 0% โ€” meaning if your taxable income is below $47,025 (single) or $94,050 (married), your long-term capital gains are tax-free at the federal level.

This creates a powerful strategy: retirees or those in low-income years can realize long-term gains at 0% tax. See How Taxes Work for the broader tax context.

How to Calculate Your Capital Gains Tax

Step 1: Determine your cost basis. This is what you paid for the investment, including commissions. For reinvested dividends, each reinvestment adds to your cost basis.

Step 2: Determine your sale proceeds. This is what you sold it for, minus selling commissions.

Step 3: Calculate the gain. Sale proceeds minus cost basis = capital gain (or loss).

Step 4: Determine short-term or long-term. Based on the holding period from purchase date to sale date.

Step 5: Apply the rate. Short-term uses your ordinary rate; long-term uses 0%, 15%, or 20% based on your income.

Example: You bought 100 shares of an ETF at $50 ($5,000) on January 1, 2023, and sold them at $80 ($8,000) on March 1, 2024 (held 14 months โ€” long-term). Your taxable income is $80,000 (single), putting you in the 15% long-term bracket.

  • Gain: $8,000 - $5,000 = $3,000
  • Tax: $3,000 ร— 15% = $450

Tax-Loss Harvesting

If you have investment losses, you can use them to offset capital gains:

  1. Offset gains with losses: If you have $3,000 in gains and $2,000 in losses, your net taxable gain is $1,000.
  2. Offset ordinary income: If your losses exceed your gains, up to $3,000 of the excess can offset ordinary income each year.
  3. Carry forward: Losses beyond $3,000 carry forward to future years indefinitely.

Example: You have $5,000 in long-term gains and $8,000 in losses. You offset all $5,000 in gains, then use $3,000 of the remaining $3,000 loss to offset ordinary income. The result: $0 capital gains tax and $3,000 ร— 22% = $660 in ordinary income tax savings.

Beware the wash-sale rule: You cannot buy the same or a "substantially identical" security within 30 days before or after selling at a loss, or the loss is disallowed. To maintain your market exposure while harvesting a loss, buy a similar but not identical fund (e.g., swap one total market fund for a different provider total market fund).

Minimizing Capital Gains Tax

1. Hold Investments Over One Year

The single most impactful strategy: hold investments for more than one year to qualify for long-term rates. The difference between 22% (short-term) and 15% (long-term) is significant on large gains.

2. Use Tax-Advantaged Accounts

Investments inside a 401(k), Traditional IRA, or Roth IRA are not subject to capital gains tax:

  • Traditional 401(k)/IRA: No capital gains tax while growing; withdrawals taxed as ordinary income
  • Roth IRA/401(k): No capital gains tax; qualified withdrawals are tax-free

This is a major advantage of tax-advantaged accounts โ€” you can buy, sell, and rebalance inside them with no tax consequences. Maximize these accounts for investments that generate frequent taxable events. See How a 401(k) Works.

3. Asset Location

Place tax-inefficient investments (actively managed funds, REITs, high-dividend stocks) in tax-advantaged accounts where their gains and distributions are sheltered. Place tax-efficient investments (broad index ETFs) in taxable accounts. See Asset Allocation.

4. Tax-Loss Harvest Annually

Review your taxable portfolio at year-end for losses. Harvest them to offset gains and up to $3,000 of ordinary income. This is a powerful annual tax strategy for taxable accounts.

5. Donate Appreciated Stock

If you give to charity, donate appreciated stock you have held over one year. You deduct the full fair market value AND pay no capital gains tax on the appreciation. This is far better than selling the stock (paying gains tax) and donating cash.

6. Hold Until Death (Step-Up in Basis)

Assets you hold until death receive a "step-up in basis" to their current market value. Your heirs inherit the asset at the current value with no capital gains tax on the lifetime appreciation. This is a powerful estate planning strategy for highly appreciated assets.


Frequently Asked Questions

Q: Do I owe capital gains tax if I do not sell? No. Capital gains are only realized when you sell. Unrealized gains (investments you still hold) are not taxed. This is why buy-and-hold investing is tax-efficient โ€” you defer taxes until you choose to sell.

Q: How are dividends taxed? Qualified dividends (from most US and some foreign companies, held for a minimum period) are taxed at long-term capital gains rates (0%, 15%, 20%). Non-qualified dividends are taxed at ordinary income rates. Most index fund dividends are qualified. See ETFs Explained.

Q: What is the wash-sale rule? If you sell an investment at a loss and buy the same or a substantially identical security within 30 days before or after, the loss is disallowed (deferred until you sell the replacement). To harvest a loss while staying invested, buy a similar but not identical fund.

Q: Do I pay capital gains tax inside my IRA or 401(k)? No. Sales inside tax-advantaged accounts do not trigger capital gains tax. Traditional account withdrawals are taxed as ordinary income; Roth withdrawals are tax-free. This is a major advantage of these accounts. See How Taxes Work.

Q: What is the 0% long-term capital gains bracket? If your taxable income is below $47,025 (single) or $94,050 (married) in 2024, your long-term capital gains are taxed at 0% federally. This benefits retirees and low-income years โ€” you can realize gains tax-free in these years.

Q: How does real estate capital gains work? Primary home sales have a special exclusion: up to $250,000 of gain ($500,000 married) is tax-free if you lived in the home 2 of the last 5 years. Investment property gains are taxed as capital gains but depreciation recapture may apply. See a tax professional for real estate specifics.