When you sell an investment for more than you paid, the profit triggers a tax bill. Whether you are cashing out stocks, mutual fund shares, ETFs, or investment property, the IRS expects a percentage of that gain. The capital gains tax calculator helps you estimate exactly what you owe before you sell, so there are no surprises at filing time.

The uncertainty is the problem: many investors sell without knowing their tax liability, then face an unexpected bill months later when they prepare their return. Real estate sellers often underestimate the hit after a home sale that exceeds the primary residence exclusion. Stock traders who time the market can inadvertently push gains into the higher short-term bracket. The calculator removes the guesswork by applying current rates to your specific transaction.

The Formula: Sale Price Minus Cost Basis

Capital gain equals the amount you receive from the sale (your proceeds) minus what you originally paid for the asset plus any purchase costs (your cost basis). If you bought 100 shares of an index fund at $50 each and sold them at $75, your gain is $2,500: ($75 x 100) minus ($50 x 100).

Cost basis includes the purchase price, any commissions or fees paid when you bought the asset, and in some cases, reinvested dividends that increased your stake over time. For real estate, cost basis also includes the original purchase price, closing costs at purchase, and the cost of major improvements (a new roof, a kitchen remodel), but not routine repairs. According to foundational tax texts such as Principles of Finance, understanding cost basis adjustments is essential for accurate capital gains reporting.

The holding period determines your tax rate. If you owned the asset for one year or less before selling, the gain is short-term and taxed at your ordinary income tax rate (the same rate that applies to your wages). If you held it for more than one year, the gain is long-term and qualifies for lower preferential rates.

Short-Term vs. Long-Term Rates

Short-term capital gains face the full ordinary income tax schedule. For 2026, that ranges from 10% to 37% depending on your total taxable income. A single filer earning $100,000 who realizes a $10,000 short-term gain will pay 24% federal tax on that gain, or $2,400 (as of August 2026; verify current brackets before deciding).

Long-term capital gains get preferential treatment. The rates are 0%, 15%, or 20%, again depending on your taxable income. Most middle- and upper-middle-income households pay 15%. High earners whose income exceeds roughly $492,000 (single) or $553,000 (married filing jointly) pay 20%. Very low earners whose income stays below about $44,000 (single) or $89,000 (married) pay 0% on long-term gains.

An additional 3.8% Net Investment Income Tax (NIIT) applies to investment income (including capital gains) if your modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly). The NIIT stacks on top of the base capital gains rate, so a high earner could face a combined 23.8% federal rate on long-term gains.

State taxes add another layer. States such as California tax capital gains as ordinary income, which can add 9% or more. Other states have no income tax at all. The federal calculation is universal, but the total bill depends on where you file.

Worked Example: Selling Stocks

You purchased 200 shares of a technology ETF at $120 per share in January 2024, paying a $10 brokerage commission. Total cost basis: (200 x $120) + $10 = $24,010. You sell all 200 shares in March 2026 at $165 per share, paying another $10 commission. Proceeds: (200 x $165) minus $10 = $32,990.

Capital gain: $32,990 minus $24,010 = $8,980.

Read also: Understanding Capital Gains Tax Brackets and How to Reduce What You Owe

You held the shares for more than one year, so this is a long-term gain. Assume you are a single filer with $95,000 in taxable income, putting you in the 15% long-term capital gains bracket. Federal tax: $8,980 x 0.15 = $1,347. Your modified adjusted gross income does not exceed $200,000, so the NIIT does not apply. If you live in a state with no income tax, your total capital gains tax is $1,347. If you live in California and fall into the 9.3% bracket, add roughly $835 in state tax for a total of about $2,182.

Had you sold the shares in December 2024 (holding period under one year), the gain would be short-term and taxed at your ordinary 24% rate: $8,980 x 0.24 = $2,155 federal, before state. The one-year mark saves you $808 in federal tax alone in this scenario.

Worked Example: Selling Investment Property

You bought a rental condo in 2020 for $250,000, paid $8,000 in closing costs at purchase, and spent $15,000 on a new HVAC system in 2022. Cost basis: $250,000 + $8,000 + $15,000 = $273,000. You sell the property in 2026 for $340,000 and pay $20,000 in selling costs (agent commission, title fees). Net proceeds: $340,000 minus $20,000 = $320,000.

Capital gain: $320,000 minus $273,000 = $47,000.

This is a long-term gain (held more than one year). At the 15% federal rate, you owe $7,050 in federal capital gains tax. If the NIIT applies to you, add another 3.8%, bringing the federal total to $8,846. State tax depends on your residence.

Real estate also involves depreciation recapture if you claimed depreciation deductions while renting the property. The portion of the gain attributable to depreciation is taxed at a maximum 25% federal rate, not the preferential 15%. The calculator accounts for this by separating recapture from the remaining gain.

When the Calculator Matters Most

The calculator is most valuable before you execute the sale. If you are considering selling a stock position in December versus waiting until January, the calculator shows the tax difference and helps you decide whether the timing is worth it. If you are evaluating a 1031 like-kind exchange to defer tax on investment property, the calculator quantifies what you would owe without the exchange.

Tax-loss harvesting strategies also depend on accurate capital gains estimates. If you have $10,000 in unrealized losses and $15,000 in unrealized gains, you can offset the gain with the loss and owe tax only on the net $5,000. The calculator helps you model these scenarios in advance.

The IRS provides official guidance on capital gains through Publication 550 and the instructions for Schedule D (Form 1040), and the mechanics are covered in detail by educational resources such as those offered by the SEC. For complex situations involving inherited assets, gifted property, or business sales, consult a CPA or tax professional. The calculator handles the standard case: you bought something, you sold it, and you need to know the tax bill.