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:
- 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.
- Enter your sale proceeds, cost basis, and any selling expenses (broker commissions, closing costs).
- Enter your other taxable income for the year — this determines which bracket your gain stacks into.
- Select your filing status.
- 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.
- 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.

