Capital Gains Tax Calculator
Calculate capital gains tax owed on the sale of an investment given the sale price, purchase price (cost basis), and applicable tax rate. Use it for stocks, real estate, business interests, collectibles — any appreciated asset sold for a profit.
Last updated: May 2026
Compare with similar
About this calculator
The formula is: capital gains tax = (sale price − purchase price) × rate ÷ 100. The numerator (sale − purchase) is the capital gain — your profit from the asset's appreciation. The rate depends critically on holding period and asset type. SHORT-TERM capital gains (asset held one year or less) are taxed as ordinary income at your regular federal income tax rate (10–37% for 2024). LONG-TERM capital gains (asset held more than one year) are taxed at preferential rates: 0% for taxable income under $47,025 single / $94,050 joint, 15% for most middle-income earners, 20% for high-income filers (over $518,900 single / $583,750 joint in 2024). Collectibles (art, coins, gold) are taxed at 28% regardless of holding period. Real estate has special rules including a primary-residence exclusion ($250K single / $500K joint of gain excluded from tax if you lived in the home 2 of the past 5 years). High earners also face the 3.8% Net Investment Income Tax (NIIT) on top of the standard capital gains rates. Cost basis is what you paid for the asset PLUS any improvements (for real estate) PLUS reinvested dividends (for mutual funds) — getting cost basis right is critical because the IRS taxes the gain, not the sale price. Edge cases: a sale below purchase produces a capital loss, which can offset other gains and up to $3,000 of ordinary income per year (excess carries forward). Wash-sale rules prevent claiming a loss if you buy back the same security within 30 days.
How to use
Example 1 — Long-term stock sale at 15% rate. You bought $20,000 of stock in 2018 and sold it in 2024 for $52,000. Long-term gain = $32,000. As a middle-income filer, the long-term capital gains rate is 15%. Enter 52000 for Sale Price, 20000 for Purchase Price, and 15 for Tax Rate. Result: $4,800. Verify: (52000 − 20000) × 15 / 100 = 32000 × 0.15 = $4,800. ✓ At 15% you keep $27,200 of the $32,000 gain after federal tax; state capital gains tax may add 0–13% more depending on your state. Example 2 — Short-term real estate sale. You bought a rental property for $310,000 ten months ago and sold it for $355,000. Because you held less than one year, this is short-term and taxed at your ordinary income rate — say 24% for a high earner. Enter 355000, 310000, and 24. Result: $10,800. Verify: (355000 − 310000) × 24 / 100 = 45000 × 0.24 = $10,800. ✓ Holding the property just 2 more months to cross the one-year line would have qualified for the 15% long-term rate, saving roughly $4,050 in federal tax — a real-world reason to plan asset sales around the holding-period threshold.
Frequently asked questions
What is the difference between short-term and long-term capital gains?
Short-term gains (asset held one year or less) are taxed at your ordinary income tax rate — the same as wages, ranging from 10% to 37% for 2024. Long-term gains (asset held more than one year) are taxed at preferential rates: 0% for taxable income under $47,025 single / $94,050 joint, 15% for most middle-income filers, 20% for high-income filers (over $518,900 single / $583,750 joint in 2024). The difference can be enormous — a high earner selling a $100,000 gain pays $37,000 short-term but only $20,000 long-term, a $17,000 swing on holding period alone. The holding period starts the day AFTER you buy and includes the day you sell. Planning a sale around the one-year mark is often the single largest tax-optimization decision an individual investor makes. Note that some assets (collectibles, certain real-estate gains) have special rates that don't follow this schedule.
How is cost basis calculated?
Cost basis is what you paid for the asset, adjusted for various factors. For stocks: purchase price + commissions and fees. For mutual funds: purchase price + reinvested dividends and distributions (which you already paid tax on). For real estate: purchase price + closing costs (transfer tax, title insurance, settlement fees) + capital improvements (additions, renovations, new roof — not maintenance like painting or repairs). For inherited assets: stepped-up basis to the fair market value on the date of death, which can wipe out decades of unrealized gains. For gifted assets: usually the donor's original basis carries over. Getting cost basis right is critical because the IRS taxes the GAIN, not the sale price; missing reinvested dividends in a mutual fund's basis can produce thousands of dollars of phantom tax. Brokerages now report cost basis to the IRS, but only for covered shares (purchased after 2011); for older holdings you need your own records.
What is the primary-residence exclusion?
Under Section 121 of the tax code, you can exclude up to $250,000 of capital gain on the sale of your primary residence ($500,000 for married filing jointly) if you owned and lived in the home for at least 2 of the past 5 years before the sale (the "2-out-of-5" rule). The exclusion is per sale, not per lifetime, so you can use it again after another 2-year period elapses. Gain above the exclusion is taxed at long-term capital-gains rates (since most homeowners hold the property more than a year). For example, a couple selling their home for $850,000 that they bought for $400,000 has a $450,000 gain — fully covered by the $500,000 joint exclusion, no capital gains tax owed. The same couple with an $850,000 sale on a $200,000 purchase has a $650,000 gain — $500,000 excluded, $150,000 taxable at long-term rates. This is one of the most valuable tax benefits in the US code and partly explains why housing equity is the foundation of most middle-class wealth.
What are the most common mistakes people make with capital gains?
The biggest is selling just before the one-year holding threshold and paying ordinary rates instead of long-term — a single day too soon can cost 10–22 percentage points of tax. The second is forgetting to include reinvested dividends in mutual fund cost basis, which inflates the apparent gain and the tax. The third is wash-sale violations: claiming a tax loss while buying back the same security within 30 days disallows the loss for tax purposes; the loss is added to the basis of the replacement shares. The fourth is forgetting that capital losses can offset gains (1:1) and up to $3,000 of ordinary income per year, with excess carrying forward indefinitely — tax-loss harvesting in down years is one of the most reliable ways to reduce taxes. The fifth is selling assets in a year you'll be in a higher bracket; deferring a few months into a low-income year (between jobs, in retirement) can dramatically lower the effective rate. Finally, high earners often forget the 3.8% NIIT on top of the headline capital-gains rate, pushing real long-term rates to 23.8% rather than 20%.
When should I not use this calculator?
Skip it for tax-deferred or tax-advantaged accounts — gains inside a traditional 401(k), IRA, or HSA are not taxed at sale (they're taxed at withdrawal as ordinary income); Roth account gains are not taxed at all when withdrawn correctly. It is the wrong tool for cryptocurrency transactions, which have their own complex rules including the requirement to track every transaction (every swap, sale, and even some staking events triggers a tax event) — use a dedicated crypto-tax tool. Do not use it for partnership interests, qualified small business stock (Section 1202), or other specialized investments that have unique tax treatment. It also doesn't handle the Net Investment Income Tax (NIIT) that adds 3.8% on top of capital gains for high earners (over $200K single / $250K joint), state capital-gains tax (which varies 0–13% depending on state), or the depreciation recapture on rental real estate (taxed at up to 25% rather than long-term rates). For any actual investment sale involving real money, use full tax software or consult a CPA, especially for real estate, business sales, or large transactions.