Capital Gains Tax Calculator

Enter your purchase price, sale price, and holding period to see the exact federal tax on your gain — broken down by bracket, including the 3.8% NII surtax where applicable. Short-term and long-term rates are handled separately.

Last updated: March 15, 2026

Advertisement

Investment Details

$
$
$

Capital improvements, broker fees, or other additions to basis

$

W-2 wages, business income, etc. (excluding this gain)

Total Federal Tax on Gain

Federal Rate

0%

NII Surtax (3.8%)

$0

Effective Rate

0%

Net Proceeds

$0

Gain Summary

Sale Price $0
Cost Basis (Purchase + Improvements) $0
Capital Gain $0
Holding Period Long-term

Bracket Breakdown

Detailed Tax Breakdown
Bracket Rate Taxable Amount Tax
Advertisement

Short-Term vs. Long-Term: The Rate Gap Is Larger Than You Think

Selling an asset held 11 months versus 13 months can mean the difference between a 24% marginal rate and a 15% rate on the same gain. For a single filer with $175,000 in W-2 income and a $75,000 gain, the short-term tax (ordinary rates stacked on top of existing income) comes to roughly $19,800. Hold that same asset two more months past the one-year mark, and the long-term tax drops to about $11,250 — a $8,550 difference from 60 days of patience.

The stacking mechanic matters. Short-term gains sit on top of your ordinary income and get taxed in whatever bracket that lands. A $75,000 short-term gain on top of $175,000 in income pushes your total to $250,000, which means a chunk hits the 32% bracket for single filers. Long-term gains use a separate, more favorable rate schedule: 0% up to $47,025 in taxable income (2025 thresholds, single), 15% from there to $518,900, and 20% above that. Your ordinary income determines where your gains start on this scale, but the rates themselves are much lower.

The 3.8% NII Surtax: Thresholds That Haven't Moved Since 2013

The Net Investment Income Tax was enacted as part of the Affordable Care Act with thresholds of $200,000 (single) and $250,000 (married filing jointly). Unlike tax brackets, these thresholds are not indexed to inflation. In 2013, $250,000 in household income was solidly upper-middle. By March 2026, that same number catches dual-income couples in high-cost metros who wouldn't consider themselves wealthy.

The surtax applies to the lesser of your net investment income or the amount your MAGI exceeds the threshold. A married couple earning $280,000 in salary who realizes a $120,000 long-term gain has MAGI of $400,000 — exceeding the $250,000 threshold by $150,000. The NIIT is 3.8% on the lesser of $120,000 (the gain) or $150,000 (the excess), resulting in $4,560 in additional tax. This effectively turns a 15% long-term rate into 18.8%, or a 20% rate into 23.8%.

Strategic Timing Around the NII Threshold

If your base income fluctuates year to year — common with bonuses, RSU vesting, or self-employment — timing asset sales for lower-income years can avoid or reduce the NIIT. A single filer with $190,000 in W-2 income is $10,000 below the $200,000 threshold. Realizing up to $10,000 in gains that year avoids the surtax entirely. Realize $50,000 instead, and the 3.8% hits $40,000 of the gain — $1,520 in additional tax.

Tax-Loss Harvesting: Offset Mechanics and the $3,000 Rule

Losses offset gains in a specific order. Short-term losses first offset short-term gains, and long-term losses first offset long-term gains. Net remaining losses of either type then offset the other. This ordering matters: a $20,000 short-term loss is more valuable if you also have $20,000 in short-term gains (taxed at up to 37%) than if you only have long-term gains (taxed at up to 20%). The loss saves you up to $7,400 in the first case versus $4,000 in the second.

When net losses exceed net gains for the year, you can deduct up to $3,000 against ordinary income ($1,500 if married filing separately). Unused losses carry forward indefinitely. A $50,000 realized loss in a year with no gains takes 16+ years to fully utilize at $3,000/year — unless you generate offsetting gains in future years. This asymmetry means large harvested losses are most valuable when you have gains to offset them against, not as standalone ordinary income deductions.

Concentrated Stock and RSU Positions

Employees with large RSU or stock option positions face a specific version of this problem. RSU shares vest as ordinary income at the market price on the vesting date — that price becomes your cost basis. If the stock drops after vesting, selling locks in a capital loss that offsets other gains. If the stock rises, you have a gain taxed at capital gains rates (long-term if held more than one year from vesting). Diversifying a $500,000 concentrated position over three tax years instead of one can keep each year's gain in lower brackets and potentially below NII thresholds.

Advertisement

Tax Software That Handles Capital Gains Automatically

TurboTax imports your 1099-B directly, applies wash sale adjustments, and calculates short-term vs. long-term rates across all your brokerage accounts.

Start Filing Free

PennyCalc may earn a commission if you sign up through this link. Our calculator math is independent of this partnership.

Related Calculators

Frequently Asked Questions

How does the wash sale rule affect capital gains tax?
The wash sale rule disallows a tax loss if you buy a substantially identical security within 30 days before or after selling at a loss. If you sell 100 shares of AAPL at a $5,000 loss on March 10 and repurchase AAPL on March 25, the $5,000 loss is disallowed — it gets added to your cost basis in the replacement shares instead. The rule applies across all your accounts (brokerage, IRA, spouse's accounts). It does not apply to gains, only losses. Selling at a gain and rebuying immediately is fine.
What cost basis methods can I use, and how do they change my tax?
The IRS allows several methods: FIFO (first in, first out — default), specific identification (you choose which lots to sell), and average cost (mutual funds and ETFs only). Specific identification gives the most control. If you bought 100 shares at $50 in 2020 and 100 shares at $120 in 2024, selling 100 shares at $130 yields a $10/share gain using the 2024 lot (short-term) versus an $80/share gain using the 2020 lot (long-term at preferential rates). Choosing high-cost lots minimizes taxable gain; choosing long-held lots gets the lower rate. Your broker must be notified of your method choice before the trade settles.
Who pays the 3.8% Net Investment Income Tax (NIIT) surtax?
The NIIT applies to the lesser of your net investment income or the amount your modified adjusted gross income (MAGI) exceeds: $200,000 for single filers, $250,000 for married filing jointly, or $200,000 for head of household. Net investment income includes capital gains, dividends, interest, rental income, and royalties. If you're married filing jointly with $280,000 in W-2 income and a $75,000 long-term gain, your MAGI is $355,000 — exceeding the threshold by $105,000. The NIIT is 3.8% on the lesser of $75,000 (the gain) or $105,000 (the excess), so $75,000 x 3.8% = $2,850.
How does tax-loss harvesting reduce my capital gains tax?
Tax-loss harvesting means selling investments at a loss to offset gains realized elsewhere. If you have $40,000 in long-term gains and $15,000 in losses from another position, you net them to $25,000 in taxable gains. Losses offset short-term gains first (taxed at higher ordinary rates), then long-term gains. If net losses exceed gains, you can deduct up to $3,000 per year against ordinary income, carrying forward the remainder indefinitely. Timing matters: harvest losses in the same calendar year as your gains. Watch the wash sale rule — replace sold positions with non-identical alternatives to keep market exposure.
Can I defer capital gains tax using a 1031 exchange?
Section 1031 exchanges allow deferral of capital gains tax on real property held for investment or business use — not stocks, bonds, or personal residences. You must identify a replacement property within 45 days of selling and close within 180 days. A qualified intermediary must hold the proceeds; you cannot touch the funds. The replacement property must be of equal or greater value to defer the entire gain. If you sell a rental property for $650,000 with a $200,000 gain, exchanging into a $700,000 property defers the full $200,000 gain. Partial exchanges (trading down in value) trigger tax on the difference.

This calculator is for educational purposes. Consult a financial professional for advice specific to your situation.

Advertisement