Capital Gains Tax Calculator

Calculate federal capital gains tax on your investment profits. Enter your purchase and sale prices, select your filing status and holding period, and instantly see your estimated tax liability, effective rate, and after-tax proceeds with a short-term vs long-term comparison.

Calculate Capital Gains Tax

Enter your investment details to estimate federal capital gains tax for 2025.

What you paid for the asset (cost basis)

$

What you sold (or plan to sell) the asset for

$

Your other taxable income (excluding this gain) — determines which bracket applies

$

Losses from other investments to offset this gain

$

Frequently Asked Questions About Capital Gains Tax

What is capital gains tax?

Capital gains tax is a tax levied on the profit you make from selling a capital asset such as stocks, bonds, real estate, or other investments. The tax is assessed on the difference between the sale price and your original purchase price (cost basis). Capital gains are only realized and taxed when you sell an asset at a profit. If you hold an asset without selling, any increase in value is considered an unrealized gain and is not subject to tax. The tax rate depends on how long you held the asset and your taxable income level.

What is the difference between short-term and long-term capital gains?

The key difference is the holding period. Short-term capital gains apply to assets held for one year or less before selling, and are taxed at your ordinary income tax rate (10% to 37% depending on your income bracket). Long-term capital gains apply to assets held for more than one year, and benefit from preferential tax rates of 0%, 15%, or 20% depending on your taxable income and filing status. This significant tax advantage is one of the primary reasons financial advisors recommend holding investments for at least one year before selling.

What are the 2025 long-term capital gains tax rates?

For 2025, long-term capital gains are taxed at three rates: 0% for single filers with taxable income up to $48,350 (up to $96,700 for married filing jointly), 15% for single filers with income from $48,350 to $533,400 (from $96,700 to $600,050 for married filing jointly), and 20% for single filers with income above $533,400 (above $600,050 for married filing jointly). Additionally, high-income taxpayers may owe a 3.8% Net Investment Income Tax (NIIT) on top of these rates if their modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married filing jointly.

How do I calculate capital gains?

To calculate capital gains, subtract your cost basis (purchase price plus any associated costs like commissions) from the sale price. For example, if you bought stock for $10,000 and sold it for $15,000, your capital gain is $5,000. You can reduce your capital gain by deducting capital losses from other investments. If your total capital losses exceed your capital gains, you can deduct up to $3,000 of the excess loss against ordinary income per year, carrying forward any remaining losses to future tax years.

Are there any exemptions for capital gains tax?

Yes, several exemptions exist. The most significant is the primary residence exclusion: if you have owned and lived in your home for at least 2 of the last 5 years, you can exclude up to $250,000 in capital gains from the sale ($500,000 for married couples filing jointly). Assets held in tax-advantaged accounts like 401(k)s, IRAs, and Roth IRAs grow tax-free or tax-deferred, meaning capital gains within these accounts are not immediately taxable. Inherited assets receive a stepped-up cost basis to their fair market value at the date of death, potentially eliminating capital gains tax on appreciation during the decedent's lifetime.

How does filing status affect capital gains tax?

Filing status significantly affects capital gains tax because it determines the income thresholds for each tax bracket. For example, the 0% long-term capital gains rate applies up to $48,350 for single filers but up to $96,700 for married filing jointly, effectively doubling the tax-free threshold. Similarly, the NIIT threshold is $200,000 for single filers and head of household, but $250,000 for married filing jointly and only $125,000 for married filing separately. Choosing the right filing status can result in thousands of dollars in tax savings on investment gains.

Can capital losses offset capital gains?

Yes, capital losses can offset capital gains dollar for dollar. First, short-term losses offset short-term gains, and long-term losses offset long-term gains. Any remaining net losses can then offset gains of the other type. If your total capital losses exceed your total capital gains for the year, you can deduct up to $3,000 of net capital losses against your ordinary income ($1,500 if married filing separately). Any losses beyond $3,000 are carried forward indefinitely to future tax years. This strategy, known as tax-loss harvesting, is commonly used to minimize tax liability.

Do I pay state capital gains tax too?

Most states tax capital gains as ordinary income, which means you may owe state tax in addition to federal capital gains tax. State tax rates vary widely: nine states have no income tax (Alaska, Florida, Nevada, New Hampshire, South Dakota, Tennessee, Texas, Washington, and Wyoming), while states like California can tax capital gains at rates up to 13.3%. A few states offer preferential rates for long-term gains or exclude certain types of gains. This calculator estimates federal tax only; consult your state's tax guidelines or a tax professional for your total combined tax liability.

Understanding Capital Gains Tax on Investments

What is Capital Gains Tax?

Capital gains tax is a federal tax levied on the profit realized from the sale of a capital asset. Capital assets include stocks, bonds, mutual funds, exchange-traded funds (ETFs), real estate, precious metals, cryptocurrency, collectibles, and other investments. The tax applies to the difference between what you paid for an asset (your cost basis) and what you received when you sold it.

A capital gain is only "realized" when you actually sell or dispose of an asset. As long as you continue to hold an investment, any increase in its value is considered an "unrealized gain" and is not subject to tax. This distinction is important because it gives investors control over when they recognize taxable gains, forming the basis for many tax planning strategies.

The United States tax code distinguishes between two types of capital gains based on how long you held the asset before selling: short-term and long-term. This holding period determines which tax rates apply and can result in dramatically different tax outcomes. Understanding this distinction is one of the most impactful tax planning decisions an investor can make, potentially saving thousands of dollars annually.

Capital gains tax is separate from ordinary income tax, though short-term gains are taxed at ordinary income rates. The tax applies at the federal level, and most states also impose their own capital gains taxes. This calculator focuses on federal capital gains tax, which is typically the largest component of the total tax liability on investment profits. For a broader view of how your overall income is taxed, see our Salary Calculator, which covers federal income tax brackets in detail.

Short-Term vs Long-Term Capital Gains

The holding period of an asset determines whether a capital gain is classified as short-term or long-term, which in turn determines the applicable tax rate. This is one of the most consequential distinctions in the U.S. tax code for investors.

Short-Term Capital Gains

Short-term capital gains arise from the sale of assets held for one year or less. These gains are taxed at your ordinary income tax rate, which ranges from 10% to 37% depending on your total taxable income and filing status. Essentially, short-term capital gains are treated the same as wages, salary, and other ordinary income for tax purposes. For active traders, day traders, and anyone who frequently buys and sells investments within a one-year window, the short-term rate applies to all profits.

Long-Term Capital Gains

Long-term capital gains arise from the sale of assets held for more than one year. These gains benefit from preferential tax rates that are significantly lower than ordinary income rates. The long-term capital gains tax rates are 0%, 15%, or 20%, depending on your taxable income and filing status. For most taxpayers, the long-term rate is 15%, which is substantially less than their marginal ordinary income tax rate.

The Tax Savings of Long-Term Holding

The difference in tax treatment between short-term and long-term capital gains creates a powerful incentive to hold investments for more than one year. Consider an investor in the 24% ordinary income tax bracket who realizes a $50,000 capital gain. If classified as short-term, the federal tax would be approximately $12,000. If classified as long-term (at the 15% rate), the tax would be $7,500 -- a savings of $4,500 simply by holding the asset for one additional day beyond the one-year mark.

For this reason, tax-efficient investing strategies generally favor holding assets for at least one year before selling. Tax-aware investors will often time their sales to ensure they qualify for long-term treatment, even delaying a sale by a few days or weeks to cross the one-year threshold. This is especially important for large gains where the tax savings can be substantial.

2025 Tax Rate Tables

The following tables show the 2025 federal tax rates for both short-term capital gains (which use ordinary income tax brackets) and long-term capital gains for all filing statuses.

Short-Term Capital Gains Rates (Ordinary Income Brackets) — 2025

Single Filer

Taxable IncomeTax Rate
$0 - $11,92510%
$11,925 - $48,47512%
$48,475 - $103,35022%
$103,350 - $197,30024%
$197,300 - $250,52532%
$250,525 - $626,35035%
Over $626,35037%

Married Filing Jointly

Taxable IncomeTax Rate
$0 - $23,85010%
$23,850 - $96,95012%
$96,950 - $206,70022%
$206,700 - $394,60024%
$394,600 - $501,05032%
$501,050 - $751,60035%
Over $751,60037%

Married Filing Separately

Taxable IncomeTax Rate
$0 - $11,92510%
$11,925 - $48,47512%
$48,475 - $103,35022%
$103,350 - $197,30024%
$197,300 - $250,52532%
$250,525 - $375,80035%
Over $375,80037%

Head of Household

Taxable IncomeTax Rate
$0 - $17,00010%
$17,000 - $64,85012%
$64,850 - $103,35022%
$103,350 - $197,30024%
$197,300 - $250,52532%
$250,525 - $626,35035%
Over $626,35037%

Long-Term Capital Gains Tax Rates — 2025

Single Filer

Taxable IncomeTax Rate
$0 - $48,3500%
$48,350 - $533,40015%
Over $533,40020%

Married Filing Jointly

Taxable IncomeTax Rate
$0 - $96,7000%
$96,700 - $600,05015%
Over $600,05020%

Married Filing Separately

Taxable IncomeTax Rate
$0 - $48,3500%
$48,350 - $300,02515%
Over $300,02520%

Head of Household

Taxable IncomeTax Rate
$0 - $64,7500%
$64,750 - $566,70015%
Over $566,70020%

Note: These income thresholds are based on total taxable income including the capital gain itself. Long-term rates are significantly lower than short-term rates for most taxpayers, making the holding period a critical factor in tax planning.

Net Investment Income Tax (NIIT)

The Net Investment Income Tax (NIIT) is an additional 3.8% surtax on investment income that applies to higher-income taxpayers. Introduced as part of the Affordable Care Act in 2013, the NIIT applies to the lesser of your net investment income or the amount by which your modified adjusted gross income (MAGI) exceeds certain thresholds.

The NIIT thresholds for 2025 are:

  • Single: $200,000
  • Married Filing Jointly: $250,000
  • Married Filing Separately: $125,000
  • Head of Household: $200,000

Unlike the regular income tax brackets, these NIIT thresholds are not indexed for inflation and have remained unchanged since the tax was introduced. This means that more taxpayers become subject to the NIIT each year as incomes rise with inflation.

NIIT Calculation Formula:

NIIT = min(Net Investment Income, MAGI - Threshold) x 3.8%

Example: Single filer, $75,000 income + $150,000 gain = $225,000 MAGI

NIIT = min($150,000, $225,000 - $200,000) x 3.8% = $25,000 x 3.8% = $950

Net investment income includes capital gains, dividends, interest, rental income, royalties, and income from passive activities. It does not include wages, self-employment income, Social Security benefits, or distributions from certain retirement plans. The NIIT effectively raises the maximum long-term capital gains rate from 20% to 23.8% for the highest-income taxpayers.

How to Calculate Capital Gains Tax Step-by-Step

Calculating your capital gains tax involves several steps. Here is a comprehensive walkthrough of the process:

  1. Determine your cost basis: This is the original purchase price of the asset, plus any acquisition costs such as broker commissions, transfer fees, or improvements (for real estate). For stocks, your cost basis is typically the price you paid per share multiplied by the number of shares sold.
  2. Determine the sale price: This is the gross proceeds from the sale, minus any selling costs such as broker commissions or closing costs (for real estate).
  3. Calculate the capital gain or loss: Subtract the cost basis from the sale price. If the result is positive, you have a capital gain. If negative, you have a capital loss.
  4. Apply any capital losses: If you have capital losses from other investments, you can use them to offset your capital gains dollar for dollar.
  5. Determine the holding period: Count the days from the day after you purchased the asset to the day you sold it. If more than one year (366 days or more), the gain is long-term. Otherwise, it is short-term.
  6. Apply the appropriate tax rate: Based on your holding period, filing status, and total taxable income, look up the applicable tax rate from the tables above.
  7. Check for NIIT: If your modified adjusted gross income exceeds the NIIT threshold for your filing status, add 3.8% on the applicable portion of your investment income.

Capital Gains Tax Formula:

Capital Gain = Sale Price - Purchase Price - Capital Losses

Tax = Capital Gain x Applicable Tax Rate + NIIT (if applicable)

Effective Rate = Total Tax / Capital Gain x 100

After-Tax Proceeds = Sale Price - Total Tax

Remember that capital gains tax is calculated on the gain, not on the total sale price. Your cost basis -- the amount you originally invested -- is returned to you tax-free. Only the profit above your cost basis is subject to capital gains tax. This is a common point of confusion for new investors who may initially fear that the entire sale amount is taxable.

Capital Losses and Tax-Loss Harvesting

Capital losses occur when you sell an investment for less than your cost basis. While nobody wants to lose money on an investment, capital losses do provide a valuable tax benefit: they can be used to offset capital gains, reducing your overall tax liability.

The IRS requires that losses first offset gains of the same type: short-term losses offset short-term gains, and long-term losses offset long-term gains. If you have net losses remaining after this matching, they can then offset gains of the other type. If your total capital losses exceed your total capital gains for the year, you can deduct up to $3,000 of the excess against your ordinary income ($1,500 if married filing separately). Any losses beyond the $3,000 annual limit are carried forward indefinitely to future tax years.

Tax-Loss Harvesting

Tax-loss harvesting is a strategy where investors intentionally sell investments at a loss to offset realized capital gains. This is particularly useful at year-end when investors review their portfolios for tax planning purposes. By selling underperforming investments, you can generate losses to offset gains from winners, effectively reducing your net capital gains and the associated tax.

There is an important caveat to tax-loss harvesting: the wash sale rule. The IRS prohibits claiming a loss on a security if you purchase a "substantially identical" security within 30 days before or after the sale. This prevents investors from selling solely for the tax benefit and immediately repurchasing the same investment. To comply with the wash sale rule, you can either wait 31 days before repurchasing the same security, or purchase a similar (but not substantially identical) investment to maintain your portfolio allocation.

When used strategically, tax-loss harvesting can save investors significant amounts in capital gains tax over time. Many financial advisors and robo-advisors offer automated tax-loss harvesting services that monitor portfolios daily for harvesting opportunities. For a deeper look at how investment returns compound over time, check out our Investment Calculator.

Real-World Examples

Example 1: Short-Term Stock Sale

Maria, a single filer with $85,000 in annual taxable income, purchased 200 shares of a tech stock at $50 per share ($10,000 total) in March 2025. Eight months later, she sells all 200 shares at $75 per share ($15,000 total). Since she held the stock for less than one year, this is a short-term capital gain.

Capital Gain = $15,000 - $10,000 = $5,000
Maria's income ($85,000) places the gain in the 22% bracket
Short-term tax = $5,000 x 22% = $1,100
NIIT: Not applicable ($90,000 total income < $200,000 threshold)
Total tax = $1,100
Effective rate = 22.0%
After-tax proceeds = $15,000 - $1,100 = $13,900

If Maria had held the stock for just four more months (more than one year), the gain would qualify as long-term. Her total income of $90,000 would place her in the 15% long-term bracket, resulting in a tax of $750 instead of $1,100 -- a savings of $350 simply by waiting.

Example 2: Long-Term Real Estate Sale

David and Sarah, married filing jointly with $180,000 in combined annual taxable income, purchased a rental property in 2019 for $300,000. In 2025, they sell it for $450,000 after deducting $15,000 in selling costs (real estate commission and closing costs). They held the property for over 6 years, so this is a long-term capital gain. They also have $8,000 in capital losses from selling other investments at a loss.

Adjusted sale price = $450,000 - $15,000 = $435,000
Capital Gain = $435,000 - $300,000 = $135,000
After capital losses = $135,000 - $8,000 = $127,000
Total income = $180,000 + $127,000 = $307,000
Long-term bracket: $96,700 to $600,050 at 15%
Long-term tax = $127,000 x 15% = $19,050
NIIT: $307,000 > $250,000 threshold
NIIT = min($127,000, $307,000 - $250,000) x 3.8%
NIIT = $57,000 x 3.8% = $2,166
Total tax = $19,050 + $2,166 = $21,216
Effective rate = $21,216 / $127,000 = 16.7%
After-tax proceeds = $435,000 - $21,216 = $413,784

Note: This example simplifies real estate taxation. In practice, depreciation recapture (taxed at 25%) would apply to any depreciation previously claimed on the rental property, and state taxes would add to the liability. Depreciation recapture is calculated before applying long-term capital gains rates to the remaining gain.

Example 3: Mixed Portfolio with Gains and Losses

James, a single filer with $120,000 in annual taxable income, has the following investment activity in 2025:

  • Stock A: Bought for $20,000, sold for $35,000 (held 2 years) — long-term gain of $15,000
  • Stock B: Bought for $15,000, sold for $10,000 (held 6 months) — short-term loss of $5,000
  • Stock C: Bought for $8,000, sold for $12,000 (held 3 months) — short-term gain of $4,000

Short-term gains: $4,000 (Stock C)
Short-term losses: $5,000 (Stock B)
Net short-term: -$1,000 (loss)

Long-term gains: $15,000 (Stock A)
Long-term losses: $0
Net long-term: $15,000 (gain)

Net short-term loss offsets long-term gain:
Taxable long-term gain = $15,000 - $1,000 = $14,000
Total income = $120,000 + $14,000 = $134,000
Long-term rate: 15% (within $48,350 - $533,400 bracket)
Long-term tax = $14,000 x 15% = $2,100
NIIT: Not applicable ($134,000 < $200,000)
Total tax on investment activity = $2,100
Effective rate = 15.0%

This example illustrates the value of netting gains and losses. James's short-term loss from Stock B reduced his taxable long-term gain by $1,000, saving him $150 in taxes (at the 15% long-term rate). If he had additional short-term losses, they could further reduce or even eliminate the taxable gain. See our Salary Calculator to understand how ordinary income brackets affect your short-term capital gains rate.

Strategies for Minimizing Capital Gains Tax

While capital gains taxes are an unavoidable part of successful investing, there are several legitimate strategies to minimize your tax liability:

  1. Hold investments for more than one year: The single most effective strategy for most investors. Long-term capital gains rates (0%, 15%, 20%) are significantly lower than short-term rates (10% to 37%). If you are close to the one-year mark, delaying a sale by even a few days can result in substantial tax savings.
  2. Use tax-advantaged accounts: Invest through 401(k)s, IRAs, Roth IRAs, and Health Savings Accounts (HSAs) when possible. In a traditional 401(k) or IRA, capital gains are tax-deferred until withdrawal. In a Roth IRA, qualified withdrawals (including gains) are completely tax-free. HSAs offer triple tax advantages: tax-deductible contributions, tax-free growth, and tax-free withdrawals for qualified medical expenses.
  3. Harvest tax losses: As described above, selling losing investments to offset gains can reduce your overall tax liability. Be mindful of the wash sale rule when implementing this strategy.
  4. Take advantage of the 0% rate: If your taxable income is low enough (under $48,350 for single filers in 2025), you may qualify for the 0% long-term capital gains rate. This is particularly useful for retirees or during years with lower income. You can strategically realize gains in low-income years to lock in the 0% rate.
  5. Gift appreciated assets: Instead of selling appreciated assets yourself, consider gifting them to family members in lower tax brackets. The recipient assumes your cost basis but may pay a lower tax rate on the gain when they sell. Annual gift tax exclusions allow gifts of up to $18,000 per recipient in 2025 without triggering gift tax.
  6. Donate appreciated assets to charity: If you donate appreciated long-term assets directly to a qualified charity, you can deduct the full market value as a charitable contribution while avoiding capital gains tax entirely. This is more tax-efficient than selling the asset and donating the cash proceeds.
  7. Use specific identification for cost basis: When selling shares of a stock or fund you purchased at different times and prices, you can use specific identification to select which shares to sell. By choosing shares with the highest cost basis, you minimize your capital gain and the resulting tax.
  8. Consider Qualified Opportunity Zones: Investing capital gains into a Qualified Opportunity Zone (QOZ) fund can defer and potentially reduce capital gains tax. If you hold the QOZ investment for 10 or more years, any appreciation in the QOZ investment itself may be excluded from tax entirely.
  9. Plan around life changes: Major life events such as retirement, job changes, sabbaticals, or relocating to a state with no income tax can create opportunities to realize gains at lower rates. Plan asset sales during years when your taxable income is expected to be lower.
  10. Use installment sales: For large gains, particularly on real estate, an installment sale allows you to spread the gain over multiple tax years, potentially keeping more of the gain in lower tax brackets. This can also help avoid or reduce the NIIT by keeping annual income below the threshold.

For more information on how compound growth and investment returns work over time, explore our Investment Calculator to project your portfolio growth with different contribution amounts and return rates.

Primary Residence Exclusion ($250k/$500k)

One of the most generous tax provisions for individuals is the primary residence capital gains exclusion under Section 121 of the Internal Revenue Code. This provision allows homeowners to exclude a significant portion of the profit from selling their primary residence from capital gains tax.

The exclusion amounts are:

  • Single filers: Up to $250,000 in capital gains can be excluded from tax
  • Married filing jointly: Up to $500,000 in capital gains can be excluded from tax

To qualify for the exclusion, you must meet two requirements:

  • Ownership test: You must have owned the home for at least 2 of the 5 years preceding the sale
  • Use test: You must have used the home as your primary residence for at least 2 of the 5 years preceding the sale

The 2 years do not need to be consecutive. For example, if you lived in a home for 2 years, rented it out for 2 years, then sold it, you would still qualify because you used it as your primary residence for 2 of the last 5 years. You can use this exclusion once every 2 years.

Primary Residence Exclusion Example:

Purchase price: $350,000 (bought in 2020)

Sale price: $550,000 (sold in 2025)

Capital gain: $550,000 - $350,000 = $200,000

Single filer exclusion: $250,000

Taxable gain: $0 (gain is fully within the exclusion)

Tax owed: $0

If the gain exceeds the exclusion amount, only the excess is subject to capital gains tax. For example, a married couple with a $600,000 gain would exclude $500,000 and pay tax only on the remaining $100,000. The gain would be classified as long-term (assuming they owned the home for more than one year), qualifying for the preferential long-term capital gains rates.

There are partial exclusions available for homeowners who do not meet the full 2-year requirement due to unforeseen circumstances such as a change in employment, health issues, or other qualifying events. The partial exclusion is calculated by prorating the full exclusion amount based on the fraction of the 2-year requirement that was met.

This exclusion makes homeownership one of the most tax-advantaged forms of investment available to individuals. A married couple could potentially realize $500,000 in tax-free capital gains every two years by selling their primary residence, though this strategy is limited by the practical considerations of purchasing, living in, and selling homes.

Important Tax Disclaimer

This guide and the accompanying calculator are provided for educational and informational purposes only. They are not intended to be, and should not be construed as, tax advice. Tax laws are complex and subject to change. Individual circumstances such as state taxes, deductions, credits, alternative minimum tax (AMT), depreciation recapture, and other factors can significantly affect your actual tax liability. Always consult a qualified tax professional, CPA, or tax attorney for advice specific to your situation. The information presented here is based on 2025 federal tax law and may not reflect subsequent legislative changes.