Lifetime Deal Complete Personal Financial Planning Bundle →
✓ Financial Planning✓ Net Worth Tracker✓ Monthly Budgeting✓ Travel Budget Planner✓ Annual Budgeting Planner✓ Monthly Expense Tracker✓ Annual Tax Planner✓ Retirement Planning
View Bundle →

Capital Gains Tax Calculator: What You Owe When You Sell Investments

Capital gains tax calculation on investment sales

Capital gains tax depends on how long you held the asset. Sell after a year or less and the profit is taxed as ordinary income, up to 37%. Hold longer than a year and long-term rates of 0%, 15%, or 20% apply, so pushing a sale past the one-year mark can cut the bill substantially. Losses offset gains dollar-for-dollar, and up to $3,000 of leftover losses reduce ordinary income each year.

Selling an investment at a profit feels good until the tax bill arrives. The gap between what you paid and what you sold for is a capital gain, and the government wants its share. How much depends on one surprisingly simple factor: how long you held the thing before selling it.

The Capital Gains Tax Calculator estimates what you will owe. No signup required.

The One-Year Line

The tax code draws a hard line at one year of ownership. Everything on one side of that line is taxed one way. Everything on the other side is taxed very differently.

One year or less (short-term): Gains are taxed at your ordinary income tax rate. If you are in the 24% bracket, you pay 24% on the gain. At the highest bracket, it is 37%.

More than one year (long-term): Gains qualify for preferential rates. For most people, that means 15%. For lower incomes, it can be 0%. For very high incomes, it tops out at 20%.

The practical difference is striking. A $10,000 gain on a stock sold at 11 months costs $2,400 in taxes for someone in the 24% bracket. Hold the same position past the one-year mark and the gain costs $1,500 at the 15% long-term rate. That is a $900 difference for a few more weeks of waiting. Few financial moves offer that kind of return for doing nothing.

How the Math Works

The formula is simple: subtract what you paid from what you received, then apply the appropriate tax rate.

Sale price - cost basis = capital gain

Cost basis includes the original purchase price plus any commissions or fees. For stocks bought in multiple lots over time, the basis depends on which shares you sell, so the choice is between specific identification (naming the exact shares) and FIFO (first in, first out). Average cost is a third method, but IRS Publication 550 limits it to mutual fund shares and shares held in a dividend reinvestment plan.

Choosing the right method matters. Selling the shares with the highest cost basis first produces a smaller gain and less tax. It is a detail that is easy to overlook and worth getting right.

Losses Are a Tool, Not Just Bad Luck

When an investment drops below what you paid for it, selling it creates a capital loss. Losses offset gains dollar-for-dollar. This is tax-loss harvesting, and it is one of the few ways to directly reduce your tax bill from investments.

Say you sold Fund A for a $5,000 gain this year. Fund B in your portfolio is currently down $3,000. Selling Fund B creates a $3,000 loss that offsets part of the gain. Instead of paying tax on $5,000, you pay on $2,000. At the 15% rate, that saves $450.

If your losses exceed your gains in a given year, up to $3,000 of the excess can offset ordinary income. Any remaining losses carry forward to future years, and they do not expire.

One catch: the wash sale rule. If you sell an investment to harvest a loss and buy something “substantially identical” within 30 days (before or after the sale), the loss is disallowed. Buying a similar but not identical fund, such as swapping one S&P 500 index fund for a total market fund, typically avoids this.

Real Estate Has Its Own Rules

Selling a home is the one capital gains event where many people owe nothing. The primary residence exclusion lets single filers exclude up to $250,000 in gains and married couples exclude up to $500,000, as long as the home was a primary residence for at least two of the last five years.

For a home purchased at $300,000 and sold at $500,000, the $200,000 gain is fully excluded. No tax. This exclusion is one of the more generous provisions in the tax code, and it applies automatically for qualifying homes.

Investment properties are a different story. No exclusion applies. All gains are taxable, and any depreciation claimed during ownership is recaptured at up to 25%. A 1031 exchange can defer the tax by reinvesting the proceeds into another investment property within specific timeframes, but the rules are strict and the process involves coordination with a qualified intermediary.

The Extra 3.8% Nobody Expects

For someone selling a large position, such as concentrated stock from an employer, the NIIT can add thousands to the tax bill. The calculator above applies the federal and state rates you pick and does not add the 3.8% for you, so that piece sits on top of the figure it returns.

Timing as Strategy

Capital gains tax is one of the few taxes where you have meaningful control over timing.

Holding period management. If a stock has gained value and you are close to the one-year mark, waiting a few weeks to sell can drop the rate significantly. Not every situation allows for patience, but when it does, the savings are real.

Income-year planning. Expecting lower income next year due to a sabbatical, career change, or retirement? Pushing a sale into the low-income year could move the long-term rate from 15% to 0%. The 0% bracket for long-term gains covers a meaningful amount of taxable income.

Charitable giving. Donating appreciated stock directly to charity avoids capital gains entirely. Instead of selling the stock, paying the tax, and donating the cash, you donate the stock and, for shares held more than a year, deduct their full market value. Shares held a year or less are deductible only up to what you paid for them. The charity sells it tax-free. Both sides come out ahead compared to donating cash.

Annual Tax Planner income table listing Capital Gains at a 15% rate alongside employment, dividend, and rental income

The Annual Tax Planner (Premium tier) treats capital gains as their own income line, applies the flat rate you enter for that line (15% in the sample), and rolls the result into a single tax-due total.

The Annual Tax Planner Template logs each sale on its Income sheet with a date, amount and currency, and its Dashboard sums those entries into one Capital Gains line, so the year’s total is already there when the return is due.

Tax-Aware Investing Guides

Frequently asked questions

Can I offset gains with losses?

Yes. Capital losses offset capital gains dollar-for-dollar. If losses exceed gains, up to $3,000 in net losses can offset ordinary income. Remaining losses carry forward to future years.

Do I owe capital gains on my home?

Primary residence gains up to $250,000 (single) or $500,000 (married filing jointly) are excluded if you've lived there 2 of the last 5 years. Gains above those thresholds are taxable.

How are inherited investments taxed when I sell them?

Inherited assets usually get a stepped-up basis to their fair market value on the date of death. If you sell soon after inheriting, the taxable gain is measured from that stepped-up value rather than what the original owner paid, so it is often small.

Does my state tax capital gains too?

Often, yes. The rates in this guide are federal. Most states with an income tax also tax capital gains, and a handful treat them the same as ordinary income. A few states have no income tax and no separate capital gains tax. State rules are separate from the federal calculation.

Do mutual funds trigger capital gains even if I didn't sell?

They can. Funds pass through capital gains distributions to shareholders, usually late in the year, and those are taxable even if you reinvest them and never sold a share. That is separate from the gain or loss you realize when you sell the fund itself.

When is capital gains tax due?

Capital gains are reported on your annual tax return. If gains are substantial, estimated quarterly payments may be needed to avoid underpayment penalties.

Sources

About this article

Capital gains rates, the $3,000 loss limit, and the wash sale rule checked against IRS Topic 409 and Publication 550. The home-sale exclusion and the 3.8% Net Investment Income Tax thresholds checked against IRS Topic 701 and the IRS Net Investment Income Tax guidance. Holding-period rule, the 2026 long-term rate thresholds and the 3.8% NIIT thresholds rechecked on 2026-09-10 against IRS Topic 409, Rev. Proc. 2025-32 and the IRS Net Investment Income Tax Q&A. Annual Tax Planner claims checked on 2026-09-10 against the shipped workbook (Dashboard income table, Income sheet) and the Dashboard screenshot embedded here. Last reviewed September 2026.

Ready to get started?

Download instantly and start managing your finances, or contact us to design a custom template package for your needs.

Private & secure

Your financial data stays on your device. We never see it.

Learn more →

Need help?

Check our guides or reach out with questions.

View FAQ →