Taxes and income

How Capital Gains Tax Is Calculated

Reviewed by the Smart Finance Calculators Editorial TeamLast reviewed:

When you sell an investment for more than you paid for it, the profit is called a capital gain — and only the gain, not the full sale amount, is subject to federal income tax. The tax calculation begins by determining your adjusted cost basis, subtracting it from the amount you actually received after selling expenses, and then applying the correct federal rate based on how long you held the investment.

This guide explains each step: how adjusted basis is established, how the amount realized differs from gross proceeds, why holding period matters so much, how the preferential long-term rate bands work, and what net proceeds look like after estimated taxes.

Key takeaways

  • Only the gain — amount realized minus adjusted basis — is taxable, not the full sale proceeds.
  • Short-term gains (held one year or less) are taxed as ordinary income through the standard federal brackets.
  • Long-term gains (held more than one year) may qualify for preferential 0%, 15%, or 20% federal rates.
  • The applicable long-term rate depends on total taxable income, not just the size of the gain.
  • Higher-income taxpayers may also owe the 3.8% Net Investment Income Tax on top of the capital-gains rate.
Try the Capital Gains Tax CalculatorPut these ideas to work with your own numbers

Step 1: Determine adjusted cost basis

Adjusted cost basis is your tax investment in an asset. It begins with the original purchase price and is increased by purchase commissions, certain acquisition fees, and other capitalized costs, then reduced by return-of-capital distributions and applicable prior adjustments.

For example, if you bought 100 shares at $50 each and paid a $25 commission, your initial basis is $5,025. If the company later returned $0.50 per share as a non-taxable return of capital, the basis would decrease to $4,975. Reinvested dividends generally create new tax lots with their own acquisition dates and basis; they do not simply add to the original lot's basis.

Step 2: Calculate the amount realized

The amount realized is what you actually received from the sale, reduced by direct selling costs. If you sold for $8,500 and paid a $25 brokerage commission on the sale, your amount realized is $8,475.

Do not subtract selling expenses that are already reflected in the proceeds reported on Form 1099-B. Deducting the same expense twice overstates the reduction.

Step 3: Compute the capital gain or loss

Capital gain or loss equals the amount realized minus the adjusted cost basis. Using the examples above: $8,475 amount realized minus $4,975 adjusted basis equals a $3,500 capital gain.

If adjusted basis exceeds the amount realized, the result is a capital loss. A capital loss can offset capital gains and, within limits, reduce ordinary taxable income.

Worked example: long-term stock sale (2026)

Purchase: 100 shares at $50 each with a $25 commission = adjusted basis of $5,025.

Sale: 100 shares at $85 each with a $25 commission = amount realized of $8,475.

Capital gain: $8,475 − $5,025 = $3,450 long-term capital gain (held more than one year).

Other taxable income: $45,000 (single filer, 2026). The 0%–15% threshold for single filers in 2026 is $49,450.

Space remaining below the threshold: $49,450 − $45,000 = $4,450. The entire $3,450 gain fits within that space.

Federal capital-gains tax: $0 (0% rate applies to the full gain).

If income had been $48,000 instead, only $1,450 of space would remain, so $1,450 would be taxed at 0% and $2,000 at 15%, producing a $300 federal tax.

2026 long-term capital-gain rate thresholds (taxable income)

Filing statusTop of 0% bandTop of 15% band
Single$49,450$545,500
Married Filing Jointly$98,900$613,700
Married Filing Separately$49,450$306,850
Head of Household$66,200$579,600
Qualifying Surviving Spouse$98,900$613,700

Taxable-income thresholds from IRS Revenue Procedure 2025-32. Ordinary income fills bands first; gains and qualified dividends are stacked above.

Step 4: Determine the holding period

Counting begins the day after you acquired the asset. The sale date is included. An asset sold exactly one year after purchase is still short-term; it must be held more than one year to qualify as long-term.

Short-term gains are taxed as ordinary income through the standard federal brackets — the same brackets that apply to wages. Long-term gains from most investment assets may qualify for lower preferential rates.

Step 5: Apply the correct federal rate

Short-term gains are added to other ordinary income and taxed through progressive brackets. Different portions can fall in different brackets, so the gain is not taxed at a single flat rate.

Long-term gains use the stacking method: ordinary taxable income fills the lower bands, then qualified dividends and long-term gains are stacked above. The 0% rate applies to the gain that fits within the available space below the 0%–15% threshold; the 15% rate applies to the next portion; the 20% rate applies to any remaining gain.

How to use the Capital Gains Tax Calculator

Use the Capital Gains Tax Calculator to estimate your short-term or long-term federal capital-gains tax, Net Investment Income Tax, and net proceeds. Enter your purchase price, sale proceeds, dates, filing status, and other income.

Open the Capital Gains Tax Calculator

Common mistakes to avoid

  • Treating the full sale proceeds as taxable income rather than only the gain above adjusted basis.
  • Forgetting to add purchase commissions and acquisition fees to the cost basis.
  • Deducting selling expenses that are already reflected in the proceeds on Form 1099-B, which counts them twice.
  • Assuming a gain is long-term simply because the sale happened in a new calendar year without checking the exact date count.
  • Applying the top marginal ordinary-income rate to a long-term gain without checking whether any of the gain falls in the 0% band.

Practical takeaways

  • The taxable gain is only the excess of amount realized over adjusted cost basis.
  • Holding an investment for more than one year can significantly reduce the federal rate, especially for taxpayers within the 0% long-term band.
  • Different portions of a single gain can be taxed at different rates if the gain spans two rate bands.
  • Qualified dividends share the same preferential rate bands and reduce the available 0%/15% space for capital gains.
  • The Net Investment Income Tax (3.8%) applies separately when MAGI exceeds the applicable threshold.

Frequently asked questions

Gross proceeds are the total amount received from the sale before subtracting anything. Taxable gain is what remains after subtracting both selling expenses (which reduce the amount realized) and adjusted cost basis. For example, selling an investment for $10,000 that you paid $7,000 for (with $50 in selling expenses) produces a taxable gain of $2,950 — not $10,000. Only the gain is subject to capital-gains tax.

Related calculators

Related guides

Sources and methodology

This article is based on general financial principles and information published by the authoritative primary sources below. Figures are illustrative and rounded to explain the concepts.

Rate thresholds are from IRS Revenue Procedure 2025-32 and apply to federal tax year 2026. Last reviewed: August 3, 2026.

About this article

Written and reviewed by the Smart Finance Calculators Editorial Team.

Published · Last reviewed

Financial disclaimer: Results are estimates for educational purposes only and are not professional financial, tax, legal or investment advice. Figures may not reflect your exact situation. Consult a qualified professional before making financial decisions.