For most investors, the single largest controllable tax bill is the capital gains tax—and the single largest lever for reducing it is timing. Hold an asset for one day more than a year before selling, and your federal tax rate on the gain can drop from 37% to 0%. That gap, repeated across a portfolio over decades, can mean the difference between retiring comfortably and working five extra years. Yet many investors don't understand the holding-period rules, don't track their cost basis carefully, and don't harvest losses systematically.
This guide covers the holding period rules, 2024 long-term capital gains brackets, the NIIT surtax, tax-loss harvesting, the wash sale rule, the primary residence exclusion, 1031 exchanges, and how crypto is taxed. With these tools, you can legally keep tens of thousands of dollars that would otherwise go to the IRS.
The holding period rule: the most important line in the tax code
The IRS divides capital gains into two categories based on how long you held the asset before selling:
- Short-term capital gain: asset held one year or less. Taxed at your ordinary income tax rate—the same rate as your salary, up to 37% federal.
- Long-term capital gain: asset held more than one year. Taxed at preferential long-term rates: 0%, 15%, or 20%, depending on income.
The holding period clock starts the day after you acquire the asset and ends on the day you sell it. If you buy 100 shares of Apple on January 15, 2024, your holding period begins January 16. To qualify for long-term treatment, you must sell on January 17, 2025 or later.
Why the one-year cliff matters
Selling one day too early is a costly mistake. Consider a single filer with $80,000 of ordinary income who has a $20,000 capital gain on a stock position:
- If sold as short-term (held 11 months): the $20,000 is added to ordinary income, pushing total taxable income to $100,000. The gain is taxed at the 22% marginal rate = $4,400 in federal tax.
- If sold as long-term (held 13 months): with $80,000 ordinary income, the $20,000 long-term gain is taxed at 15% (because total income exceeds the 0% bracket threshold of $47,025 but is below the 15% threshold's upper end) = $3,000 in federal tax.
Waiting two extra months saves $1,400 on a $20,000 gain. On a $200,000 gain, the same logic saves $14,000. The date of sale is one of the few tax variables you control completely.
2024 long-term capital gains brackets
Long-term capital gains are taxed under their own bracket system, separate from ordinary income. The brackets are tied to your total taxable income (ordinary + capital gains combined):
Single filers
- 0% rate: taxable income up to $47,025
- 15% rate: $47,026 to $518,900
- 20% rate: over $518,900
Married filing jointly
- 0% rate: taxable income up to $94,050
- 15% rate: $94,051 to $583,750
- 20% rate: over $583,750
Head of household
- 0% rate: taxable income up to $63,000
- 15% rate: $63,001 to $551,350
- 20% rate: over $551,350
Most taxpayers pay 15% on long-term gains. The 0% bracket is a powerful opportunity for retirees, low-income years, and early-career savers—more on that below. The 20% rate affects only high earners.
Short-term gains: ordinary rates apply
Short-term gains are taxed at the same progressive rates as your salary. The 2024 ordinary brackets for single filers run 10%, 12%, 22%, 24%, 32%, 35%, and 37% (topping out at income over $609,350). For high earners, a short-term gain is taxed at up to 37%—nearly double the long-term rate.
This is why active traders, day traders, and high-turnover strategies face such large tax headwinds. A strategy that generates 100% annual turnover with 15% pretax returns nets the investor about 9.4% after taxes in the 37% bracket. The same 15% return with zero turnover (held over a year) nets 12.75%—a 3.4 percentage point annual drag that compounds into hundreds of thousands of dollars over a career.
The Net Investment Income Tax (NIIT)
High earners face an additional 3.8% surtax on investment income. The NIIT applies to the lesser of (a) your net investment income or (b) the amount by which your modified adjusted gross income exceeds:
- $200,000 (single or head of household)
- $250,000 (married filing jointly)
- $125,000 (married filing separately)
Investment income subject to NIIT includes capital gains, dividends, interest, rents, royalties, and passive business income. The NIIT stacks on top of the regular LTCG rate—so a single filer at $600,000 income pays 20% + 3.8% = 23.8% federal on long-term gains, plus applicable state taxes. In California, the combined marginal rate on a long-term gain at high income can exceed 37%.
Tax-loss harvesting: turning losses into tax savings
Capital losses offset capital gains dollar for dollar. If you have $20,000 in long-term gains and $15,000 in long-term losses, you net to $5,000 of taxable gain. If losses exceed gains, you can deduct up to $3,000 of the excess against ordinary income per year ($1,500 for married filing separately), with any remainder carrying forward indefinitely.
How harvesting works
In December (or any time), review your portfolio for positions trading below your cost basis. Sell them to realize the loss, which offsets gains elsewhere. Then immediately buy a similar but not "substantially identical" asset to maintain your market exposure.
Example: you have $10,000 of capital gains from selling appreciated Apple stock, and $8,000 of unrealized loss in a total stock market ETF (VTI). You sell VTI at a loss, offsetting $8,000 of the gain. Your taxable gain drops to $2,000. You immediately reinvest the proceeds in a different broad-market ETF like SCHB (Schwab Total Stock Market), keeping your market exposure essentially identical.
The wash sale rule
If you sell a security at a loss and buy a "substantially identical" security within 30 days before or after the sale (a 61-day window), the loss is disallowed and added to the cost basis of the replacement shares. The wash sale rule applies across all your accounts, including IRAs (since 2008, wash sales in IRAs permanently disallow the loss).
"Substantially identical" is not precisely defined, but the IRS has clarified that:
- Different shares of the same company are identical (sell Apple, buy Apple = wash)
- Different mutual funds tracking the same index may be substantially identical (sell VTI, buy ITOT—same index, different provider—debatable; sell VTI, buy SCHB—similar but different index methodology—safer)
- Different ETFs tracking different indexes (sell VTI, buy VOO—total market vs S&P 500) are not identical
- An S&P 500 ETF and a total stock market ETF are not identical
Conservative practice: harvest losses into a different but correlated asset class. Sell large-cap blend, buy large-cap value. Sell total US, buy total world. Wait 31 days, then switch back if you want.
The primary residence exclusion (Section 121)
One of the most generous tax breaks in the code: if you sell your primary residence, you can exclude up to $250,000 of gain from tax ($500,000 if married filing jointly)—provided you've owned and lived in the home as your primary residence for at least 2 of the last 5 years.
How it works
You bought a home in 2010 for $300,000. You sell it in 2024 for $800,000. The $500,000 gain, if you're single and meet the ownership/use tests, is fully excluded—no federal capital gains tax. If married filing jointly, you'd exclude up to $500,000, paying zero tax.
Important caveats
- The 2-of-5-year rule is cumulative—you don't have to live there continuously, just 24 months total within the 60-month window ending on the sale date.
- You can use the exclusion once every 2 years, not once per lifetime (this changed in 1997).
- Partial exclusions are available if you move for job, health, or unforeseen circumstances before meeting the 2-year test.
- Home office depreciation claimed after May 6, 1997 is "recaptured" at 25%—you can't exclude that portion.
- Gains exceeding the exclusion are long-term if you held the home more than one year.
1031 exchanges for investment property
Section 1031 of the Internal Revenue Code allows you to defer capital gains tax on the sale of investment real estate by reinvesting the proceeds in a like-kind property. The deferral can continue indefinitely—you can 1031 from one property to another for decades, never paying capital gains tax, until you finally sell for cash or die (at which point heirs get a stepped-up basis, eliminating the gain entirely).
Key rules
- Property must be held for investment or business use, not personal use.
- You must identify up to 3 replacement properties within 45 days of sale.
- You must close on the replacement property within 180 days of sale.
- The replacement property must be of equal or greater value to fully defer all gain.
- All cash and debt from the relinquished property must be reinvested.
- Use a qualified intermediary to hold the funds—you cannot touch the cash between sale and purchase.
What doesn't qualify for 1031 anymore
The Tax Cuts and Jobs Act of 2017 eliminated 1031 eligibility for personal property—art, collectibles, equipment, aircraft, cryptocurrency. Only real estate qualifies post-2018. Crypto investors who used to 1031 between tokens now must realize gains on every swap.
Cryptocurrency taxation
The IRS treats cryptocurrency as property for tax purposes. Every sale, trade, or use of crypto is a taxable event:
- Selling crypto for fiat: capital gain or loss based on cost basis vs sale price.
- Trading one crypto for another (Bitcoin for Ethereum): taxable event, even though no fiat was received.
- Using crypto to buy goods or services: taxable event on the gain.
- Earning crypto as income (mining, staking, salary): taxed as ordinary income at fair market value on receipt.
- Airdrops and forks: generally taxed as ordinary income at fair market value when received.
Tracking cost basis across hundreds of trades is painful—use crypto tax software like CoinTracker or Koinly. The wash sale rule technically doesn't apply to crypto (since it's property, not a "security"), but the IRS may close this loophole. Many tax advisors recommend treating crypto wash sales as if the rule applies, to be safe.
Stepped-up basis at death
When you die, your heirs inherit your assets with a "stepped-up" basis equal to the fair market value on your date of death. All unrealized capital gains during your lifetime are erased for tax purposes. If you bought $100,000 of stock that's worth $2 million when you die, your heirs' cost basis becomes $2 million—they can sell immediately and owe zero capital gains tax.
This is one reason wealthy families hold appreciated assets until death rather than selling. It's also why 1031 exchanges and Roth IRAs (which already avoid capital gains tax) are less attractive for assets intended to pass to heirs.
Tax-aware investing strategies
- Hold winners over a year whenever possible. The cost of waiting is usually less than the tax savings.
- Sell losers in taxable accounts to harvest losses, then immediately reinvest in non-identical assets.
- Locate tax-inefficient assets in tax-advantaged accounts: bonds, REITs, high-turnover funds belong in IRAs; tax-efficient index funds can go in taxable accounts.
- Use specific share identification when selling, not FIFO. This lets you sell highest-basis shares first to minimize gains.
- Gift appreciated stock to charity instead of cash. You deduct the fair market value and pay no capital gains tax on the appreciation.
- Harvest gains in low-income years to use the 0% bracket. If you're retired with $40,000 of income, you can realize up to $7,025 of long-term gains tax-free each year.
- Use donor-advised funds to bunch charitable contributions in high-income years, deducting the full fair market value of appreciated stock.
Common mistakes
- Not tracking cost basis. Brokerages are required to track basis for shares acquired after 2011, but older holdings and reinvested dividends need your attention.
- Triggering wash sales inadvertently by auto-reinvesting dividends in the same fund you just sold at a loss.
- Selling before the one-year mark unnecessarily. Check the holding period before every sale.
- Forgetting state capital gains taxes. California taxes capital gains as ordinary income—up to 13.3% on top of federal.
- Ignoring NIIT. If your income is near $200K (single) or $250K (MFJ), additional harvesting can push you into the surtax zone.
- Not using the 0% bracket in retirement. Many retirees pay 0% on long-term gains because their taxable income is below the threshold.
Putting it into practice
Capital gains tax planning is one of the highest-ROI activities in personal finance. Every $10,000 of gains shifted from short-term to long-term saves $2,200+ in federal tax for high earners. Every $3,000 of harvested losses saves $660+ at the 22% bracket. Over a lifetime, these moves add up to tens of thousands of dollars retained rather than remitted.
To calculate the tax impact of a sale before you make it, try our Capital Gains Calculator. Enter your cost basis, sale price, holding period, and income, and it computes your federal tax liability under short-term vs long-term treatment—including NIIT if applicable—so you can decide when to sell.