To Calculate Capital Gains Tax or loss, use this formula:

Capital gain or loss = Amount realized − Adjusted basis

How Is Capital Gains Tax Calculated?

Capital Gains Calculation Formula

The basic formula for calculating a capital gain or loss is:

Capital gain or loss = Amount realized − Adjusted basis

Why Capital Gains Tax Is Not Simply Gain × One Rate

The general rule for determining the capital gain or loss is:

Capital Gain vs. Capital Loss

A capital gain occurs when the amount realized from selling an asset is greater than its adjusted basis. For example, buying an investment for $10,000 and selling it for $15,000 creates a $5,000 capital gain.

A capital loss occurs when the amount realized is lower than the adjusted basis. For example, selling an asset purchased for $10,000 for $7,000 results in a $3,000 capital loss. Capital losses may be used to offset capital gains, subject to tax rules and limitations.

How to Calculate Capital Gains Tax Step by Step

Calculating capital gains tax involves more than subtracting your purchase price from your selling price. Follow these steps to estimate your potential tax liability.

1: Determine Your Amount Realized

The calculation of capital gains tax is more complicated than just subtracting the purchase price from the selling price. These are the steps to figuring out how much you could owe in taxes.

2: Calculate Your Adjusted Cost Basis

Your adjusted basis generally begins with the asset’s original cost. Certain expenses, improvements, fees, depreciation, and other adjustments may increase or decrease that basis.

3: Calculate Your Capital Gain or Loss

Use the basic formula:

Capital gain or loss = Amount realized − Adjusted basis

A positive result is a capital gain; a negative result is a capital loss.

4: Determine Your Holding Period

Assets held for one year or less generally produce short-term gains. Assets held for more than one year generally produce long-term gains. Short-term gains are typically taxed as ordinary income, while long-term gains may receive preferential rates.

5: Net Your Capital Gains and Losses

If you have multiple transactions, you generally cannot calculate the tax on each transaction independently and simply add the amounts. Short-term and long-term gains and losses must be categorized and netted according to IRS rules.

6: Determine the Applicable Tax Rate

Your applicable rate depends on factors including taxable income, filing status, holding period, and type of gain. Long-term capital gains generally use different federal rate thresholds than ordinary income.

 7: Check Additional and State Taxes

Some taxpayers may also owe the Net Investment Income Tax (NIIT). State taxes can further affect the total because capital gains taxation varies by state.

8: Estimate Your Total Capital Gains Tax

Suppose you have a $20,000 net taxable long-term capital gain and, after considering your taxable income and filing status, the applicable federal rate on the entire gain is 15%.

$20,000 × 15% = $3,000 estimated federal capital gains tax

This simplified example excludes NIIT, state taxes, special asset rates, and other circumstances that could change the final tax bill.

How to Calculate Adjusted Cost Basis

The adjusted cost basis is the amount that you invested in an asset for tax purposes; it is an important figure in determining the capital gains or capital losses from an asset. In the case of property purchased, basis begins with the cost and adjustments are made for certain adjustments.

Purchase Price and Acquisition Costs

Typically, the starting basis will correspond to the purchase price of the asset. Other qualifying purchase costs, like commissions, transfer fees, etc. can also be added.

Adjustments That Can Increase Basis

Basis may be increased due to the following:

Adjustments That Can Decrease Basis

Other applicable reductions may also cause basis to be reduced, such as insurance reimbursements or certain casualty-loss adjustments, or depreciation.

Cost Basis for Stocks and Investments

The basis of purchased stocks and bonds is typically the purchase price plus any commissions and other expenses that are considered “qualifying costs. The basis of purchased stocks and bonds is normally the purchase price plus any commission or other costs that are known as “qualifying costs. Investors should pay close attention to the brokerage statements as corporate actions, reinvestments, and other events may impact basis.

Basis of Inherited or Gifted Property

Special consideration must be given to inherited and gifted assets. Fair market value at the time of death is the basis for inherited property, but other exceptions may apply, such as estate-tax valuations and alternate valuations. The adjusted basis of the donor, the fair market value at the time of the gift, the gift tax, and the different calculations if there is a gain or loss at the time of sale, are all involved in the gift of property.

The rules of the income tax can be intricate, so when figuring out basis of inherited or gifted assets, taxpayers should refer to the current IRS Publication 551 on the basis of assets or seek the advice of qualified tax advice.

Short-Term vs. Long-Term Capital Gains Tax Calculations

How a gain on an asset is treated for tax purposes can vary depending on the asset and the length of time the asset is held. IRS rules also dictate that any asset with a holding period under one year would be short-term and any asset with a holding period greater than one year would be considered long-term.

How to Calculate Short-Term Capital Gains Tax

The net short-term capital gains are (usually) taxable as ordinary income. Once gains (or short-term losses) have been calculated and the net short-term gain (loss) netted, the net short-term gain is added to other taxable income and taxed at the taxpayer’s applicable ordinary income tax rates.

As an illustration, a $5,000 net short-term capital gain will not be subject to the special capital gains rate. Rather, it has a tax effect on the taxpayer’s entire taxable income and taxable brackets.

How to Calculate Long-Term Capital Gains Tax

Federal capital-gain rates may be applied to the net long-term capital gains. The tax rate depends on the type of gain, filing status and taxable income. There are special rate rules for certain assets, such as collectibles and some real-estate gains.

Why Taxable Income Matters

It is not always possible to determine the long-term gains as gain × one rate. The rate thresholds for taxation of capital gains are tied to the total of all taxable income, so a capital gain on some of the income could be taxed at a lower rate than the others. When calculating final tax, taxpayers should use the tax worksheet and thresholds from the current year IRS publication.

Current Federal Capital Gains Tax Rates and Brackets

Long term gains are mostly taxed at preferential federal rates, typically 0%, 15%, or 20% and depend on the taxpayer’s filing status and taxable income. Income thresholds vary, so be sure to use a table with the tax year indicated and the thresholds straight from the IRS guidance when publishing or updating this article.

Capital Gains Tax Calculation Examples

1: Long-Term Stock Gain

$20,000 proceeds → $12,000 basis → $8,000 gain → net long-term gain → applicable long-term rate → estimated tax

2: Short-Term Stock Gain

$15,000 proceeds → $10,000 basis → $5,000 gain → net short-term gain → ordinary-income treatment → estimated tax

3: Multiple Gains and Losses

$12,000 gains − $5,000 losses → $7,000 net gain → applicable treatment → estimated tax

4: Losses Exceed Gains

$4,000 gains − $9,000 losses → $5,000 net capital loss → apply current IRS deduction and carryover rules

5: Real Estate Sale

$400,000 proceeds → $300,000 adjusted basis → $100,000 gain → apply applicable exclusions, depreciation and netting rules → determine rate → estimated tax

How Capital Losses Affect Your Capital Gains Tax Calculation

Capital losses can decrease the amount of capital gain that is subject to tax. The IRS netting process typically involves taxpayers first netting gains and losses by short-term and long-term classification.

Netting Short-Term and Long-Term Gains and Losses

Short-Term Gains are first offset by short-term losses and Long-Term Gains are first offset by the long-term losses. The amounts that are resulting from these are then netted together according to the IRS rules as a net capital gain or loss for the taxpayer.

Individuals might be able to deduct a portion of the total allowable capital losses from other income if the total allowable capital loss is greater than the capital gain. The limit is normally $3,000, $1,500 for married filing separately, for 2025 returns. Eligible losses often can be carried forward to future years. Confirm limits for the article for the year it is intended to be published.

How to Calculate Capital Gains Tax on Stocks and Investments

When it comes to stocks, first you have to calculate the cost basis (typically the price of the stock plus related commissions and fees), which will then be modified as appropriate. Subtract the adjusted basis from the proceeds of the sale to determine a gain (or loss).

The sales and available basis information is generally reported on Form 1099-B by the brokerage and tax payers should review the information for accuracy. Mutual funds and ETFs follow the same basis and holding time rules, but distributions made from a mutual fund that are reinvested may impact basis.

There are also other taxable dispositions of digital assets, such as digital asset sales, which may result in a capital gain or capital loss and have other reporting and basis rules depending on the type of sale.

How to Calculate Capital Gains Tax on Real Estate

The first step in calculating capital gains on a real estate transaction is to calculate the adjusted basis of the property and then compare it to the amount realized from the transaction.

Calculating Adjusted Basis in Property

The basis typically starts with the purchase price of the property plus some of the costs of acquisition. The basis can be increased by substantial renovations or adding on (qualifying capital improvements). Some adjustments, such as depreciation, might decrease it.

The amount realized may also be impacted by selling expenses. Therefore, it is important to keep good records of the cost of buying, adding value, depreciation, and selling.

Investment and Rental Property Considerations

There may be other tax rules that apply to selling an investment or rental property. The depreciation deductions typically decrease adjusted basis, which can increase the taxable gain. The portion of the gain due to depreciation could also be classified as unrecaptured Section 1250 gain, for which there are special federal tax-rate rules.

Calculating Gain on the Sale of a Main Home

The basic calculation is:

Gain = Amount realized − Adjusted basis

Many married couples filing jointly may be able to exclude up to $500,000 of gain, however, up to $250,000 of gain may be excluded subject to IRS requirements for qualifying homeowners.

Generally it is required that the applicant is subject to tests of ownership and use, and other tests. To calculate the taxable gain, taxpayers should make sure to check with the IRS for the latest guidelines regarding the home-sale exclusion.

Does the 3.8% Net Investment Income Tax Affect Your Calculation?

In reality, the Net Investment Income Tax (NIIT) will raise the federal income tax burden for some taxpayers with investment income, but it should not be a “one size fits all” tax on all capital gains.

For taxpayers subject to NIIT, the tax is generally 3.8% of the lesser of:

There are some capital gains, dividends, interest, rental income and other investment income that are included in net investment income. The application of NIIT would depend on the type of income and taxpayer’s MAGI. So, first compute regular capital gains tax rate and then compute NIIT.

How State Capital Gains Taxes Affect Your Total Tax

Federal Capital Gains Taxes may only be a part of your tax liability. Tax treatment will differ from state to state and federal and state capital gains calculations should be distinct.

A number of states have a state income tax system in place that bases the imposition of income taxes on capital gains, and some states may have different capital gains rates, deductions, exclusions or special rules. Other factors such as where you are located, where your property is located, and your situation before the transaction may impact the outcome.

To accurately plan, the federal liability is first determined, then if applicable, state taxes determine if there is an additional liability.

To focus on the details of state capital gains tax and for long-term accuracy, a separate state capital gains tax hub is provided instead of adding 50 state rules that are frequently changing.

How to Report Capital Gains and Losses to the IRS

Once capital gains and losses have been computed, taxpayers normally report the transactions on their federal income tax return on the necessary IRS forms.

Form 1099-B

In general, brokers will provide a Form 1099-B that reports investment sale proceeds and (if available) cost basis and holding period data. Taxpayers should check these on their tax records.

Form 8949

Form 8949 is typically used to report individual sales/exchanges of capital assets and to apply adjustments to the transaction information reported.

Schedule D (Form 1040)

Schedule D reports capital gains and losses, includes other related capital-gain items and aids in calculating the net capital gain or loss.

Capital Gains Tax Calculator: What Information Do You Need?

A useful capital gains tax calculator should request:

These inputs enable an estimate of basis, holding period, net gains and applicable rates to be carried out on a calculator.

However, simple estimates might not cover the case of NIIT, depreciation, collectibles, qualified small business stock, inherited or gifted property, home-sale exclusions or the complicated loss netting rules. In some cases, IRS worksheets and/or specialized tax advice may be necessary.

Common Capital Gains Tax Calculation Mistakes

Capital gains tax calculations can become inaccurate when taxpayers overlook basis adjustments, holding periods, or additional taxes. Common mistakes include:

Ways to Potentially Reduce Capital Gains Tax

Several planning strategies may help eligible taxpayers reduce their capital gains tax exposure:

The effectiveness of each strategy depends on individual circumstances and current tax law, so taxpayers should review applicable IRS guidance before making tax-driven decisions.

Frequently Asked Questions About Calculating Capital Gains Tax

1. What is the formula for calculating capital gains tax?

First calculate your gain or loss:

Capital gain or loss = Amount realized − Adjusted basis

The taxable amount is then dependent on a variety of factors including the holding period, taxable income, filing status, asset type, losses and applicable tax rates.

2. How do I calculate capital gains tax on stocks?

The amount of profit from the sale of the stock after subtracting the adjusted cost basis. Then figure out if it’s a short term or long term gain, and use the correct tax treatment.

3. How do I calculate capital gains tax on real estate?

Determine the amount of money realized in the sale and deduct the adjusted basis of the property. The taxable result may be impacted by improvements, depreciation, selling costs and/or any home-sale exclusion.

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

The capital gains tax is usually only on the taxable gain, rather than the total sales price. The gain is determined by comparing the amount realized with the asset’s adjusted basis.

5. What expenses can be included in adjusted cost basis?

Basis can include some of the acquisition costs, commissions, capital improvements, and other qualifying costs depending on the asset and the applicable tax rules. Basis can be reduced by some adjustments, like depreciation.

6. How do I calculate capital gains if I bought shares at different prices?

These shares can have varying bases of valuation. The calculation will vary based on which shares are considered to be sold and the allowable basis identification approach adopted, such as specific identification or other acceptable basis identification approach.

7. How does taxable income affect my capital gains tax rate?

Long term capital gains are calculated based on the taxable income. Gains are subject to income thresholds, and therefore may be subject to different rates for different parts.

8. How are short-term capital gains calculated?

Compute and record appropriate short term gains and losses. Net short-term capital gains are typically considered ordinary income and not long-term capital gains rates.

9. How are capital losses deducted from capital gains?

Under the IRS rules, short- and long-term gains and losses are typically netted. Losses that are limited and deductible against other income are subject to a limit, and losses that exceed that limit may be carried forward.

10. Do I have to pay capital gains tax if I reinvest the money?

There is no general rule that a sale of an investment that loses money is a taxable sale that doesn’t result in a capital gains tax. Some transactions and tax-advantaged transactions may have their own rules.

11. Does my state charge capital gains tax in addition to federal tax?

Possibly. Some taxpayers could be liable to state income tax as well as capital gains tax at the federal level. Please review your state and transaction rules.

12. How do I report capital gains on my federal tax return?

The following table summarizes the common methods of reporting capital-asset transactions: Brokers can also send a Form 1099-B that details information necessary to fill out the return.

Conclusion: Calculating Capital Gains Tax Accurately

The basic formula for calculating capital gains tax is: Capital gain or loss equals amount realized minus adjusted basis. But there are some extra steps to be taken to calculate the actual tax.

The length of time that you hold an investment for determines whether the gain is short term or long term, and taxable income and filing status will help determine the applicable federal tax rate. Capital losses and carryovers may lower taxable gains and taxes at every level may have other requirements, including the Net Investment Income Tax (NIIT).

Stock, real estate, and investments are particularly important items that need to have accurate cost basis records. Prior to filing, please check relevant information on Form 1099-B and report relevant transactions on Form 8949 and Schedule D.

Capital Gains Tax Rates, Capital Gains Tax Brackets and other capital gains tax laws may vary from one tax year to the next, so always apply current IRS guidelines to perform the calculation. If you are dealing with a complex transaction, such as real estate, inherited property, depreciation or significant investment gains, it is advisable to work with a qualified tax professional to make sure you report and calculate your transaction correctly.