Capital Gains Calculator
Calculate your capital gain, tax owed, and net profit from any investment sale. Works for stocks, ETFs, real estate, and more.
Investment Details
Brokerage commissions, transaction fees
15% long-term, 20–37% short-term (US)
Net Profit
—
after capital gains tax
—
Capital Gain
—
Tax Owed
—
Net ROI
Investment Gain Breakdown
Tax Rate Comparison
Calculation Details
Embed This Calculator
Copy the code and paste it into any webpage to embed this calculator.
WordPress users: add a Custom HTML block (not the Embed block) and paste the code there.
Free to use. A small "Powered by Blucalculator" credit is appreciated but not required.
How to use this calculator
Enter the purchase price, sale price, holding period, and your annual taxable income. The calculator returns your short-term or long-term capital gain, the estimated federal tax, and your after-tax profit.
The holding period matters more than most people realize. Hold an asset for one day under a year and you pay ordinary income rates — potentially 37%. Hold it one day longer and the maximum federal rate drops to 20%.
You bought 100 shares of a stock at $45 in January 2023 and sold them at $78 in March 2025:
Cost basis = 100 × $45 = $4,500 Sale proceeds = 100 × $78 = $7,800 Gain = $7,800 − $4,500 = $3,300
Held for over one year, so this is a long-term capital gain. At a 15% federal rate (income $47,026–$518,900 for single filers in 2025), federal tax = $3,300 × 15% = $495.
After-tax profit: $3,300 − $495 = $2,805.
Short-term vs long-term capital gains
The IRS splits capital gains into two buckets based on how long you held the asset.
Short-term: assets held one year or less. Taxed as ordinary income, meaning the same rate as your wages. In 2025, federal ordinary income rates range from 10% to 37%.
Long-term: assets held more than one year. Taxed at preferential rates: 0%, 15%, or 20%, depending on your total taxable income.
The cost basis is what you paid for the asset, including commissions. If you received shares as a gift, your basis generally carries over from the original owner. Inherited assets typically get a step-up in basis to the fair market value on the date of death, which is one of the more significant tax breaks in the U.S. tax code.
2025 federal long-term capital gains tax rates
| Taxable Income (Single) | Rate |
|---|---|
| $0 to $48,350 | 0% |
| $48,351 to $533,400 | 15% |
| Above $533,400 | 20% |
| Taxable Income (Married Filing Jointly) | Rate |
|---|---|
| $0 to $96,700 | 0% |
| $96,701 to $600,050 | 15% |
| Above $600,050 | 20% |
These thresholds adjust annually for inflation. The 0% bracket is a real opportunity: if your total taxable income falls below $48,350 as a single filer, you can realize long-term capital gains completely free of federal tax.
Some investors specifically time their income in early retirement to stay in the 0% bracket before Social Security and required minimum distributions start.
The Net Investment Income Tax (NIIT)
If your modified adjusted gross income (MAGI) exceeds $200,000 (single) or $250,000 (married filing jointly), the IRS charges an additional 3.8% surtax on the lesser of your net investment income or the amount above the threshold.
This means high earners can face effective federal rates of 23.8% on long-term gains (20% + 3.8%) rather than 20%.
The NIIT applies to capital gains, dividends, interest, rental income, and passive income. It does not apply to wages or income from active businesses. The thresholds are not adjusted for inflation — they’ve been fixed since 2013.
State capital gains taxes
Most states tax capital gains as ordinary income. California, for example, taxes capital gains at the same rate as wages — up to 13.3% on high earners. New York tops out at 10.9%.
Seven states have no income tax at all: Alaska, Florida, Nevada, South Dakota, Tennessee, Texas, and Wyoming. Washington and New Hampshire have no tax on wage income but do tax investment income in some cases.
When you’re calculating the real tax cost on a gain, add the federal rate and your state rate together. A California resident in the top bracket can face combined rates of over 33% on short-term gains — more than one-third of the profit gone before you spend a dollar.
Cost basis methods
When you’ve bought the same stock at multiple prices, you need a method to calculate what your cost basis is. The IRS allows several approaches.
FIFO (First In, First Out): The shares you bought first are assumed to be the ones you sell first. This is the default for most brokers. In a rising market, FIFO means you’re selling your lowest-basis shares first, which creates the largest gains.
Specific Identification: You tell your broker exactly which lot of shares you’re selling. This gives you the most control. You can sell your highest-basis shares to minimize the gain, or your lowest-basis shares to realize losses strategically.
Average Cost: Only allowed for mutual funds. The IRS averages the cost across all shares in the fund, so every share has the same basis. You can’t switch back from average cost once you’ve used it without IRS permission.
Choosing the right method at the time of sale can save thousands in taxes. Most people never think about it. If you’re selling a large position, take 10 minutes to check which lots minimize your tax bill.
The wash-sale rule
You can’t sell a losing investment, claim the tax loss, and buy the same investment back immediately. The IRS has a rule for this: the wash-sale rule.
If you sell a security at a loss and buy the same or a “substantially identical” security within 30 days before or after the sale, the loss is disallowed for the current year. The disallowed loss gets added to your basis in the replacement shares instead.
The wash-sale window is 61 days total: 30 days before the sale, the day of the sale, and 30 days after.
The rule applies to stocks, ETFs, and options on those securities. It does not apply to cryptocurrencies under current IRS guidance (as of 2025). If you want to maintain exposure to a sector after harvesting a loss, buy a similar but not substantially identical ETF during the 30-day window.
Strategies to minimize capital gains taxes
Hold for over one year. This is the single biggest lever. At ordinary income rates, a gain that could have been taxed at 15% might be taxed at 32% instead. Patience has a tax return.
Use tax-loss harvesting. Selling losing positions to offset gains is called tax-loss harvesting. You can use capital losses to offset an unlimited amount of capital gains, plus up to $3,000 of ordinary income per year. Unused losses carry forward to future years.
Donate appreciated stock. If you give shares directly to a charity instead of cash, you get a deduction for the full fair market value and never pay capital gains tax on the appreciation. This is consistently one of the most tax-efficient forms of charitable giving.
Use tax-advantaged accounts. Investments inside a traditional IRA, Roth IRA, or 401(k) grow without triggering capital gains taxes. When you sell inside a Roth IRA, gains are tax-free entirely. This is where your highest-return, highest-turnover investments probably belong.
Realize gains in low-income years. If you retire early or take a sabbatical, your income in that year may fall into the 0% long-term capital gains bracket. That’s a window to sell appreciated assets at zero federal tax cost.
Consider installment sales. If you sell a business or real estate, structuring payments over multiple years can spread the gain across tax years and potentially keep you in lower brackets each year.
Capital losses and the $3,000 deduction
If your total capital losses exceed your total capital gains for the year, you can deduct up to $3,000 of the net loss against ordinary income. Any excess carries forward to the next year, indefinitely.
This carry-forward has real value. A $30,000 capital loss that generates no gains to offset can deduct $3,000 per year for 10 years. If you’re in the 22% bracket, that’s $660 of tax savings every year.
Short-term losses first offset short-term gains. Long-term losses first offset long-term gains. If losses in one category exceed gains in that category, the remainder offsets gains in the other category.
Calculating basis for stock received as compensation
If your employer granted you restricted stock units (RSUs) or stock options, the tax math is different.
For RSUs, you pay ordinary income tax on the value at vesting. That value becomes your cost basis. Any subsequent gain from that basis to the eventual sale is a capital gain — and if held over a year from vesting, it’s long-term.
For non-qualified stock options (NSOs), you pay ordinary income tax on the spread at exercise (fair market value minus strike price). That spread is your additional basis. The capital gain or loss at sale is measured from your total basis (strike price plus ordinary income recognized).
For incentive stock options (ISOs), the mechanics are more complex because of the Alternative Minimum Tax. ISOs require calculating the bargain element for AMT purposes even if you don’t sell at exercise. If you’re holding a lot of unexercised ISOs, consider running the AMT calculation before year-end.
Real estate capital gains
Gains from selling your primary home get special treatment. If you’ve lived in the home for at least 2 of the last 5 years, you can exclude up to $250,000 of gain from tax ($500,000 for married couples filing jointly). This exclusion can be used once every two years.
Investment properties don’t qualify for the exclusion. Depreciation you’ve claimed on rental property gets “recaptured” at 25%, a special rate for unrecaptured Section 1250 gain — higher than the standard 15% long-term capital gains rate.
A 1031 exchange lets you defer capital gains on investment property indefinitely by reinvesting the proceeds into a “like-kind” property within a strict timeline. This is one of the most powerful tax-deferral tools in real estate investing.
Common mistakes when calculating capital gains
Forgetting about reinvested dividends. Every dividend reinvestment purchase creates a new tax lot with its own basis. If you’ve held a mutual fund for 20 years and reinvested dividends, your actual average basis is much higher than just your original purchase — and ignoring those reinvestments means overpaying taxes. Your broker’s 1099-B should track this, but it’s worth verifying.
Mixing up proceeds and profit. Capital gains tax is on the net gain, not on total sale proceeds. Selling $50,000 of stock you bought for $45,000 means you owe tax on $5,000, not $50,000. Some people panic at large sale amounts on their 1099-B without checking the basis.
Missing the step-up in basis for inherited assets. If you inherit stock and immediately sell it, you generally owe no capital gains tax — the basis steps up to the date-of-death value. Not knowing this is a costly mistake.
Failing to account for improvements on real estate. Improvements to a property add to your basis, reducing the eventual gain. Keep records of every renovation. A $30,000 kitchen remodel you did 10 years ago could save $4,500 in taxes when you sell.
Frequently Asked Questions
What is a capital gain?
A capital gain is the profit from selling a capital asset — a stock, bond, real estate, or other investment — for more than you paid for it. The gain equals your net proceeds minus your cost basis (what you paid plus any fees).
What is the difference between short-term and long-term capital gains?
Short-term gains come from assets held one year or less, taxed at your ordinary income rate (up to 37% in the US). Long-term gains come from assets held more than one year, taxed at preferential rates of 0%, 15%, or 20%. Holding an asset just past the one-year mark can cut your tax rate significantly.
What are the 2024 long-term capital gains tax rates?
For 2024, long-term capital gains rates are: 0% for single filers with taxable income up to $47,025; 15% for income from $47,026 to $518,900; and 20% above $518,900. High earners may also owe an additional 3.8% Net Investment Income Tax.
Do I pay capital gains tax if I don't sell?
No. Capital gains tax is only triggered when you sell, or "realize" the gain. An investment that has grown in value but hasn't been sold has an unrealized gain, which is not taxable. This is why "buy and hold" can be an effective tax deferral strategy.
What is cost basis and how do I calculate it?
Cost basis is what you paid for the investment, including commissions. For stocks bought in multiple lots, you have several methods: FIFO (first purchased, first sold), LIFO (last purchased, first sold), and specific identification (you choose which shares to sell). The IRS default for mutual funds is average cost.
Are brokerage fees deductible from capital gains?
Yes. Brokerage commissions and transaction fees are added to your cost basis, which reduces your taxable gain dollar for dollar. If you paid $50 in commission to buy and $50 to sell, those $100 in total fees directly reduce the gain you report.
What happens if I have a capital loss?
A capital loss occurs when you sell an asset for less than your cost basis. You can use capital losses to offset capital gains dollar for dollar. If your losses exceed your gains, up to $3,000 of the net loss can be deducted against ordinary income per year, with remaining losses carrying forward.
Can capital losses offset ordinary income?
Yes, but only up to $3,000 per year ($1,500 if married filing separately). If you have a net capital loss of $15,000 after offsetting all gains, you can deduct $3,000 against ordinary income this year and carry the remaining $12,000 forward to future years.
What is the net investment income tax (NIIT)?
The NIIT is an additional 3.8% tax on investment income — including capital gains, dividends, and interest — for taxpayers above certain income thresholds: $200,000 for single filers and $250,000 for married filing jointly. High earners can effectively pay 23.8% on long-term capital gains.
How do wash sale rules affect capital gains?
The wash sale rule disallows a capital loss if you buy the same or substantially identical security within 30 days before or after the sale. The disallowed loss is added to the cost basis of the replacement shares. The rule exists to prevent investors from selling to harvest a loss and then immediately buying back the same position.
Related Calculators
Tax Loss Harvesting Calculator
Calculate tax savings from harvesting investment losses and see how capital losses offset your gains.
Stock Profit Calculator
Calculate your net profit or loss from a stock trade — including brokerage fees, taxes, and dividends.
ROI Calculator
Calculate Return on Investment (ROI), net profit, annualized ROI, and investment performance.
Annualized Return Calculator
Calculate annualized return (CAGR), total return %, and growth multiplier for any investment. Includes live growth chart comparing compound vs simple return.
Rate of Return Calculator
Calculate rate of return, total profit/loss, and annualized return on any investment.
Stock Average Calculator
Calculate your average stock purchase price, total cost basis, and break-even price across multiple buy orders.