You buy a stock or fund, it goes up, and at some point you wonder: when does the government want its cut? The short answer is that it depends on where you hold the investment and when you sell it. Money growing inside a retirement account is left alone until you withdraw it. Money in a regular brokerage account plays by a different set of rules, and those rules are worth understanding before you sell.

This article covers how gains are taxed in a taxable account. For the accounts that mostly sidestep these taxes, see What Is A Brokerage Account? and How To Maximize Your Tax-Advantaged Accounts.

Where You Hold It Changes Everything

The same investment can be taxed very differently depending on the account.

Inside a 401(k), traditional IRA, or Roth IRA, you do not owe tax as your investments grow or when you buy and sell within the account. Traditional accounts get taxed when you withdraw in retirement; Roth accounts are not taxed on qualified withdrawals at all. Either way, there is no annual bill for gains and dividends.

Inside a regular taxable brokerage account, gains and dividends can create a tax bill in the year they happen. That is the tradeoff for the flexibility of an account with no contribution limits and no withdrawal rules.

So if all your investing happens in retirement accounts, most of what follows will not touch you for years. If you have a taxable account, read on.

Realized vs Unrealized Gains

A gain on paper is not taxed. If you bought a fund at $5,000 and it is now worth $8,000, that $3,000 gain is unrealized. You do not owe anything on it while you hold the investment, even if it grows for a decade.

You realize the gain when you sell. That is the moment the $3,000 becomes a taxable event. This is why long-term investors who buy and hold can defer taxes for years: no sale, no realized gain, no bill.

Short-Term vs Long-Term Capital Gains

When you do sell for a profit, how long you held the investment decides the rate.

  • Short-term capital gain: you held it one year or less. This is taxed as ordinary income, at the same rate as your paycheck. See What Is A Tax Bracket? for how those rates work.
  • Long-term capital gain: you held it more than one year. This gets special lower rates, generally 0%, 15%, or 20% depending on your total income.

The gap is significant. A short-term gain might be taxed at 22% or higher, while the same gain held a few weeks longer could be taxed at 15%, or even 0% for people with lower incomes. The income thresholds for the 0/15/20% brackets change each year, so check the current figures at IRS.gov, but the structure has been stable for a long time.

The practical takeaway: if you are close to the one-year mark and you do not urgently need to sell, waiting can meaningfully lower the tax.

How Dividends Are Taxed

If you own dividend-paying stocks or funds, you may receive dividends even in years you do not sell anything. These fall into two buckets:

  • Qualified dividends are taxed at the same favorable long-term capital gains rates (0/15/20%). Most dividends from US stocks and many funds held for the required period qualify.
  • Ordinary (non-qualified) dividends are taxed at your regular income rate.

Your brokerage sorts this out and reports it for you. You do not have to figure out which is which by hand, but it explains why two people with the same dividend income can owe different amounts.

Cost Basis: The Number That Decides Your Gain

Your cost basis is what you paid for an investment, including any reinvested dividends. Your gain (or loss) is the sale price minus the basis.

This matters more than people expect, because reinvested dividends quietly raise your basis over the years. If you forget to count them, you can overstate your gain and pay more tax than you owe. Brokerages track basis for you on most accounts now, but it is worth confirming the number looks right, especially if you transferred investments between firms.

The Forms Your Brokerage Sends

Around late January or February, your brokerage sends tax forms that report all of this:

  • 1099-B lists your sales, showing what you sold, your cost basis, and the gain or loss.
  • 1099-DIV reports dividends, split into qualified and ordinary.
  • 1099-INT reports interest, for example from a money market fund or cash sweep.

Hand these to whoever prepares your taxes or load them into your software. Most tax programs import them directly from the brokerage, which reduces the chance of a typo. You do not need to understand every box, but you do need to include every form.

Capital Losses Work in Your Favor

Not every sale is a gain. If you sell for less than you paid, you have a capital loss, and losses are useful at tax time.

First, losses offset gains. If you have a $2,000 gain and a $2,000 loss in the same year, they cancel out. If your losses exceed your gains, you can deduct up to $3,000 of the extra against ordinary income each year, and carry the rest forward to future years.

Deliberately selling a losing investment to capture this benefit is called tax-loss harvesting. It can be a reasonable move, but watch the trap below.

The Wash Sale Rule

If you sell an investment for a loss and buy the same or a “substantially identical” investment within 30 days before or after the sale, the IRS disallows the loss. This is the wash sale rule, and it exists to stop people from selling purely for the tax break and immediately buying back in.

If you are harvesting losses, either stay out of that specific investment for the window or buy something similar but not identical. When in doubt, this is a good question for a tax professional.

Common Mistakes

Selling right before the one-year mark. Holding a few extra days or weeks can shift a gain from ordinary rates to long-term rates. Check the purchase date before you sell.

Forgetting reinvested dividends in your basis. Those reinvestments were already taxed as dividends. If you do not count them toward basis, you pay tax twice on the same money.

Ignoring a 1099. The brokerage sends a copy to the IRS too. Leaving it off your return is a common way to trigger a letter from the IRS months later.

Doing all your investing in a taxable account when tax-advantaged space is available. If you have not used your 401(k) or IRA, filling those first usually beats a taxable account for long-term investing.

Frequently Asked Questions

Do I owe taxes if my investments went up but I did not sell?

Generally no, not in a taxable brokerage account. Unrealized gains are not taxed. You may still owe on dividends or interest paid during the year, even if you did not sell.

Do I pay capital gains tax inside my Roth IRA or 401(k)?

No. Buying and selling within those accounts does not create a capital gains bill. That is a large part of why they are so valuable for long-term investing.

What if I only made a small amount?

You still report it. Even small dividends and sales show up on the forms your brokerage sends to the IRS, so include them. The tax owed may be minor, but the return should match the paperwork.

Are index funds and ETFs taxed differently from stocks?

The same capital gains and dividend rules apply. ETFs are often a bit more tax-efficient inside a taxable account because of how they are structured, but the core rules are the same. See What Is An ETF? and What Is An Index Fund?.

Learn More

Note: This guide is for general education, not individualized financial, legal, tax, insurance, investment, or career advice. Read our editorial standards.