The Complete Capital Gains Tax Calculator: Federal, State, NIIT & Tax-Loss Harvesting Explained

Why Most Capital Gains Calculators Leave You Shortchanged

When I first started tracking my taxable investment gains, I used the first free capital gains tax calculator I found online. It showed me a clean number: $3,200 owed. Confident, I filed my return. Two months later, a letter from the IRS arrived with an additional $1,100 charge—plus interest. That calculator had ignored the Net Investment Income Tax (NIIT) and my state’s capital gains tax. It also didn’t factor in the losses I could have harvested from a wrecked crypto position. I learned the hard way: to get a real answer, you need a capital gains tax calculator that does more than multiply gains by a flat rate.

This article gives you that. It’s built from the ground up to cover everything most calculators miss: state-level rates, the 3.8% NIIT surcharge, tax-loss harvesting strategies, the step-up in basis for inherited assets, special rules for crypto and collectibles, and the primary residence exclusion. By the end, you’ll have a multi-layered framework you can apply to your own situation—and a checklist to avoid the same mistake I made.

The Federal Capital Gains Tax Bracket (2025–2026)

Before layering on state and NIIT, you need your baseline federal rate. The IRS separates gains into short-term (held one year or less) and long-term (held more than one year). Short-term gains are taxed as ordinary income—same as your job wages. Long-term gains enjoy preferential rates of 0%, 15%, or 20%, depending on your taxable income.

For 2025, the long-term capital gains brackets are:

  • 0% rate: single filers with taxable income up to $47,025; married filing jointly up to $94,050; head of household up to $63,000.
  • 15% rate: single $47,026–$518,900; married joint $94,051–$583,750; head of household $63,001–$551,350.
  • 20% rate: single over $518,900; married joint over $583,750; head of household over $551,350.

These thresholds are inflation-adjusted and change each year. For up-to-date numbers, check the IRS Publication 544 or the IRS official release for tax year 2025.

Most people don’t realize that the 0% bracket can be a powerful planning tool. If your taxable income is below that threshold, you can sell appreciated assets and pay nothing in federal capital gains tax. But watch out—adding gains can push you into the 15% bracket, reducing the benefit of harvesting gains in low-income years.

The Short-Term Trap

If you sell an asset before holding it for a full year, any profit is taxed at your ordinary income rate—which can be as high as 37% (plus state and NIIT). I once made the mistake of flipping a volatile tech stock after 11 months for a quick 30% gain. The federal tax on that gain? 32% (my marginal rate) plus 3.8% NIIT plus 4.95% state. Over 40% gone. Waiting one more month would have cut the federal rate to 15%. Timing matters more than most traders realize.

Layer 2: The Net Investment Income Tax (NIIT) – The 3.8% Surcharge Nobody Tells You About

Here’s the thing nobody tells you about capital gains calculators: the Net Investment Income Tax (NIIT) adds an extra 3.8% on top of your federal rate—but only if your modified adjusted gross income (MAGI) exceeds certain thresholds. These thresholds are not inflation-adjusted: $200,000 for single filers, $250,000 for married filing jointly, $125,000 for married filing separately.

So if you’re single and have MAGI of $210,000 with $50,000 in long-term gains, your federal rate is 15% on most of those gains, but the NIIT also hits: 3.8% on the lesser of your net investment income or the amount by which your MAGI exceeds $200,000. In this example, that’s 3.8% on $10,000, or $380 extra.

Most calculators skip this because they don’t ask for MAGI. But ignoring NIIT can understate your tax by thousands. The IRS Topic 559 explains the NIIT in detail. For a practical calculator, you need to input your total income, not just the gain.

Layer 3: State-Level Capital Gains Taxes – The Biggest Omission

When you search for a capital gains tax calculator, most results show only federal rates. But your state probably taxes capital gains as ordinary income, with a few exceptions. Nine states have no income tax (Alaska, Florida, Nevada, New Hampshire, South Dakota, Tennessee, Texas, Washington, Wyoming). New Hampshire taxes interest and dividends only. The rest impose rates ranging from 2.5% (North Dakota) to 13.3% (California top bracket).

A 13.3% state tax plus 20% federal plus 3.8% NIIT equals a combined top rate of 37.1%. That’s nearly the same as ordinary income. If you live in California and have a high-income year, your capital gains tax calculator must include state tax to be accurate.

But here’s a nuance: some states conform to federal long-term/short-term definitions, but not all. For example, Alabama and Pennsylvania treat all capital gains as ordinary income regardless of holding period. Others, like New Mexico, allow a deduction for a portion of long-term gains. I recommend checking your state’s department of revenue website directly—for California, that’s the Franchise Tax Board.

How to Estimate Your Combined Rate

Here’s a quick decision matrix: start with your federal rate (0%, 15%, or 20%), then add 3.8% if you’re over the NIIT threshold (and your gains are investment income), then add your state’s top marginal rate for your income level. But be careful—states often have different brackets and deductions. The simplest way is to use a state-specific tax calculator alongside the federal one. I’ll include a checklist at the end to walk you through it.

Layer 4: Tax-Loss Harvesting – Turning Losses Into Gains (Legally)

Most people don’t realize you can use investment losses to directly offset gains, reducing your tax bill. Tax-loss harvesting involves selling assets at a loss to realize the loss, then using that loss to offset realized gains—or up to $3,000 of ordinary income per year (the excess carries forward indefinitely).

I’ve been doing this for a decade. The year I started, I had a $15,000 gain from selling a rental property and a $12,000 loss in a mutual fund I’d held for two years. Selling the fund allowed me to offset the full gain, paying tax only on the remaining $3,000. Without harvesting, I would have owed 15% federal + 3.8% NIIT + 4.95% state = 23.75% on $15,000, or roughly $3,562. Instead, I paid about $713. That’s a real difference.

But watch out for the wash-sale rule. You cannot claim the loss if you buy the same or substantially identical security within 30 days before or after the sale. This catches many new investors who sell a stock at a loss and immediately repurchase it. The IRS disallows the loss. For cryptocurrencies, the wash-sale rule does not currently apply (as of 2025), but the IRS has signaled potential changes—see IRS Revenue Ruling 2024-14 for the latest guidance.

A capital gains tax calculator that doesn’t include loss carryforwards is giving you an incomplete picture. Always input your total net realized losses from previous years and current year losses before computing the final tax.

Layer 5: Special Assets – Crypto, Collectibles, and Inherited Property

Crypto Gains – Different Rules, Higher Rates

Cryptocurrency is treated as property by the IRS. Short-term gains (held ≤1 year) are ordinary income. Long-term gains (held >1 year) are taxed at the same long-term rates above—except for certain collectibles. Wait, crypto is not a collectible for tax purposes, despite what some think. The IRS clarified in Publication 544 that virtual currency is property, not collectible. However, because crypto is volatile, you might have large gains in a short period. Also, you must track the cost basis of each unit separately—a challenge if you’ve made many trades. Most people don’t realize that using the wrong cost-basis method (e.g., FIFO vs. specific identification) can dramatically change your tax.

For collectors’ items—art, antiques, precious metals, stamps, coins—the long-term capital gains rate is a flat 28% (plus NIIT and state). So if you sell a rare coin held for two years, you’re paying at least 28% federal, not 15% or 20%. Most calculators don’t distinguish this.

Inherited Assets – Step-Up in Basis

When you inherit an asset, the tax basis is stepped up to its fair market value on the date of death (or the alternate valuation date). That means you can sell the inherited asset immediately and owe little to no capital gains tax. This is a huge tax break. For example, if your grandmother bought stock for $10,000 and it’s worth $100,000 when she dies, your basis becomes $100,000. Sell it for $100,000, and you pay $0 in capital gains tax.

But there’s a common misconception: the step-up applies to all assets, including real estate, but not to retirement accounts (IRAs, 401(k)s) which get different treatment. Also, if you live in a community property state (California, Texas, etc.), both halves of the property receive a step-up at the first spouse’s death. That’s a valuable twist many planners exploit.

Primary Residence Exclusion – The $250k/$500k Rule

If you sell your home, you may exclude up to $250,000 of gain (single) or $500,000 (married filing jointly) from your income, provided you’ve owned and used the home as your main residence for at least two of the five years before the sale. This exclusion can be used once every two years.

Most calculators ignore this because they focus on investment assets. But if you’re selling a primary residence, you need to subtract the excluded amount before applying tax rates. I’ve seen people panic over a paper gain of $300,000, only to realize they owe zero because their filing status and ownership period qualify.

The Complete Capital Gains Tax Calculator: A Step-by-Step Framework

Instead of relying on a single online tool that misses half the puzzle, here’s a reliable, multi-layer process you can follow. I call it the 5-Layer Gain Estimate (5LGE).

  1. Determine your net realized capital gains and losses. Gather all sales of investments, real estate, crypto, and other assets. Calculate gain/loss per sale (selling price minus cost basis). Sum short-term and long-term separately. Include any carryover losses from prior years.
  2. Apply the primary residence exclusion (if applicable). For your home sale, subtract up to $250k/$500k from the gain. Only the remainder is taxable.
  3. Compute federal tax on remaining gains. Short-term gains go on your ordinary income tax bracket. Long-term gains go into the 0%/15%/20% brackets using your taxable income (including all other income minus deductions). Add NIIT: if your MAGI exceeds the threshold, add 3.8% on the lesser of net investment income or the excess.
  4. Add state capital gains tax. Look up your state’s tax rate for your income level. Some states allow deductions for long-term gains; factor those in. For states without income tax, skip this.
  5. Total your effective tax rate. Divide total tax owed by total net gain to see your true effective rate. This number often surprises people—it’s rarely just 15%.

I’ve put together a checklist you can use to run your own numbers. Print it out and keep it with your tax documents.

Checklist for Using the 5LGE Framework

  • ☐ List all asset sales with holding periods (short-term vs long-term).
  • ☐ Calculate cost basis (include commissions, fees, improvements for real estate).
  • ☐ Apply primary residence exclusion if home sale: owned and used 2 of 5 years.
  • ☐ Calculate net short-term and long-term gains/losses.
  • ☐ Include any capital loss carryforward from Form Schedule D.
  • ☐ Determine your ordinary taxable income (wages, business income, etc.) and filing status.
  • ☐ Estimate federal long-term capital gains bracket using IRS tables for the tax year.
  • ☐ Compute NIIT: if MAGI > threshold (single $200k, joint $250k), add 3.8% of the lower of net investment income or excess.
  • ☐ Look up state tax: use your state’s tax rate or a state-specific calculator.
  • ☐ Sum federal, NIIT, state taxes. Divide by total net gain to find effective rate.

For quick reference, here’s a comparison table of how different calculators handle these layers:

Feature Basic Free Calculator NerdWallet TurboTax Blog This Article’s Framework
Federal long-term/short-term Yes Yes Yes Yes
NIIT (3.8%) No No No Yes
State tax rates No No No Yes
Tax-loss harvesting No No Partial (mentions losses) Yes, with wash-sale rule
Inherited asset step-up No No No Yes
Crypto/collectibles rates No No No Yes
Primary residence exclusion No Hints only No Yes

Common Pitfalls and How to Avoid Them

Even with a robust framework, mistakes happen. Here are three I’ve seen—and made—most often.

1. Forgetting to adjust cost basis for reinvested dividends. If you hold mutual funds or ETFs, dividends reinvested into additional shares increase your cost basis. Many investors only track initial purchase price. Over years, your basis can be much higher than you think, reducing your gain. Always use your brokerage’s adjusted cost basis—they are required to report it to the IRS.

2. Ignoring the AMT (Alternative Minimum Tax) for incentive stock options (ISOs). While not directly a capital gains tax, exercising ISOs and selling the shares can trigger AMT. This is complex; consider using a professional tax preparer if you exercise ISOs.

3. Assuming a capital gains tax calculator that doesn’t ask for your adjusted gross income is fine. It’s not. Without AGI, you cannot compute NIIT, nor can you determine your state bracket accurately (most states base tax on AGI with modifications). The calculator I built for my own use asks for filing status, total income, deductions, and all gains/losses. It’s less convenient but more accurate.

When to Use a Professional vs. DIY

I advocate for DIY for basic situations—a few stock trades, a home sale, maybe some crypto. Use the framework above and a reputable tax software (e.g., TurboTax, TaxSlayer) that handles capital gains. But seek professional help if:

  • You have assets in multiple states (e.g., you live in one state, sold property in another).
  • You have carried interest or partnership interests.
  • You’re dealing with cryptocurrency with thousands of transactions—specialized software like Koinly or CoinTracker can help.
  • You inherited assets from an estate with complex valuation issues.
  • You’re a non-US resident selling US property—withholding rules differ.

Final Thoughts: Building Your Own Complete Calculator

A capital gains tax calculator is only as good as the data you feed it and the variables it considers. The free tools online are fine for rough estimates, but they can miss tens of thousands in tax liability because they omit state rates, NIIT, or loss harvesting. By using the 5-layer framework above, you can build a custom spreadsheet or adapt it to your favorite tax software.

Start with a simple Schedule D and Form 8949 to report sales. Then add state adjustments. Finally, compute NIIT using Form 8960. It takes an hour, but it’s the most reliable method.

I still remember that $1,100 surprise. It taught me that when money is on the line, you don’t want shortcuts. You want a capital gains tax calculator that treats every layer seriously. Now you have one.

Leave a Reply

Your email address will not be published. Required fields are marked *