Skip to content

Capital Gains Calculator

✦ Finance & Money

Use this free capital gains calculator to find your gain or loss from any asset sale — stocks, real estate or crypto — with automatic short-term vs long-term classification and commission adjustments on both sides.

  • ✓ Calculated in your browser
  • ✓ Nothing you type is stored
  • ✓ No sign-up required
  • ✓ Formula and sources shown

The formula

Capital gain or loss

Adjusted Cost Basis = Purchase Price + Purchase Commission/Fees
Net Proceeds = Sale Price - Sale Commission/Fees
Capital Gain (Loss) = Net Proceeds - Adjusted Cost Basis
Gain % = Capital Gain / Adjusted Cost Basis x 100

The IRS measures gain or loss on the net amount you received minus your adjusted basis — what you actually paid, including buying costs. The holding period starts the day after the purchase and includes the sale date; a gain is long-term when the sale is after the first calendar anniversary of the purchase (a 29 February purchase: after 28 February of the next year). Source: IRS Topic 409, IRS Publication 550.

Calculating it by hand

  1. Add the purchase price and any buying commission or fees to find your adjusted cost basis.
  2. Subtract any selling commission or fees from the gross sale price to find your net proceeds.
  3. Subtract the adjusted cost basis from net proceeds: a positive result is a capital gain; negative is a capital loss.
  4. Enter your purchase and sale dates — the calculator applies the IRS one-year rule: a sale after the first anniversary of the purchase is long-term, one on or before it is short-term.
  5. Divide the capital gain or loss by the adjusted cost basis to find the percentage gain or loss.
  6. Optionally add an annual inflation assumption to see the inflation-adjusted real gain.

Worked examples

200 shares bought at $45 ($9,009.95 basis including $9.95 commission), sold at $62 ($12,390.05 net after $9.95 commission), held 14 months

  1. Adjusted cost basis: 200 x $45 + $9.95 = $9,009.95
  2. Net proceeds: 200 x $62 - $9.95 = $12,390.05
  3. Capital gain: $12,390.05 - $9,009.95 = $3,380.10
  4. Gain %: $3,380.10 / $9,009.95 = 37.52%
  5. Holding: bought 15 January 2025, sold 15 March 2026 — after the 15 January 2026 anniversary, so long-term

Capital gain $3,380.10 (37.52%); long-term — taxed at 0%, 15% or 20% federally depending on taxable income.

Home purchased at $280,000 (+ $3,500 closing costs) sold at $420,000 (- $12,600 agent commission) after 7 years

  1. Adjusted cost basis: $280,000 + $3,500 = $283,500
  2. Net proceeds: $420,000 - $12,600 = $407,400
  3. Capital gain: $407,400 - $283,500 = $123,900
  4. Gain %: $123,900 / $283,500 = 43.70%
  5. Holding: 1 June 2018 to 1 June 2025 — long-term

Capital gain $123,900 (43.70%); long-term. The main-home exclusion ($250,000 single / $500,000 married filing jointly) is not applied here — see IRS Publication 523.

0.5 ETH bought at $48,000 total, sold at $18,000 total after 9 months — a capital loss

  1. Adjusted cost basis: $48,000 (no buying commission)
  2. Net proceeds: $18,000 (no selling commission)
  3. Capital loss: $18,000 - $48,000 = -$30,000
  4. Loss %: -$30,000 / $48,000 = -62.50%
  5. Holding: 10 January 2025 to 10 October 2025 — before the anniversary, so short-term

Capital loss $30,000 (-62.50%); short-term. It offsets short-term and then long-term gains, and up to $3,000 of ordinary income a year (IRS Topic 409).

Methodology

How capital gains and losses are calculated

Most people focus on the sale price, but what determines your taxable gain is the difference between what you received and your adjusted cost basis — with the commissions and fees on both sides counted.

Read sources and limits

What is a capital gain or loss?

A capital gain is the profit you realise when you sell a capital asset — a stock, bond, piece of real estate, cryptocurrency, collectible or other investment — for more than your adjusted cost basis in that asset. A capital loss is the opposite: you sell for less than your basis.

Capital gains are taxed differently from wages. Long-term gains are taxed at preferential federal rates of 0%, 15% or 20%; short-term gains, on assets held one year or less, are taxed as ordinary income at rates from 10% to 37%. That difference is why the holding period matters: the same dollar gain can be taxed very differently a day apart.

Gains and losses are realised — and taxable — only when you sell or otherwise dispose of the asset; a gain on a position you still hold is not taxed. Capital losses offset capital gains, and a net capital loss offsets up to $3,000 of ordinary income a year ($1,500 married filing separately), with the rest carried forward (IRS Topic 409).

When is a gain long-term, and what are the 2026 rates?

A gain is long-term when you held the asset for more than one year. The holding period starts the day after you buy and includes the day you sell, so a sale on the first anniversary of the purchase is still short-term and the day after is long-term (IRS Publication 550). Bought 15 January 2025: long-term from 16 January 2026.

Count by the calendar, not by 365 days. Across a 29 February the anniversary is 366 days away: bought 1 February 2024, a sale on 1 February 2025 — 366 days later — is still short-term. Bought on 29 February 2024, the anniversary is 28 February 2025 and 1 March 2025 is the first long-term day. The calculator applies the anniversary rule and shows the first long-term date.

The 2026 long-term rates (IRS Rev. Proc. 2025-32 §4.03): 0% on taxable income up to $49,450 (single), $98,900 (married filing jointly) or $66,200 (head of household); 15% up to $545,500, $613,700 or $579,600; 20% above. Short-term gains are taxed with ordinary income at 10% to 37%.

The 3.8% Net Investment Income Tax can apply on top when modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly), on the lesser of net investment income or the excess (IRS Topic 559) — a top long-term rate of 23.8%. This calculator classifies the gain and gives the rate context; the tax itself depends on your full income.

What counts in cost basis and adjusted basis?

Your cost basis is generally what you paid for an asset, including the purchase commission, brokerage fee or closing costs. Shares bought for $10,000 with a $9.95 commission have an adjusted basis of $10,009.95, not $10,000. Selling costs come off the proceeds instead. Both change the size of the gain.

Basis can change over time. For real estate, capital improvements — a new roof, an added bathroom — increase it, and depreciation you claimed reduces it (with recapture taxed at up to 25% on sale). For securities, return-of-capital distributions reduce it and splits change the per-share figure. Inherited assets generally take a basis equal to the value at the date of death (IRC §1014).

If you own several lots of the same security bought at different prices, the method — first-in, first-out, specific identification or average cost for fund shares — decides which basis is used. This calculator models one lot; for several, enter each lot separately from your broker's cost-basis records.

How are crypto and real estate gains treated?

The IRS treats cryptocurrency as property (Notice 2014-21), so a sale, a swap for another coin or spending it is a taxable disposal under the same short- and long-term holding rules and the same basis methods as securities. This calculator handles crypto exactly as it handles stocks: enter the total purchase cost and total sale proceeds in dollars.

Investment real estate follows the same capital-gains rules, with two additions this calculator does not model: depreciation recapture, taxed at up to 25% on the depreciation you claimed (IRC §1250), and instalment sales, where each payment carries part of the gain into the year it is received. For a rental property with prior depreciation, use Schedule D and Form 4797.

For a main home, up to $250,000 of gain ($500,000 married filing jointly) can be excluded if you owned and lived in it for at least two of the five years before the sale (IRS Publication 523). The calculator cannot verify occupancy, so it does not apply the exclusion; see worked example 2.

What does this capital gains calculator not calculate?

It computes the gain or loss and classifies the holding period; it does not compute the dollar tax owed. That needs your total taxable income, filing status, every other gain and loss for the year, and your deductions — the federal tax depends on where the gain stacks on top of your other income.

State tax is not modelled. Most states tax capital gains as ordinary income at their own rates; a few have no personal income tax, and some treat gains separately. Check your state revenue department's current rules.

Depreciation recapture, instalment sales, wash sales across accounts, the home-sale exclusion and the §1202 small-business stock exclusion are outside a general calculator. The wash-sale flag here is a single-lot warning. For filing, use your Form 1099-B and Schedule D, and a tax professional for property or large losses. This is an educational estimate, not tax advice.

Capital Gains questions

How do you calculate capital gains?

Subtract your adjusted cost basis from your net proceeds. Adjusted basis is the purchase price plus buying commissions or fees; net proceeds are the sale price minus selling costs. Bought for $10,000 + $10 commission ($10,010 basis), sold for $14,500 - $10 ($14,490 proceeds): gain $4,480, or 44.76% of basis (IRS Topic 409).

What is the difference between short-term and long-term capital gains?

A gain is long-term when you held the asset more than one year — the holding period starts the day after purchase, so the sale must be after the first anniversary. Long-term gains are taxed at 0%, 15% or 20%; short-term gains, held one year or less, at ordinary income rates of 10% to 37%. A sale on the anniversary itself is short-term.

What are the long-term capital gains tax rates for 2026?

For 2026 (IRS Rev. Proc. 2025-32 §4.03): 0% on taxable income up to $49,450 single, $98,900 married filing jointly, $66,200 head of household; 15% up to $545,500, $613,700 and $579,600; 20% above. The 3.8% Net Investment Income Tax applies above $200,000 of modified AGI (single) or $250,000 (joint), for a top rate of 23.8%. Thresholds are indexed each year.

Is capital gains tax calculated on the sale price or the profit?

On the profit: net proceeds minus adjusted cost basis, not the sale price. Paid $80,000, sold for $100,000 with $2,000 of selling costs: the taxable gain is $100,000 - $2,000 - $80,000 = $18,000. On real estate the commission alone can be a large sum that directly reduces the gain.

Can capital losses offset capital gains?

Yes, in a fixed order: short-term losses against short-term gains and long-term against long-term, then any net loss against the other kind. A $5,000 short-term gain and an $8,000 long-term loss net to a $3,000 loss, deductible against ordinary income (the limit is $3,000 a year, $1,500 married filing separately); the rest carries forward. Rebuying within 30 days can trigger the wash-sale rule (IRS Publication 550).

What is adjusted cost basis and what can I add to it?

Start with the purchase price and add the costs of buying: commissions, transaction fees and real estate closing costs. For property, add capital improvements — not routine repairs. Subtract depreciation claimed and return-of-capital distributions. A higher basis means a smaller gain or a larger loss (IRS Publication 550).

How long do I need to hold a stock to get the long-term capital gains rate?

More than one year: sell after the first anniversary of the purchase date. Bought 1 March 2025, you qualify from 2 March 2026; a sale on 1 March 2026 is short-term. Across a leap day count by the calendar — bought 1 February 2024, a sale on 1 February 2025 is 366 days but still short-term. A 29 February purchase is long-term from 1 March of the next year.

Do I pay capital gains tax on the sale of my home?

Possibly not. If you owned the home and lived in it as your main home for at least two of the five years before the sale, you can exclude up to $250,000 of gain ($500,000 married filing jointly). Gain above the exclusion is taxable. This calculator does not apply the exclusion because it cannot check your occupancy; see IRS Publication 523.

What happens to capital gains when I inherit an asset?

An inherited asset generally takes a basis equal to its fair market value at the date of death (IRC §1014). Shares bought for $20,000 and worth $80,000 at death have an $80,000 basis; sold for $85,000, the gain is $5,000. Inherited property is treated as held long-term whatever the dates. Enter the value at death as the purchase price here.

Do capital gains push me into a higher tax bracket?

Long-term gains stack on top of your ordinary taxable income and are taxed at 0%, 15% or 20% depending on where the stack lands; they do not raise the rate on your wages. Single filer, 2026: $40,000 of ordinary taxable income plus a $20,000 long-term gain — $9,450 of the gain fills the 0% band to $49,450 and $10,550 is taxed at 15%, or $1,582.50.

How can I reduce capital gains tax?

Timing and account choice are the main levers. Holding past the first anniversary moves the gain from ordinary rates to 0%, 15% or 20%. Realised losses offset gains. Selling in a low-income year can put part of a gain in the 0% band — up to $49,450 of taxable income single, $98,900 joint in 2026. Gains inside IRAs and 401(k)s are not taxed on sale.

Do I pay capital gains tax on stocks sold inside an IRA or 401(k)?

No. Sales inside a traditional IRA, Roth IRA or 401(k) do not create a taxable gain, so the holding period does not matter. The trade-off comes at withdrawal: traditional-account withdrawals are taxed as ordinary income, so a gain that would have been taxed at 15% in a brokerage account may be taxed at your marginal rate later. Qualified Roth withdrawals are tax-free.

Source notes

Method, sources & limitations

Every figure on this page comes from the formula above applied to the values you enter. Nothing is estimated from market data, and no result is a forecast. These are the sources behind the method and any fixed figures it uses:

Educational information only. Results are estimates produced from the assumptions you enter, and are not financial, tax, legal or medical advice. Check anything that matters against a qualified professional and the cited sources.