The math behind this calculator (click to expand)
The realized gain is sale_price - cost_basis. If holding period is 365 days or less, the gain is short-term and stacks on top of ordinary taxable income at the regular bracket schedule (10/12/22/24/32/35/37% for 2026). If holding is greater than 365 days, the gain is long-term and uses the separate long-term rate schedule (0/15/20%) with thresholds tied to taxable income.
The 2026 long-term thresholds (single): 0% up to $48,350 of taxable income, 15% from $48,350 to $533,400, 20% above $533,400. Married filing jointly: 0% up to $96,700, 15% from $96,700 to $600,050, 20% above. The position of your ordinary income on this scale determines where the long-term gain starts on the rate schedule.
Net Investment Income Tax (NIIT) is 3.8% on the lesser of (a) net investment income or (b) the amount MAGI exceeds the threshold ($200,000 single, $250,000 MFJ, $200,000 HoH). These thresholds are not inflation-indexed, so they catch more taxpayers each year.
Implementation by Michael.
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.
What might change in the next 24 months
Capital gains rates and thresholds are politically active in a way that ordinary income rates have not been since TCJA. Three specific items to watch. First, the long-term capital gains thresholds are inflation-indexed annually (IRS Rev. Proc. issued each November), so the 0% bracket continues to widen modestly. The 0% rate is meaningfully usable for retirees with no W-2 income and for sabbatical scenarios where ordinary income drops below ~$48,000 single or ~$96,700 married.
Second, the Net Investment Income Tax thresholds are still nominal-dollar from 2013 ($200K single, $250K married) and continue to capture more dual-income households each year as wage growth outpaces the unindexed cap. Worth knowing: there have been multiple legislative proposals to either raise the threshold or extend NIIT to active business income, and the latter scenario would materially change the math for owners of pass-through businesses.
Third, the qualified small business stock (QSBS) Section 1202 exclusion remains at 100% of gain (up to the greater of $10M or 10x basis) for stock acquired after September 28, 2010 and held more than five years. Several Treasury proposals have aimed at narrowing 1202 (lowering the exclusion to 75% or 50%, tightening qualified-trade-or-business definitions); none have passed but it's the single most generous capital gains preference left in the code, and changes would be retroactive only to date of enactment.