Guide
Capital gains tax explained
You bought a stock, ETF, or token. It went up. When you sell, the IRS cares about one number: your capital gain — sale proceeds minus your cost basis. That gain is taxed differently depending on how long you held the asset, what other gains and losses you realized in the same year, and whether the account is taxable or sheltered inside a 401(k) or IRA. This guide walks through short-term vs long-term rates, basis tracking, loss offsets, tax-loss harvesting, crypto-specific wrinkles, and the checklist every investor should run before clicking Sell in a taxable brokerage.
This is general educational information, not personalized tax advice. Rules change; consult a qualified tax professional for your situation.
Realized vs unrealized gains
An unrealized gain exists on paper while you still hold the asset. Portfolio apps show green numbers; the tax bill has not arrived. A realized gain is created only when you dispose of the asset — sell for cash, swap one crypto for another, gift above certain thresholds, or sometimes when a fund distributes capital gains to shareholders even if you did not sell shares.
The basic formula is straightforward:
Capital gain = amount realized (proceeds) − adjusted cost basis
Proceeds are what you received — net of commissions in most broker reporting. Cost basis includes the purchase price plus certain adjustments: reinvested dividends that were taxed as income (increasing basis), stock splits, and return of capital distributions that reduce basis. If proceeds are less than basis, you have a capital loss instead.
Holding a winner for years creates no current tax. That is why long-term investors often prefer to defer sales — and why account placement (taxable vs retirement) matters as much as which fund you pick.
Short-term vs long-term holding periods
U.S. federal tax law splits gains into two buckets based on holding period:
- Short-term — asset held one year or less. Gains are taxed at ordinary income rates (the same brackets as wages), which for many investors top out higher than long-term rates.
- Long-term — asset held more than one year. Gains qualify for preferential long-term capital gains rates (0%, 15%, or 20% at the federal level for most assets, depending on taxable income).
The one-year clock usually starts the day after purchase and ends the day of sale. Partial lots matter: if you bought 100 shares on three dates, each lot has its own holding period when you sell part of the position.
Why it matters in practice: selling a winner at 11 months vs 13 months can change the marginal rate by ten percentage points or more for high earners. Traders who flip positions weekly pay ordinary rates on every win. Buy-and-hold investors who rebalance annually often harvest long-term treatment on core holdings.
Some assets follow different rules — collectibles may face a 28% cap, and depreciation recapture on real estate is a separate category — but stocks, ETFs, most mutual funds, and typical crypto dispositions use the standard short/long split.
Cost basis methods and lot tracking
When you accumulate multiple purchases of the same ticker, the broker must know which shares you sold to compute gain. Common methods:
- FIFO (first in, first out) — default at many brokers; oldest lots sell first. Can maximize long-term treatment if early lots are aged, or trigger short-term gains if recent buys are sold first under partial sales.
- Specific identification — you tell the broker which tax lots to sell (by purchase date or lot ID). Most flexible for tax planning if you act before settlement; some platforms require advance lot selection on the order ticket.
- Average cost — common for mutual funds; all shares share one average basis. Simplifies record-keeping but removes lot-by-lot optimization.
- HIFO / LIFO — highest or lowest cost first; useful when harvesting losses or minimizing gains if your broker supports it.
Broker 1099-B forms report proceeds and often basis, but the filer remains responsible for accuracy — especially for transfers between accounts, gifted shares, or crypto moved off-exchange. Keep your own ledger when in doubt.
Netting gains and losses
Capital gains and losses net inside the tax year in a fixed order:
- Short-term gains and losses net against each other.
- Long-term gains and losses net against each other.
- If one bucket has a net loss and the other a net gain, they offset each other (short-term loss offsets long-term gain and vice versa).
- Remaining net capital loss (up to $3,000 per year for married filing jointly; $1,500 if married filing separately) can offset ordinary income; excess carries forward to future years.
Because short-term gains face higher rates, a short-term loss is often more valuable per dollar when offsetting short-term gains — and why tax-loss harvesting targets lots with the biggest rate-adjusted benefit, not just the biggest red numbers on screen.
Wash-sale rules can disallow a loss if you rebuy a substantially identical security within 30 days before or after the sale. Harvesting strategies use substitute ETFs or wait out the window — covered in detail in the harvesting guide.
NIIT and state taxes
High-income taxpayers may owe an extra 3.8% Net Investment Income Tax (NIIT) on net investment income (including capital gains, dividends, and interest) when modified adjusted gross income exceeds thresholds (historically around $200k single / $250k married filing jointly — verify current-year limits). NIIT stacks on top of regular capital gains rates, so a 15% long-term gain can effectively become 18.8% before state tax.
State capital gains taxes vary widely: some states tax gains as ordinary income, others offer exclusions or lower rates, and a few have no income tax at all. Remote workers and multi-state filers can face sourcing questions on where a gain is taxed. Federal loss carryforwards do not always mirror state treatment.
Tax-advantaged accounts vs taxable brokerage
Account type determines whether capital gains tax applies at all in the current year:
- Taxable brokerage — every sale can trigger capital gains tax; dividends may be qualified or ordinary. Full reporting on 1099-B and Schedule D. Best for tax-loss harvesting and long-term hold of tax-efficient assets.
- Traditional 401(k) / IRA — no capital gains tax on trades inside the account; withdrawals taxed as ordinary income in retirement. Ideal for active rebalancing and high-turnover funds.
- Roth 401(k) / Roth IRA — qualified withdrawals tax-free; no annual tax on gains inside the account. See our retirement accounts guide for contribution limits and withdrawal rules.
Asset location — placing tax-inefficient assets (bonds throwing ordinary income, REITs, actively traded strategies) in retirement accounts while holding broad index ETFs in taxable — can add meaningful after-tax return without changing overall risk. Pair with rebalancing plans that respect which account sells what.
Crypto and digital asset capital gains
For U.S. taxpayers, the IRS treats most convertible digital assets as property. Every disposition is a taxable event — selling for dollars, swapping ETH for SOL, paying for goods with crypto, and many DeFi interactions (liquidity provision, some airdrops, token migrations) can trigger gain or loss calculation.
- Lot tracking is mandatory — exchanges may not supply complete 1099s; self-custody moves break broker reporting. Use cost-basis software or spreadsheets from day one.
- Income vs capital gain — staking rewards, mining, and some airdrops are often ordinary income when received; basis is set at that value. A later price drop creates a capital loss on sale, not a reversal of income.
- Wash-sale clarity — statutory wash-sale rules historically targeted securities; crypto treatment has been ambiguous. Conservative planners assume similar logic may apply as regulation tightens.
- Loss carryforwards — crypto capital losses net the same way as stock losses, subject to the same annual ordinary-income offset cap.
Policy headlines — staking de minimis thresholds, broker reporting rules — can change filing burden without changing the core gain formula. Track lots; do not rely on year-end guesses.
Mutual fund and ETF distributions
You can owe capital gains tax without selling if a fund distributes embedded gains near year-end — common in active mutual funds after strong in-fund appreciation. ETF share creation/redemption mechanics often make ETFs more tax-efficient in taxable accounts, though not immune to distributions.
Reinvested distributions increase your cost basis (so you are not double-taxed when you eventually sell). Check the 1099-DIV and adjust basis on your records if the broker’s adjusted basis feed lags.
Reporting: 1099-B and Schedule D
Brokers send Form 1099-B summarizing proceeds and reported basis for covered securities. You consolidate on Schedule D and Form 8949 if adjustments are needed (missing basis, gifted shares, crypto off-exchange).
Common filing friction points:
- Box 3 “basis not reported to IRS” — you must document basis or overpay.
- Corporate actions (mergers, spinoffs) require basis allocation across new tickers.
- Multiple wallets and bridges — cost basis breaks if you cannot trace transfer history.
- Estimated tax payments — large realized gains may require quarterly estimates to avoid underpayment penalties.
Planning levers before you sell
| Lever | What it does | Watch out for |
|---|---|---|
| Extend holding period | Converts short-term gain into long-term rate | Concentration risk if you hold purely for tax timing |
| Specific lot selection | Sell highest-basis shares to minimize gain | Must designate before trade settles at many brokers |
| Harvest offsetting losses | Net gains against realized losses same year | Wash-sale window; dividend reinvestment on same ticker |
| Donate appreciated shares | Charitable deduction at FMV; no capital gain on donated lot | Itemizing vs standard deduction; AGI limits on donations |
| Rebalance in IRA | No current capital gains hit on trades inside account | Future ordinary-income tax on Traditional withdrawals |
Common mistakes
- Selling at 364 days — One day can flip the rate bucket; calendar alerts help.
- Ignoring reinvested dividends in basis — Overstates gain on final sale.
- Assuming crypto swaps are non-taxable — Most are dispositions.
- Trading heavily in taxable while maxing Roth — Suboptimal asset location.
- Default FIFO when HIFO would save more — Change default lot method or specify per trade.
- Forgetting NIIT and state tax — Federal long-term rate is not the all-in cost.
- No records for gifts and inheritances — Basis rules differ; stepped-up basis at death is not automatic documentation.
Production checklist
- Know your account type — taxable vs IRA vs Roth — before optimizing ticker-level trades.
- Set broker default lot method or commit to specific identification on every taxable sale.
- Track holding periods; flag positions approaching one year if rate arbitrage matters.
- Export trade history quarterly; reconcile 1099-B against your ledger.
- Plan harvests before year-end with wash-sale substitutes ready.
- Separate crypto income events (staking) from disposal gains in your records.
- Model federal + NIIT + state before large single-lot sales.
- Consider estimated tax payments when realizing six-figure gains mid-year.
- Prefer tax-efficient ETFs in taxable; rebalance bonds in retirement accounts.
- Consult a CPA when corporate actions, ISO stock options, or multi-state filing appear.
Key takeaways
- Capital gains tax applies only when gains are realized — proceeds minus adjusted basis.
- One year is the dividing line between ordinary short-term rates and preferential long-term rates.
- Cost basis method (FIFO, specific ID, average) directly changes the tax bill on identical tickers.
- Gains and losses net across short and long buckets, with limited ordinary-income offset for excess losses.
- Account placement often beats trade timing — shelter active strategies in IRAs, harvest in taxable.
- Crypto requires rigorous lot tracking; swaps and DeFi moves are usually taxable dispositions.
Related reading
- Tax-loss harvesting explained — wash sales, substitute ETFs, and offsetting gains with realized losses
- Mutual funds explained — NAV pricing, distributions, and average-cost basis
- ETFs explained — tax efficiency, in-kind creation, and taxable-account cores
- Retirement accounts (401k and Roth IRA) explained — when capital gains tax does not apply inside the account