How to calculate capital gains tax on stocks — 2026 rates
Selling a winning stock at 11 months instead of 13 months can cost thousands more in tax on the exact same gain, for many taxpayers. The difference comes down to one thing: how long you held it. Short-term gains are taxed as ordinary income, up to 37%. Long-term gains get preferential rates of 0%, 15%, or 20%. Here's exactly how the math works for 2026, including the often-overlooked 3.8% surtax, which applies above fixed income thresholds and reaches more taxpayers over time as incomes rise.
What a capital gain is
A capital gain is the profit you make when you sell an investment for more than you paid for it — the sale price minus your cost basis (see our cost basis guide for how that number is calculated). Capital gains tax only applies to realized gains — meaning you actually sold the asset. Stocks that have grown in value but remain unsold are "unrealized" and owe no tax, no matter how large the paper gain.
This is a genuinely different treatment than most other income. Your salary is taxed the year you earn it. A stock gain is only taxed the year you sell — giving you meaningful control over timing that doesn't exist with wage income.
Short-term vs long-term — the holding period test
The single most important variable in capital gains tax is how long you held the asset before selling:
- Short-term capital gains — assets held one year or less. Taxed as ordinary income at your regular marginal tax rate: 10%, 12%, 22%, 24%, 32%, 35%, or 37% for 2026, depending on your total taxable income.
- Long-term capital gains — assets held more than one year. Taxed at preferential rates of 0%, 15%, or 20% depending on your taxable income — significantly lower than ordinary rates for most investors.
To qualify for long-term treatment, you must hold the asset for more than one year — meaning at least one year and one day. If you buy on March 15 and sell exactly one year later on March 15, that sale is still short-term. The holding period excludes your purchase date and starts counting the following day, running through and including your sale date. Missing this by even a single day can mean paying ordinary income rates instead of the much lower long-term rate on the exact same gain.
2026 long-term capital gains brackets
Long-term capital gains brackets are separate from — but stack on top of — your ordinary income. Your bracket is determined by your total taxable income (ordinary income plus the gain itself), not the gain in isolation:
| Rate | Single | Married filing jointly |
|---|---|---|
| 0% | Up to $49,450 | Up to $98,900 |
| 15% | $49,450 – $545,500 | $98,900 – $613,700 |
| 20% | Above $545,500 | Above $613,700 |
Source: IRS Revenue Procedure 2025-32. Thresholds apply to taxable income (after your standard or itemized deduction) — not gross income. Unlike the NIIT thresholds below, these brackets are adjusted annually for inflation.
Because these brackets stack on top of ordinary income, the gain itself can straddle multiple rates. If your ordinary income already fills most of the 15% bracket, only the portion of your gain that pushes you past the next threshold gets taxed at the higher rate — the rest stays at the lower one. This is identical in structure to how ordinary marginal tax brackets work.
If your total taxable income — including the gain — stays under $49,450 (single) or $98,900 (married), your long-term capital gains are taxed at 0% federally. This is a genuinely useful planning tool for retirees or anyone with a lower-income year: realizing gains while in this bracket, even without needing the cash, can reset your cost basis higher at no federal tax cost — a strategy sometimes called "gain harvesting," the inverse of tax-loss harvesting.
The 3.8% NIIT surtax
Above certain income thresholds, an additional 3.8% Net Investment Income Tax (NIIT) applies on top of whatever capital gains rate you already owe. This is sometimes called the Medicare surtax, part of the Affordable Care Act. It applies to net investment income — including capital gains, interest, dividends, and rental income — for taxpayers with Modified Adjusted Gross Income (MAGI) above:
- $200,000 for single filers
- $250,000 for married filing jointly
Unlike the capital gains brackets above, which are adjusted annually for inflation, the NIIT thresholds have not been indexed for inflation since the tax was enacted. Every year, more taxpayers cross into NIIT territory simply because their nominal income rises with inflation and career growth — even though their real, inflation-adjusted purchasing power hasn't necessarily increased. A "high earner" provision from 2013 increasingly captures upper-middle-class filers by 2026.
Stacked together, the effective top rate on long-term gains reaches 23.8% (20% + 3.8% NIIT) for the highest earners — and even the 15% bracket effectively becomes 18.8% once NIIT applies.
A worked example
A single filer with $180,000 in ordinary income sells stock for a $50,000 long-term gain:
The NIIT calculation applies to the lesser of the total net investment income ($50,000) or the amount MAGI exceeds the threshold ($230,000 − $200,000 = $30,000). Here, $30,000 is smaller, so NIIT applies only to that $30,000 slice — not the full $50,000 gain.
Now compare the same $50,000 gain if this investor had sold at 11 months instead of past the one-year mark. As short-term gain, it's taxed as ordinary income stacked on the existing $180,000 — meaning it fills the remainder of the 24% bracket first, then spills into the 32% bracket:
The two-month difference in holding period costs this investor $6,758 more in federal tax on the identical $50,000 gain — a meaningful illustration of why the one-year threshold matters, even though the effect is smaller than a flat-rate comparison would suggest. The exact gap depends heavily on your specific income and which brackets the gain straddles; use the calculator below to see your own numbers.
Using losses to offset gains
Capital losses aren't just a bad outcome to accept — they have real tax value. The IRS allows you to net your gains and losses against each other before calculating what you owe:
- Losses first offset gains of the same type. Short-term losses offset short-term gains first; long-term losses offset long-term gains first.
- Remaining losses offset the other type. If you have excess short-term losses after offsetting short-term gains, they can offset long-term gains, and vice versa.
- Excess losses offset ordinary income — up to $3,000/year. If losses still exceed all your gains, you can deduct up to $3,000 ($1,500 if married filing separately) against ordinary income like wages.
- Anything beyond that carries forward indefinitely. Unused losses roll forward to future tax years with no expiration, until fully used.
This is the mechanical foundation behind tax-loss harvesting — deliberately realizing losses to offset gains elsewhere in your portfolio. See our tax-loss harvesting guide for the full strategy, including how the wash sale rule limits repurchasing the same security too soon after harvesting a loss.
Special rates — collectibles and QSBS
A few categories of assets don't follow the standard 0%/15%/20% long-term structure:
- Collectibles (art, antiques, precious metals, rare coins): Long-term gains are capped at a maximum 28% rate, regardless of your income level — higher than the standard top long-term rate of 20%. Short-term gains on collectibles are still taxed as ordinary income.
- Qualified Small Business Stock (QSBS): Under specific holding-period and eligibility requirements (Section 1202), a portion of gain on qualifying small business stock can potentially be excluded from tax entirely. QSBS does not follow the standard 0%/15%/20% long-term structure, and treatment of any taxable remainder is more complex than a simple flat rate — this is a genuinely intricate area of the tax code. Consult a tax professional if this applies to your situation.
- Unrecaptured Section 1250 gain (real estate depreciation recapture): Capped at 25%, relevant primarily for real estate investors, not typical stock investors.
Calculate your exact tax on a sale
Use the capital gains tax calculator to plug in your income and gain and see your exact federal tax, including NIIT if applicable.
Try the capital gains tax calculatorFrequently asked questions
Do state taxes apply on top of federal capital gains tax?
In most states, yes — most states tax capital gains as ordinary income, with no separate preferential rate the way federal law provides. Combined federal and state top rates can exceed 50% in high-tax states — California's top marginal rate is 13.3%, and New York plus New York City combined can approach 11.9%. A handful of states (Texas, Florida, Nevada, Washington, and others) have no state income tax at all, meaning only federal capital gains tax applies. Check your specific state's treatment, since rules vary significantly.
Do qualified dividends get the same treatment as long-term capital gains?
Yes. Qualified dividends — dividends from US corporations and certain qualifying foreign corporations, held for more than 60 days during the 121-day period surrounding the ex-dividend date — are taxed at the same preferential 0%/15%/20% long-term capital gains rates, not as ordinary income. Non-qualified (ordinary) dividends don't get this treatment and are taxed as ordinary income instead.
How do capital gains affect Social Security taxation?
Capital gains count toward your "combined income" for Social Security taxation purposes — the calculation that determines what percentage of your Social Security benefit is taxable. A large capital gain in a year you're also receiving Social Security can push more of your benefit into taxable territory, even though the gain itself is taxed at preferential capital gains rates. This interaction is easy to overlook and worth modeling before realizing a large gain while collecting benefits.
Can I avoid capital gains tax entirely by not selling?
You can defer it indefinitely by holding, since only realized gains are taxed. One notable feature of current tax law: if you hold an appreciated asset until death, your heirs generally receive a "step-up in basis" to the asset's value at your death — potentially eliminating the built-up capital gain entirely for tax purposes. This is a significant estate planning consideration, though it shouldn't be the sole driver of investment decisions during your lifetime.
Does this apply to cryptocurrency the same way?
Yes — the IRS treats cryptocurrency as property, and the same short-term versus long-term framework and rates described in this guide apply to crypto gains. The mechanics of tracking cost basis differ somewhat for crypto (see our cost basis guide for the wallet-by-wallet tracking rules that took effect in 2025), but once a taxable gain is calculated, the same capital gains rate structure applies.
This article is for informational and educational purposes only and does not constitute tax advice. Figures cited reflect 2026 federal rates per IRS Revenue Procedure 2025-32 and are subject to change. State tax figures are illustrative and may not reflect current law. This guide does not cover every special situation (QSBS, Section 1250 recapture, state-specific rules) in full detail. Consult a qualified tax professional for guidance on your specific situation.