Capital Gains Calculator

$
$
Options — fees, holding period
$
Capital gain / loss — proceeds − cost basis
Return — on cost basis
Sale proceeds — shares × sell price
Holding term —

A capital gain is the profit when you sell an investment for more than it cost — proceeds minus cost basis. This calculator works out the gain or loss and the percent return from the shares, the buy and sell price, and any fees, and it flags whether the holding is short-term or long-term based on the months held. It deliberately shows the pre-tax profit and does not apply tax rates, which vary by country and income — use the gain and the term here as the starting point for your own tax rules.

How to Calculate a Capital Gain

Cost basis in, proceeds out, the difference is your gain.

1

Enter what you bought

Type the number of shares, the buy price each, and any purchase fees — together these are your cost basis.

2

Enter what you sold for

Type the sell price each. The proceeds are shares times the sell price.

3

Read gain and term

See the gain or loss, the percent return, and whether the holding counts as short-term or long-term.

Cost Basis, Proceeds and Holding Term

The three things that define a realized gain.

Your cost basis is the full price of getting into the position — shares times the buy price, plus commissions and fees. Your proceeds are what you get out. Subtract the first from the second and you have the realized capital gain, or a loss if it comes out negative. Expressed against the cost basis, that is your percent return.

The holding term matters because many tax systems tax long-held gains more gently than short-term ones, usually splitting at one year. This calculator labels the term from the months you enter, but stops short of applying any tax rate — those depend entirely on where you live and your income. Treat the gain and the term as the inputs a tax calculation begins from, and confirm the specific rules that apply to you.

Frequently Asked Questions

How is a capital gain calculated?
A capital gain is the profit when you sell an asset for more than it cost you: gain = sale proceeds − cost basis. The cost basis is what you paid to acquire the investment, including purchase fees or commissions; the proceeds are what you receive when you sell. If the result is positive it is a capital gain, if negative it is a capital loss. This calculator builds the cost basis from the number of shares times the buy price plus any fees, computes the proceeds from shares times the sell price, and returns the gain or loss along with the percent return. Everything runs in your browser, so nothing you enter is sent anywhere.
What is the difference between short-term and long-term capital gains?
The distinction is how long you held the asset before selling, and in many tax systems it changes how the gain is taxed. A common dividing line is one year: an asset held for a year or less produces a short-term gain, and one held longer produces a long-term gain, which is often taxed at a lower rate to reward longer holding. This calculator classifies your holding period as short-term or long-term based on the months you enter, but it does not compute tax — rates depend on your country, income and filing status. Use the classification as a prompt to check the specific tax treatment where you live; treat the gain figure itself as the pre-tax profit.
Does this calculate the tax I owe?
No — this tool deliberately calculates the gain or loss and the return, not the tax, because capital-gains tax rates vary widely by country, by income level and by the type of asset, and they change over time. Baking in a specific rate would make the tool wrong for most people and quickly out of date. What it gives you is the accurate pre-tax profit and its percentage return, plus whether the holding is short-term or long-term, which is the input a tax calculation starts from. To estimate tax, take the gain shown here and apply the capital-gains rate that fits your situation, or consult the current rules for your jurisdiction. For anything with real money at stake, confirm with a qualified tax professional.
How do fees affect a capital gain?
Fees reduce your gain because they raise your cost basis, and commissions on the sale reduce your proceeds. When you buy, brokerage commissions and transaction fees add to what the investment really cost you, so they belong in the cost basis; when you sell, selling costs come out of your proceeds. Both shrink the gain, which is why ignoring fees overstates your profit. In this calculator, enter total fees in the Fees field and they are added to the cost basis; if you also paid a selling commission, you can include it there too for a close approximation, or net it out of the sell price. Accounting for fees gives a truer picture of what you actually made.
What is a capital loss and can it help me?
A capital loss is what you have when you sell an investment for less than its cost basis — the gain comes out negative. Beyond the obvious sting, losses can have a silver lining in many tax systems: realized capital losses can often be used to offset capital gains, and sometimes a limited amount of ordinary income, reducing your tax bill in a strategy known as tax-loss harvesting. The rules, limits and any restrictions on quickly rebuying the same asset vary by jurisdiction, so check what applies to you. This calculator will show a loss as a negative gain in red and a negative percent return; how you can use that loss depends on your local tax rules.