VestInClassStart

Tax-Loss Harvesting & Other Legal Ways to Keep More

How tax-loss harvesting, gain harvesting, and tax bracket management help DIY investors legally reduce what they owe.

AdvancedBy Matthew Hollander, CMP6 min readPublished March 15, 2026

Most investing advice focuses on returns before tax. But two investors with identical pre-tax returns can end up with meaningfully different after-tax wealth, depending on how well they manage the tax side of a taxable brokerage account. None of the strategies below involve anything exotic or aggressive. They're standard, legal techniques that mostly just require paying attention at the right moments.

Tax-loss harvesting: turning a loss into a tax deduction

Tax-loss harvesting means selling an investment that's currently worth less than you paid for it, locking in the loss for tax purposes, and using that loss to offset gains (or a limited amount of ordinary income) elsewhere on your tax return.

Why this matters: in a taxable brokerage account, selling an investment at a profit creates a capital gain, which is taxable. Selling at a loss creates a capital loss, which can offset those gains dollar for dollar. If your losses exceed your gains in a given year, up to $3,000 of the excess can offset ordinary income, and any leftover loss carries forward to future tax years indefinitely.

A simple example: Jordan bought $20,000 of a total stock market index fund. It's now worth $17,000, a $3,000 unrealized loss. Jordan also sold a different investment earlier in the year for a $3,000 realized gain. By selling the losing position, Jordan "harvests" a $3,000 loss that exactly offsets the $3,000 gain, reducing that year's capital gains tax to zero on those two trades combined.

Tip

"Unrealized" means the gain or loss exists only on paper: you still hold the investment. "Realized" means you've actually sold, which is the point at which a gain or loss becomes taxable (or deductible).

The wash sale rule: the catch you can't skip

The IRS doesn't let you harvest a loss and then immediately buy back the same investment. That would let you claim a tax deduction while your actual portfolio position never changed. The wash sale rule disallows the loss if you buy a "substantially identical" security within 30 days before or after the sale.

The standard workaround: sell the losing fund and immediately buy a similar, but not identical, replacement. In practice that means selling a total U.S. stock market index fund from one provider and buying a similar (but distinct) total U.S. stock market fund from a different provider. This keeps your overall market exposure essentially unchanged while staying outside the wash sale rule. After 30 days, you can switch back to the original fund if you prefer, or simply stay in the replacement.

Watch out

The wash sale rule applies across all your accounts, including your spouse's and even your IRA. Buying the same fund back inside an IRA within the 30-day window still triggers a wash sale on the taxable account sale, and unlike a taxable account, a wash sale inside an IRA typically permanently disallows the loss rather than just deferring it.

When harvesting makes the most sense

  • Down markets. Broad downturns create the most harvesting opportunities, since a wider swath of your portfolio sits at a loss simultaneously.
  • Rebalancing time. If you're already planning to sell a position to rebalance your portfolio, check whether it's at a loss first. You might as well harvest it on the way out.
  • High-income years. The value of an ordinary-income offset (up to $3,000/year) is worth more to someone in a high tax bracket than someone in a low one, so timing harvested losses against ordinary income deductions matters most in high-earning years.

Gain harvesting: the opposite strategy, for low-income years

Gain harvesting flips the logic: intentionally selling appreciated investments in a year when your income (and therefore your capital gains tax rate) is unusually low, often specifically during early retirement, before other income sources begin.

Long-term capital gains (on investments held over a year) are taxed at 0%, 15%, or 20% depending on total taxable income, with the 0% bracket covering a meaningful amount of income for single filers and married couples. Someone in early retirement with little or no earned income can potentially realize a substantial amount of long-term capital gains at a 0% federal tax rate, simply by selling and immediately rebuying the same investment (there's no wash sale rule for gains, only losses) to "step up" their cost basis for free.

A simplified example: a retired couple with $30,000 in other income sells $40,000 of long-term stock gains, staying within the 0% long-term capital gains bracket for their filing status and income level. They immediately rebuy the same investment, resetting their cost basis $40,000 higher at zero tax cost. Every dollar of that $40,000 will never be taxed again as a gain, since it's now part of the cost basis rather than embedded gain.

Why gain harvesting pairs naturally with early retirement

Early retirees often have a multi-year window of low taxable income before Social Security, pensions, or Roth conversion ladder income begins. That window is exactly when gain harvesting (and Roth conversions) are most valuable: both strategies work by filling up low tax brackets with taxable events while the rate is cheap.

Bracket management: the strategy underneath both

Both tax-loss harvesting and gain harvesting are really specific applications of a broader idea: bracket management, meaning deliberately timing taxable events (selling investments, converting retirement accounts, taking income) to land in the tax bracket that costs you the least over your lifetime, not just this year.

Applied well, bracket management often means:

  • Harvesting losses in high-income years to offset gains and ordinary income at the highest marginal value.
  • Harvesting gains in low-income years (often early retirement) to reset cost basis at a 0% rate.
  • Coordinating with Roth conversions, since both gain harvesting and conversions compete for the same limited "cheap" tax bracket space in a given year. Doing too much of both in the same year can push income into a higher bracket than necessary.
  • Watching for secondary effects, like health insurance subsidy phase-outs, which are based on total taxable income and can be affected by a large harvesting or conversion event in the same year.

Key takeaway

Tax-loss harvesting and gain harvesting are mirror-image strategies for the same underlying goal: controlling when and how much taxable income you realize. Losses are most valuable in high-income years to offset gains; gains are most valuable in low-income years to lock in a 0% rate. Both only apply to taxable brokerage accounts, never to 401(k)s or IRAs.

A word of caution

None of these strategies should drive investment decisions on their own. Selling a genuinely good long-term holding purely to harvest a small loss, or over-trading to chase tax optimization, usually costs more in complexity, transaction friction, and behavioral risk than it saves in tax. Tax-loss and gain harvesting work best as a periodic check, once or twice a year or after a significant market move, not a constant activity.

These strategies matter most for money outside retirement accounts. See investment account priority order for how taxable brokerage accounts fit alongside tax-advantaged ones, and the Roth conversion ladder for the early-retirement-specific strategy that pairs naturally with gain harvesting.

Frequently asked questions

Does tax-loss harvesting actually save me money, or just delay taxes?

Both, depending on how you use it. If you use harvested losses to offset gains you'd otherwise owe tax on now, and never sell the replacement investment at a gain later without another offset, you've effectively delayed the tax bill. Delaying taxes is still valuable, because the money you would have paid the IRS keeps compounding in the market in the meantime. Some of the benefit does eventually get paid back through a lower cost basis on the replacement shares.

What is the wash sale rule and why does it matter for harvesting?

The wash sale rule disallows a tax loss if you buy a 'substantially identical' security within 30 days before or after the sale that created the loss. It matters because harvesting a loss and then immediately buying back the exact same fund would violate the rule and erase the deduction. Investors get around this by buying a similar but not identical replacement fund during the 30-day window.

Can I do tax-loss harvesting inside my 401(k) or IRA?

No. Tax-loss harvesting only applies to taxable brokerage accounts, because retirement accounts like 401(k)s and IRAs already grow tax-deferred or tax-free. There's no annual capital gains tax being generated inside them to offset in the first place.

Related reading

This article is for educational purposes only and isn’t personalized financial, tax, or legal advice. See our disclaimer.