Capital Gains Tax Calculator — 2024 Federal & State

Calculate federal and state capital gains tax on investments using 2024 LTCG brackets, NIIT (IRC § 1411), and all 50 states. Includes tax-loss harvesting scenario and holding period analysis.

2024 rates per IRS Rev. Proc. 2023-34 and IRC § 1411 (NIIT). State rates are approximations.
Tax Disclaimer: This calculator provides estimates only. It does not account for depreciation recapture, collectibles rates, installment sales, 1031 exchanges, primary residence exclusions, or other adjustments. Consult a CPA or tax attorney for your specific situation. See IRS Topic 409 and Publication 550.

Determines LTCG rate tier and NIIT exposure

Losses you can offset against this gain

What Is the Capital Gains Tax Calculator — 2024 Federal & State?

Capital gains tax depends on two things: how long you held the asset and your total income. Assets held more than one year qualify for preferential long-term rates (0%, 15%, or 20%). Short-term gains are taxed as ordinary income — potentially at rates up to 37%.

  • Holding period matters enormously — Selling one day before the one-year mark converts a 15% or 20% long-term gain into a gain taxed at your top marginal rate (up to 37%). The difference on a $100,000 gain at a 32% bracket is $17,000 in extra tax.
  • NIIT (Net Investment Income Tax) — An additional 3.8% applies to investment income for high earners (single: MAGI > $200k; MFJ: MAGI > $250k). Effective long-term rate for high earners can be 23.8% (20% + 3.8%).
  • State capital gains tax — Most states tax capital gains as ordinary income. California applies its top rate (13.3%) to all gains regardless of holding period. A few states have no income tax at all.
  • Tax-loss harvesting — Capital losses offset capital gains dollar for dollar. Up to $3,000 of net losses can be deducted against ordinary income per year; remainder carries forward indefinitely.

Formula

Capital Gain

Gain = Sale Proceeds − Cost Basis − Selling Expenses

Long-Term Capital Gains Tax (held > 1 year)

LTCG Tax = Gain × LTCG Rate (0%, 15%, or 20%)

Net Investment Income Tax (NIIT) — IRC § 1411

NIIT = max(0, min(Gain, MAGI − Threshold)) × 3.8%

Short-Term Capital Gains

STCG = Gain taxed as ordinary income at marginal bracket rate

2024 LTCG RateSingleMarried Filing JointlyHead of Household
0%$0 – $47,025$0 – $94,050$0 – $63,000
15%$47,026 – $518,900$94,051 – $583,750$63,001 – $551,350
20%Over $518,900Over $583,750Over $551,350
NIIT 3.8%MAGI over $200,000MAGI over $250,000MAGI over $200,000

How to Use

  1. 1
    Enter purchase price: Your cost basis — original purchase price plus any commissions, fees, or improvements (for real estate).
  2. 2
    Enter sale price: Gross sale proceeds. Subtract selling costs (broker commissions) to get net proceeds.
  3. 3
    Select holding period: Short-term = held 1 year or less. Long-term = held more than 1 year. The calendar matters — one extra day can save thousands.
  4. 4
    Enter your income: Your ordinary income for the year (W-2, self-employment, etc.), not including this gain. Used to determine which LTCG bracket applies.
  5. 5
    Choose filing status and state: LTCG thresholds and NIIT triggers vary by filing status. State taxes vary widely.
  6. 6
    Add capital losses: Enter any realized capital losses to offset the gain. Losses harvest first against gains, then up to $3,000 against ordinary income.

Example Calculation

$50,000 basis → $120,000 sale, held 2 years, $130,000 income, single, California

Capital gain: $120,000 − $50,000 = $70,000 LTCG

Total income with gain: $130,000 + $70,000 = $200,000

Federal LTCG rate: 15% (income $47,026–$518,900)

Federal LTCG tax: $70,000 × 15% = $10,500

NIIT (MAGI at $200k): $0 (at exact threshold)

CA state tax (9.3%): $70,000 × 9.3% = $6,510

Total tax on gain: ~$17,010 (24.3% effective rate)

If held < 1 yr (22% fed bracket + 9.3% CA):

Federal: $70,000 × 22% = $15,400 | Total: ~$21,910 (+$4,900 more)

One year makes $4,900 difference

In this example, holding the asset just past the one-year mark saves nearly $5,000 in federal tax alone. In higher brackets (32%+ federal + 13.3% CA top rate), the difference between short-term and long-term can exceed $15,000–$20,000 on the same $70,000 gain.

Understanding Capital Gains Tax — 2024 Federal & State

The One-Year Cliff

The distinction between short-term and long-term capital gains is binary — one day determines which rate applies. For investors with large unrealized gains, knowing the exact one-year anniversary of each lot is essential tax planning. Most brokerage platforms show your holding period and mark lots as short-term or long-term. Specific lot identification lets you choose which shares to sell when you have multiple purchases of the same asset.

Qualified Dividends vs Capital Gains

Qualified dividends (from domestic corporations and qualifying foreign corporations, held at least 60 days) are taxed at the same long-term capital gains rates — 0%, 15%, or 20%. Ordinary (non-qualified) dividends are taxed as ordinary income. The distinction matters significantly for income investors: a dividend from a US stock held long enough is taxed at a far lower rate than interest income.

Tax-Loss Harvesting Rules

  • Capital losses offset capital gains dollar for dollar — short-term losses against short-term gains first, long-term against long-term.
  • Net losses up to $3,000/year can offset ordinary income. Unused losses carry forward indefinitely.
  • Wash-sale rule (IRC § 1091): you cannot repurchase substantially identical securities within 30 days before or after the sale — doing so disallows the loss.
  • ETFs from the same asset class but different indexes (e.g., VTI → SCHB) are generally not considered substantially identical, allowing immediate reinvestment.

Primary Residence Exclusion

Under IRC § 121, a single taxpayer can exclude up to $250,000 ($500,000 MFJ) of capital gains on the sale of a primary residence — provided they owned and used the home as their primary residence for at least 2 of the last 5 years. This exclusion does not apply to rental property or investment real estate.

Legal Disclaimer

Capital gains tax rules are complex and change with legislation. This calculator uses 2024 IRS parameters (Rev. Proc. 2023-34) and simplified state effective rates. Actual tax depends on your complete return, including deductions, credits, alternative minimum tax (AMT), state-specific treatment, and entity type. Consult a qualified tax professional. See IRS Topic 409 — Capital Gains and Losses and IRS Publication 550.

Frequently Asked Questions

What is the Net Investment Income Tax (NIIT)?

The NIIT is a 3.8% surtax on investment income for high earners, created by the Affordable Care Act (IRC § 1411). It applies on top of regular capital gains tax.

  • Single / Head of Household: applies when MAGI exceeds $200,000.
  • Married Filing Jointly: applies when MAGI exceeds $250,000.
  • Applies to: capital gains, dividends, interest, rental income, and passive business income.
  • Effective top rate: 23.8% for long-term gains (20% + 3.8%) or 40.8% for short-term (37% + 3.8%).

The NIIT threshold is not inflation-adjusted — more taxpayers are caught over time as incomes rise.

How does cost basis work for inherited assets?

Inherited assets receive a stepped-up cost basis — the fair market value on the date of death — which wipes out all unrealized gains accrued during the decedent's lifetime.

  • Stock inherited at $100,000 (original basis $20,000): your basis is $100,000 — a $80,000 gain is eliminated.
  • Holding period: inherited assets always qualify for long-term rates regardless of how long you hold them.
  • Alternate valuation date: the estate may use the value 6 months after death instead if it lowers estate taxes.
  • Gifted assets: do NOT get a step-up — you inherit the donor's original basis (carryover basis).

The step-up in basis is one of the most valuable estate planning tools available; assets with large unrealized gains are often held until death specifically to avoid capital gains tax.

Do capital gains affect my tax bracket for ordinary income?

Long-term capital gains are stacked on top of ordinary income to determine which LTCG rate applies — but they do not push your ordinary income into a higher federal bracket.

  • Ordinary income ($50k) + LTCG ($40k) = $90k combined for determining LTCG rate.
  • The ordinary income ($50k) is still taxed at the same marginal brackets as without the gain.
  • Short-term gains ARE ordinary income — they do push you into higher ordinary brackets.
  • The stacking effect can push LTCG from the 0% rate into the 15% bracket if combined income crosses $47,025 (single, 2024).

This stacking mechanic is a reason to realize large long-term gains in lower-income years when possible.

What is the wash-sale rule?

Under IRC § 1091, selling at a loss and repurchasing a "substantially identical" security within 30 days (before or after) disallows the loss for tax purposes.

  • 30-day window: applies 30 days BEFORE the sale and 30 days AFTER — a 61-day total window.
  • Disallowed loss: the loss is deferred and added to the basis of the replacement security, not permanently lost.
  • Substantially identical: same stock or fund; options on the same stock; similar ETFs from the same provider.
  • NOT substantially identical: ETFs tracking different indexes (e.g., VTI → SCHB) allow immediate reinvestment.

Crypto assets are currently NOT subject to the wash-sale rule (as of 2024), though legislative proposals to extend it to crypto have been introduced multiple times.

Are capital gains taxed differently in each state?

Yes — state capital gains tax treatment varies widely and can significantly impact your total effective rate.

  • No income tax states (9): Alaska, Florida, Nevada, New Hampshire (wages), SD, Tennessee, Texas, Washington, Wyoming — no state capital gains tax.
  • California: taxes all capital gains as ordinary income at rates up to 13.3% — no preferential long-term rate.
  • Most other states: tax capital gains as ordinary income at the state marginal rate (3–10%).
  • A handful of states (AZ, AR, HI, ND, SC, WI) offer partial exclusions or lower rates for long-term gains.

For large realized gains, the state rate can equal or exceed the federal rate — it's a significant factor in timing decisions.

Related Calculators