Skip to content
CalculatorAtlas

Capital Gains Calculator

Tested

Gain on a sale and tax at the rate you enter.

Tested, not yet published. The formula for this calculator is implemented and passes its automated checks. This page stays non-indexable until it is reviewed and published.

$
$
$
%

Results

Enter your values and press Calculate. Results appear here.

  • • Result

Quick answer

Capital gain = sale price − purchase price − fees, and tax = gain × rate (if positive). Buying at $10,000 and selling at $15,000 with $100 of costs gives a $4,900 gain; at a 15% rate the tax is $735, leaving $4,165 after tax.

Enter the purchase and sale price, costs and your tax rate. The calculator returns the gain, estimated tax and after-tax profit. Use this capital gains calculator to check your own figures.

Related tools: Investment Calculator: Project investment growth from a rate of return you choose. Financial Calculator: Time-value-of-money solver for N, rate, present value, payment or future value. IRR Calculator: Internal rate of return of an investment from its yearly cash flows.

How to use the Capital Gains Calculator

  1. Enter purchase price (cost basis) ($) (0 or more).
  2. Enter sale price ($) (0 or more).
  3. Optionally, enter fees and costs ($) (0 or more).
  4. Enter capital gains tax rate (%) (between 0 and 100).
  5. Press Calculate to see the result, and use Reset to start again.
Inputs of the Capital Gains Calculator
InputWhat to enterAllowed values
Purchase price (cost basis)A number, in $≥ 0
Sale priceA number, in $≥ 0
Fees and costs (optional)A number, in $≥ 0
Capital gains tax rateA number, in %≥ 0, ≤ 100

Formula and method

Formula

gain = sale − purchase − fees; tax = max(0, gain) × rate

IEEE-754 double precision; money shown to cents, rates to 4 decimals. Results are estimates, not financial advice.

Tax rates depend on your place, income and holding period, so you enter the rate; losses produce no tax here.

Worked examples

These examples are verified: each one is an automated test case that the live calculator must reproduce exactly.

Example 1

Inputs: Purchase price (cost basis) = 10000; Sale price = 15000; Fees and costs = 100; Capital gains tax rate = 15.

Results of example 1
ResultValue
Capital gain$4,900.00
Estimated tax$735.00
After-tax profit$4,165.00

Example 2

Inputs: Purchase price (cost basis) = 8000; Sale price = 6000; Fees and costs = 0; Capital gains tax rate = 20.

Results of example 2
ResultValue
Capital gain-$2,000.00
Estimated tax$0.00
After-tax profit-$2,000.00

The first line is the headline result (capital gain). Below it the capital Gains Calculator lists estimated tax and after-tax profit, which describe the same case from other angles. IEEE-754 double precision; money shown to cents, rates to 4 decimals. Results are estimates, not financial advice.

Short and long term

In the US, assets held more than a year get long-term rates of 0%, 15% or 20% depending on income, while shorter holdings are taxed as ordinary income. Enter the rate that applies to you. State taxes are separate.

Losses

A loss produces no tax in this tool. In practice, losses can offset gains and up to a limited amount of ordinary income, with the rest carried forward. This is an estimate, not tax advice.

How the result changes with purchase price

Holding every other input at the first worked example, this table changes only purchase price. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.

How the result changes with purchase price
Purchase priceCapital gainEstimated taxAfter-tax profit
5000$9,900.00$1,485.00$8,415.00
10000$4,900.00$735.00$4,165.00
20000-$5,100.00$0.00-$5,100.00
40000-$25,100.00$0.00-$25,100.00

What happens with invalid input

These messages are produced by the calculator itself, so you know what to fix.

  • Purchase price (cost basis): entering "-1" shows "Purchase price (cost basis) must be at least 0." beside that field and no result.
  • Capital gains tax rate: entering "101" shows "Capital gains tax rate must be at most 100." beside that field and no result.

Choosing between the Capital Gains Calculator and similar calculators

Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.

Choosing between the Capital Gains Calculator and similar calculators
CalculatorYou enterIt returns
[Investment Calculator](/finance/investment-calculator/)initial amount, annual interest rate and yearsProjected value
[Financial Calculator](/finance/financial-calculator/)solve for, periods per year and paymentsFuture value (FV)
[IRR Calculator](/finance/irr-calculator/)initial investment and cash flowsIRR
[CAGR Calculator](/finance/cagr-calculator/)beginning value, ending value and yearsCAGR
[Present Value Calculator](/finance/present-value-calculator/)future value, annual discount rate and yearsPresent value

Background: interest, saving and investing

A nominal rate (APR) does not include the effect of compounding; the annual percentage yield (APY) does: APY = (1 + r/n)^n − 1. A 5% nominal rate compounded annually is 5.000%, semi-annually about 5.063%, quarterly about 5.095% and monthly about 5.116%, so more frequent compounding helps, but with diminishing returns.

The rate you enter in a projection is an assumption, not a promise: real returns vary and can be negative. Fees and taxes are not modelled unless the page says so.

Assumptions and limitations

  • Losses produce no tax

Results are estimates for planning, not financial advice. Lender terms, fees, taxes and rounding rules can change real figures, so confirm important numbers with your lender or a licensed adviser.

If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for purchase price (cost basis) and capital gains tax rate to confirm this.

Frequently asked questions

What is cost basis?

The purchase price plus costs.

Do I pay tax on unrealised gains?

Generally not until you sell.

What rate should I use?

Check the current rules for your jurisdiction.

What does the Capital Gains Calculator calculate?

Gain on a sale and tax at the rate you enter. It returns Capital gain, Estimated tax and After-tax profit.

What formula does the Capital Gains Calculator use?

gain = sale − purchase − fees; tax = max(0, gain) × rate. Tax rates depend on your place, income and holding period, so you enter the rate; losses produce no tax here.

What do I need to enter in the capital Gains Calculator?

You enter Purchase price (cost basis) ($), Sale price ($) and Capital gains tax rate (%). Optional: Fees and costs ($).

How is the result rounded or limited?

IEEE-754 double precision; money shown to cents, rates to 4 decimals. Results are estimates, not financial advice. Losses produce no tax.

What is an example of a capital Gains result?

With purchase price (cost basis) 10000, sale price 15000, fees and costs 100 and capital gains tax rate 15, the capital gain is $4,900.00.

Can I rely on this calculator for a decision?

Results are estimates for planning, not financial advice. Lender terms, fees, taxes and rounding rules can change real figures, so confirm important numbers with your lender or a licensed adviser. For this calculator in particular: Losses produce no tax.

Sources

  • Standard time-value-of-money relations (e.g. Brealey, Myers & Allen, Principles of Corporate Finance)

Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.