Capital Gains Tax Calculator

Calculate your capital gains tax on stocks, crypto, or real estate using current 2024 IRS brackets. Includes NIIT surtax and home-sale exclusion.

Did this calculator help you?

What is Capital Gains Tax Calculator?

A Capital Gains Tax Calculator estimates exactly how much federal tax you'll owe when you sell an investment — stocks, cryptocurrency, mutual funds, or real estate — for a profit, using the current 2024 IRS tax brackets. The tax treatment of a capital gain depends critically on how long you held the asset before selling: short-term gains on assets held one year or less are taxed as ordinary income at your regular marginal rate, while long-term gains on assets held more than one year benefit from preferential federal rates of 0%, 15%, or 20%, based on your total taxable income and filing status. This calculator stacks your gain on top of your other ordinary income to determine precisely which bracket (or brackets) it falls into, applies the 3.8% Net Investment Income Tax surtax when your income exceeds the relevant threshold, and for real estate sales, applies the IRC Section 121 primary-residence exclusion that can eliminate tax on up to $250,000 (or $500,000 for married couples) of gain entirely. Whether you're timing the sale of an appreciated stock position, planning a rental property disposal, cashing out cryptocurrency, or selling your family home, this tool shows your exact tax liability, effective rate, marginal rate, and net after-tax proceeds — entirely in your browser, before you make an irreversible sale decision or file your return.

Steps:

  1. Select your holding period: Long-Term (held more than 1 year) or Short-Term (held 1 year or less) — this determines which tax rates apply.
  2. Enter your sale proceeds, cost basis, and any selling expenses (broker commissions, closing costs).
  3. Enter your other taxable income for the year — this determines which bracket your gain stacks into.
  4. Select your filing status.
  5. If selling a primary residence, check the box and enter how many of the last 5 years you owned and lived in the home to apply the Section 121 exclusion.
  6. Review your taxable gain, tax owed, effective and marginal rates, and net after-tax proceeds.

Formula

Raw Gain = Proceeds − Cost Basis − Selling Expenses Primary Residence Exclusion (if applicable): Exclusion = min(Raw Gain, $250,000 single / $500,000 married filing jointly) Taxable Gain = Raw Gain − Exclusion Short-term: Taxable Gain taxed at ordinary income brackets (10%–37%), stacked on other income Long-term: Taxable Gain taxed at capital gains brackets (0% / 15% / 20%), stacked on other income Net Investment Income Tax (NIIT): If MAGI > threshold ($200,000 single / $250,000 MFJ): NIIT = min(Taxable Gain, MAGI − threshold) × 3.8% Total Tax = Tax on Gain + NIIT Net Proceeds = Proceeds − Selling Expenses − Total Tax

Use Cases

  • Investors deciding whether to sell an appreciated stock now or wait to reach the long-term holding period
  • Real estate sellers estimating their tax bill on an investment property, or checking eligibility for the primary residence exclusion
  • Cryptocurrency investors calculating tax owed on realized crypto gains before filing
  • Anyone doing year-end tax planning who wants to see the exact impact of realizing a gain before December 31st
  • People deciding how much of an investment to sell in a given year to stay under a specific tax bracket or the NIIT threshold
  • Financial planning conversations about the tax efficiency of different investment account types and sale timing strategies

Key Benefits

  • Uses current 2024 federal tax brackets for both ordinary income (short-term gains) and long-term capital gains
  • Automatically applies the 3.8% Net Investment Income Tax surtax when your income crosses the relevant threshold
  • Includes the IRC Section 121 primary residence exclusion for real estate sales, which can eliminate tax entirely on qualifying home sales
  • Shows both your effective rate (total tax as a share of the gain) and marginal rate (the rate on your next dollar of gain), which are often confused
  • Works for stocks, cryptocurrency, mutual funds, and real estate — any capital asset sale — using the same accurate bracket-stacking methodology
  • Free, completely private, and calculates entirely in your browser with no financial data sent to any server

Pro Tips

  • If an asset is close to the one-year holding mark and you're not under financial pressure to sell, waiting to cross into long-term status can meaningfully reduce your tax rate
  • Consider tax-loss harvesting — selling other underperforming investments at a loss in the same year — to offset a large realized gain
  • If you're near a tax bracket threshold, spreading a large sale across two tax years (partial sales in December and January) can keep more of the gain taxed at a lower rate
  • For real estate, keep detailed records of capital improvements over the years, since they increase your cost basis and reduce your taxable gain
  • Consult a tax professional before a very large sale — this calculator estimates federal tax accurately, but doesn't account for state taxes, AMT, or other situation-specific factors

Common Mistakes to Avoid

  • Confusing effective tax rate with marginal tax rate — your marginal rate applies only to the last dollar of gain, while your effective rate is the average rate across your entire gain
  • Forgetting that short-term gains are taxed as ordinary income at rates up to 37%, not at the more favorable long-term capital gains rates, and selling just before the one-year mark when waiting a bit longer could save significantly
  • Underestimating cost basis by forgetting to include reinvested dividends, brokerage commissions, or capital improvements to real estate, which inflates the taxable gain unnecessarily
  • Assuming a home sale is automatically tax-free without verifying the 2-of-5-years ownership and residency requirement for the Section 121 exclusion
  • Not accounting for the Net Investment Income Tax when income is close to the threshold, leading to an underestimated tax bill
  • Selling a large gain all in one tax year when spreading the sale across multiple years could keep more of the gain in lower brackets

Key Terms Explained

Cost Basis: The original value of an asset for tax purposes, generally the purchase price plus qualifying adjustments, used to calculate gain or loss on sale.
Long-Term Capital Gain: Profit from selling an asset held for more than one year, taxed at preferential federal rates of 0%, 15%, or 20%.
Short-Term Capital Gain: Profit from selling an asset held for one year or less, taxed as ordinary income at regular marginal tax rates.
Net Investment Income Tax (NIIT): A 3.8% federal surtax on investment income for taxpayers above certain income thresholds.
IRC Section 121 Exclusion: A federal tax provision allowing qualifying homeowners to exclude up to $250,000 ($500,000 married) of gain on the sale of a primary residence.
Modified Adjusted Gross Income (MAGI): Adjusted gross income with certain deductions added back, used to determine eligibility for various tax provisions including the NIIT threshold.
Tax-Loss Harvesting: Selling investments at a loss to offset realized capital gains and reduce overall tax liability.

Related Concepts

  • Tax Calculator
  • Investment Growth Calculator
  • Rent vs. Buy Calculator
  • Net Worth Calculator

Example

Consider a single filer selling stock for $300,000 that was purchased for $195,000, with $5,000 in selling expenses, held for more than a year (long-term), with $60,000 in other taxable income. Raw Gain = $300,000 − $195,000 − $5,000 = $100,000. No primary residence exclusion applies. Stacking on top of $60,000 of other income, the gain falls within the 15% long-term bracket (which for a single filer runs from $47,026 to $518,900), so Tax on Gain = $100,000 × 15% = $15,000. Since total MAGI ($60,000 + $100,000 = $160,000) is below the $200,000 NIIT threshold, no surtax applies. Total Tax = $15,000, an effective rate of 15% on the gain, leaving net after-tax proceeds of $280,000.

Interpreting Your Results

Your effective tax rate tells you the true overall cost of the sale as a share of your gain, while your marginal rate tells you what the next dollar of gain would be taxed at — the two are often different because of how brackets stack, and the marginal rate is the more useful number when deciding whether to sell more of an asset in the same tax year. A 0% or very low effective rate typically means your gain falls mostly or entirely within the 0% long-term bracket, or benefited from a large primary-residence exclusion — a favorable outcome worth confirming you've correctly entered your holding period and other income. A high effective rate, especially above 20%, usually signals either a short-term gain taxed as ordinary income, a large gain pushing well into the 20% long-term bracket, or the NIIT surtax applying on top of the base capital gains tax — in any of these cases, it's worth checking whether adjusting your sale timing, spreading the sale across tax years, or harvesting offsetting losses could meaningfully reduce what you owe.

Frequently Asked Questions

What is the difference between short-term and long-term capital gains?
Short-term capital gains apply to assets held for one year or less, and are taxed as ordinary income at your regular marginal tax rate — which can run as high as 37% federally. Long-term capital gains apply to assets held for more than one year, and benefit from preferential federal rates of 0%, 15%, or 20% depending on your total taxable income and filing status. This difference is often worth tens of thousands of dollars on a large sale, which is why holding an appreciated asset for just over a year before selling — when feasible — is one of the most impactful, fully-controllable tax decisions an investor can make.
What are the 2024 long-term capital gains tax brackets?
For 2024, single filers pay 0% on long-term gains up to $47,025 of total taxable income, 15% from $47,026 to $518,900, and 20% above $518,900. Married couples filing jointly pay 0% up to $94,050, 15% up to $583,750, and 20% above that. These thresholds are based on your total taxable income, not just the gain itself — meaning your ordinary income determines which bracket your capital gain starts stacking into.
How do I calculate my cost basis?
Cost basis is generally what you paid to acquire the asset, plus certain adjustments — for stocks, this is your original purchase price plus any reinvested dividends and brokerage commissions paid; for real estate, it includes the purchase price plus the cost of any capital improvements made over the years (though not routine repairs and maintenance), minus any depreciation claimed if the property was used as a rental. Your brokerage or closing statements are the best source for confirming your exact cost basis, especially for assets held over many years or acquired through multiple purchases.
What is the Net Investment Income Tax (NIIT)?
The NIIT is an additional 3.8% federal surtax on net investment income — including capital gains, dividends, and interest — that applies once your modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married couples filing jointly. It applies to the lesser of your net investment income or the amount by which your MAGI exceeds the threshold, and it's assessed on top of, not instead of, your regular capital gains tax.
Can I avoid capital gains tax when selling my house?
Under IRC Section 121, if the property was your primary residence and you owned and lived in it for at least 2 of the 5 years before the sale, you can exclude up to $250,000 of gain from taxation ($500,000 if married filing jointly) — meaning many home sales result in little or no capital gains tax at all. This exclusion doesn't apply to investment or rental properties that were never your primary residence, and gains above the exclusion amount are still taxed at the applicable long-term capital gains rate.
How does capital gains tax work on cryptocurrency?
The IRS treats cryptocurrency as property, not currency, meaning every sale, trade, or use of crypto to purchase goods or services is a taxable event subject to the same short-term versus long-term capital gains rules that apply to stocks. Because crypto transactions can be frequent and complex, many investors underestimate their tax liability — this calculator applies the same accurate bracket logic to your crypto gains as it does to stock or real estate sales, using your specific holding period and cost basis.
What is tax-loss harvesting and how does it relate to capital gains?
Tax-loss harvesting is the strategy of selling investments at a loss to offset capital gains realized elsewhere in your portfolio, reducing your overall taxable gain. Realized losses first offset gains of the same type (short-term losses offset short-term gains first), then any type, and up to $3,000 of net losses beyond that can offset ordinary income each year, with additional losses carried forward to future tax years — a valuable planning tool for investors managing a large realized gain.
Do I owe capital gains tax on stocks I haven't sold?
No — capital gains tax only applies to realized gains, meaning you must actually sell (or otherwise dispose of) the asset for the gain to become taxable. An investment that has appreciated in value but remains unsold has an 'unrealized' gain, which is not subject to capital gains tax under current US federal law, no matter how large the paper gain has grown.
What's the wash sale rule and does it affect this calculator?
The wash sale rule disallows a tax loss deduction if you sell a security at a loss and buy a substantially identical security within 30 days before or after the sale — the disallowed loss is instead added to the cost basis of the replacement shares. This calculator assumes the gain you're entering is a valid, recognized gain (or you're only calculating a gain scenario), so wash sale considerations only come into play if you're separately trying to harvest a loss on a related position.
How are state capital gains taxes handled?
This calculator estimates federal capital gains tax only, since state tax treatment varies enormously — some states (like Texas, Florida, and Washington) have no state income tax at all, while others (like California) tax capital gains as ordinary income at rates up to 13.3%. Check your specific state's tax rules, or consult a tax professional, to estimate the additional state-level liability on top of the federal figure shown here.
What happens if I have a capital loss instead of a gain?
This calculator is built for gain scenarios, but if your sale results in a loss (proceeds below cost basis plus expenses), you generally owe no capital gains tax on that transaction, and the loss can be used to offset other gains or up to $3,000 of ordinary income per year, with any remainder carried forward to future tax years indefinitely.
Should I sell now or wait to reach the long-term holding period?
If an asset is close to the one-year holding threshold and you're not under financial pressure to sell, waiting until you cross into long-term status can meaningfully reduce your tax bill, since long-term rates (0/15/20%) are typically well below short-term ordinary-income rates (up to 37%) for the same gain. This calculator lets you compare both scenarios directly — run the same numbers under 'short-term' and 'long-term' to see the exact dollar difference before deciding whether to hold a few more weeks or months.

Discover More Tools

Fresh picks from across our tool library.