TaxGainsCalc

Capital Gains Tax Calculator

Complete Tax Guide 2025-2026

How to Calculate Capital Gains Tax

A complete step-by-step guide to calculating capital gains tax on stocks, real estate, cryptocurrency, and other investments. Includes worked examples, IRS forms, and tax strategies.

Step-by-Step Guide
Worked Examples
IRS Forms Explained
Free Calculator Included

Understanding Capital Gains Tax Calculation

Calculating capital gains tax may seem complex, but it follows a logical step-by-step process that anyone can master. Whether you are selling stocks, real estate, cryptocurrency, or other capital assets, the fundamental calculation method remains the same: determine your gain or loss, classify it as short-term or long-term, and apply the appropriate tax rate. This guide walks you through every step with clear explanations and worked examples for different asset types.

The capital gains tax calculation begins with two key numbers: your adjusted cost basis and your net sale proceeds. The difference between these figures determines your capital gain or loss. Your cost basis is what you paid for the asset plus certain acquisition costs. Your net proceeds are what you received from the sale minus selling expenses. The accuracy of your calculation depends on properly identifying both of these figures.

Once you have determined your gain, you must classify it based on how long you held the asset. Assets held for one year or less produce short-term gains taxed at ordinary income rates (10% to 37%). Assets held for more than one year produce long-term gains taxed at preferential rates (0%, 15%, or 20%). Additional taxes such as the 3.8% Net Investment Income Tax may also apply depending on your income level. This guide covers all these elements in detail.

Step 1: Determine Your Adjusted Cost Basis

Your adjusted cost basis is the total amount you have invested in an asset, including the purchase price and certain additional costs. A higher cost basis means a lower taxable gain, so it is important to include every eligible expense. The exact components of your cost basis depend on the type of asset you are selling.

Cost Basis for Stocks
  • Purchase price per share
  • Brokerage commissions at purchase
  • Reinvested dividends (for mutual funds)
  • Stock split adjustments (per-share basis only)
  • Corporate actions (spin-offs, mergers)
Cost Basis for Real Estate
  • Purchase price of the property
  • Closing costs (title insurance, legal fees)
  • Capital improvements (additions, renovations)
  • Special assessments for local improvements
  • Minus depreciation claimed (rental property)

For inherited assets, the cost basis is stepped up to the fair market value on the date of the original owner's death (or the alternate valuation date, six months later). This stepped-up basis can dramatically reduce or eliminate capital gains tax on inherited property. For gifted assets, your basis generally carries over from the donor, known as carryover basis, which means you take the donor's original cost basis.

Keeping thorough records is essential for establishing your cost basis. Retain all purchase confirmations, closing documents, receipts for improvements, and statements showing reinvested dividends. The IRS requires you to substantiate your cost basis with documentation, and failing to do so can result in the IRS assuming a basis of zero, which would make the entire sale proceeds taxable as gain.

Step 2: Calculate Your Net Sale Proceeds

Your net sale proceeds are the actual amount you receive from the sale after subtracting all selling-related expenses. This is not the same as the gross sale price listed on your contract. Deductible selling expenses reduce your net proceeds and therefore reduce your taxable gain. For stocks, the primary selling expense is the brokerage commission. For real estate, selling expenses are significantly more numerous and can include a substantial portion of the sale price.

Common deductible selling expenses for real estate include real estate agent commissions (typically 5-6% of the sale price), transfer taxes, attorney and legal fees, title insurance for the buyer, escrow fees, home warranty costs, and advertising expenses. For stocks, deduct brokerage commissions from your gross proceeds. These commissions are sometimes already factored into the net proceeds shown on your brokerage statement, so verify whether the reported amount is gross or net.

The formula is straightforward: Net Proceeds = Gross Sale Price - Selling Expenses. Always use your net proceeds, not your gross sale price, when calculating your capital gain. Using the gross sale price would overstate your gain and result in paying more tax than you actually owe. For cryptocurrency, subtract any transaction fees or mining costs from your proceeds.

Step 3: Calculate Your Capital Gain or Loss

Once you have your adjusted cost basis and net proceeds, calculating your capital gain or loss is a simple subtraction. If your net proceeds exceed your cost basis, you have a capital gain. If your cost basis exceeds your net proceeds, you have a capital loss. Capital losses are valuable because they can offset capital gains and potentially reduce your ordinary income tax as well.

The Capital Gains Formula

Capital Gain = Net Sale Proceeds - Adjusted Cost Basis

Capital Gains Tax = Capital Gain x Applicable Tax Rate

If the result is negative, you have a capital loss which can offset other gains.

When you have multiple capital gains and losses throughout the year, you first net all short-term gains and losses together, then net all long-term gains and losses together. If you have a net short-term gain and a net long-term gain, they are each taxed at their respective rates. If you have a net gain in one category and a net loss in the other, the loss offsets the gain. Any remaining net loss can offset up to $3,000 of ordinary income, with any excess carried forward.

For example, if you have $25,000 in short-term gains, $10,000 in short-term losses, $40,000 in long-term gains, and $15,000 in long-term losses, your net short-term gain is $15,000 and your net long-term gain is $25,000. The $15,000 short-term gain is taxed at ordinary income rates, and the $25,000 long-term gain is taxed at preferential rates. Our free capital gains tax calculator handles all these netting calculations automatically.

Step 4: Determine Your Holding Period

Short-Term: 1 Year or Less

Assets held for one year or less are taxed at your ordinary income tax rate. The holding period begins the day after you acquire the asset and ends on the day you sell it. Common for day traders and active investors.

Ordinary Income Tax Rates:

  • 10% bracket: $0 - $11,925 (single)
  • 12% bracket: $11,926 - $48,475
  • 22% bracket: $48,476 - $103,350
  • 24% bracket: $103,351 - $197,300
  • 32% bracket: $197,301 - $250,525
  • 35% bracket: $250,526 - $626,350
  • 37% bracket: Over $626,350
Long-Term: More Than 1 Year

Assets held for more than one year benefit from preferential tax rates. This is the single most important factor in capital gains tax planning. Waiting just one day past the one-year mark can save tens of thousands in taxes.

Long-Term Capital Gains Rates:

  • 0% rate: Up to $48,350 (single)
  • 15% rate: $48,351 - $533,400
  • 20% rate: Over $533,400
  • + 3.8% NIIT for income over $200,000

The IRS holding period rule is precise: the clock starts the day after the purchase date (the acquisition date) and ends on the disposition date (the sale date). If you buy shares on January 15, 2024, and sell them on January 15, 2025, the holding period is exactly 365 days, which qualifies as long-term. However, if you buy on January 15, 2024, and sell on January 14, 2025, you fall short by one day and the gain is short-term. Many investors use calendar reminders to avoid missing the long-term threshold by a single day.

Step 5: Apply the Appropriate Tax Rate

The final step is applying the correct tax rate to your calculated gain. For long-term gains, your rate depends on your taxable income after adding the capital gain to your ordinary income. The IRS uses a stacking method where your ordinary income fills the lower brackets first, and your long-term capital gains are stacked on top to determine which rate applies. This means part of your gain could be taxed at 0%, part at 15%, and part at 20% if your gain spans multiple brackets.

Do Not Forget the NIIT

High-income taxpayers may owe an additional 3.8% Net Investment Income Tax. This applies when your modified adjusted gross income exceeds:

  • $200,000 for Single filers
  • $250,000 for Married Filing Jointly
  • $125,000 for Married Filing Separately
  • $200,000 for Head of Household

The NIIT applies to the lesser of your net investment income or the amount your MAGI exceeds the threshold.

For the most accurate calculation, use our free capital gains tax calculator, which handles the stacking calculation, accounts for the NIIT, and applies the correct rate to each portion of your gain. It also allows you to factor in your filing status, state tax rate, and other variables for a comprehensive tax estimate.

Complete Calculation Examples

Below are fully worked examples showing the complete capital gains tax calculation for stocks, real estate, and cryptocurrency.

Example 1: Stock Sale - $25,000 Long-Term Gain

Scenario: Single filer with $75,000 in salary income sold stock for a long-term gain.

Purchase: 200 shares of ABC stock at $50/share + $10 commission = $10,010

Sale: 200 shares sold at $175/share - $10 commission = $34,990

Capital gain: $34,990 - $10,010 = $24,980

Holding period: 3 years (long-term)

Tax calculation:

Ordinary income: $75,000

Total taxable income: $75,000 + $24,980 = $99,980

Long-term gain up to $48,350 threshold: $0 (fills 0% bracket gap from $48,351-$99,980)

Long-term gain at 15%: $24,980 x 15% = $3,747

NIIT: Not applicable (MAGI under $200,000)

Total federal tax on gain: $3,747 (effective rate: 15%)

Example 2: Home Sale - $350,000 Gain with Section 121 Exclusion

Scenario: Married couple filing jointly selling their primary residence of 8 years.

Purchase price: $300,000

Closing costs at purchase: $8,000

Capital improvements (new kitchen, roof): $60,000

Adjusted cost basis: $300,000 + $8,000 + $60,000 = $368,000

Sale price: $750,000

Selling costs (6% agent commission + fees): $48,000

Net proceeds: $750,000 - $48,000 = $702,000

Capital gain: $702,000 - $368,000 = $334,000

Section 121 exclusion (MFJ): -$500,000

Taxable gain: $0 (fully excluded)

Federal tax on gain: $0

Example 3: Cryptocurrency Sale - $45,000 Short-Term Gain

Scenario: Single filer with $95,000 in salary income. Bought Bitcoin, held 8 months, then sold.

Purchase: 1.5 BTC at $35,000/BTC + $50 fee = $52,550

Sale: 1.5 BTC at $65,000/BTC - $50 fee = $97,450

Capital gain: $97,450 - $52,550 = $44,900

Holding period: 8 months (short-term)

Tax calculation:

Total taxable income: $95,000 + $44,900 = $139,900

Tax bracket (single): 24% (for income $103,351 - $197,300)

Short-term capital gains tax: $44,900 x 24% = $10,776

NIIT: Not applicable (MAGI under $200,000)

Total federal tax on gain: $10,776 (effective rate: 24%)

Note: If held for 12+ months, the same gain at 15% long-term rate would be only $6,735, saving $4,041.

Example 4: Investment Property - $200,000 Gain with Depreciation Recapture

Scenario: Single filer with $85,000 income selling a rental property held for 10 years.

Purchase price: $350,000 (building value: $280,000)

Annual depreciation: $280,000 / 27.5 = $10,182/year

Total depreciation over 10 years: $101,818

Adjusted cost basis: $350,000 - $101,818 = $248,182

Sale price: $550,000 - $33,000 selling costs = $517,000 net

Total capital gain: $517,000 - $248,182 = $268,818

Depreciation recapture (up to 25%): $101,818 x 25% = $25,455

Remaining gain at 15% (long-term): $166,999 x 15% = $25,050

NIIT: Not applicable (MAGI under $200,000)

Total federal tax on gain: $50,505

IRS Forms Needed for Reporting Capital Gains

Reporting capital gains to the IRS requires several forms, each serving a specific purpose in the reporting chain. Your broker provides Form 1099-B with details of all your sale transactions, which serves as the starting point for completing your capital gains reporting. Below is a summary of the key forms you need to understand.

Form 1099-B: Proceeds from Broker and Barter Exchange Transactions

Your broker sends this form each year reporting all your securities sales. It includes the date acquired, date sold, proceeds, cost basis (if reported to the IRS), and whether the gain is short-term or long-term. This form is typically available by mid-February and can be imported directly into most tax preparation software.

Form 8949: Sales and Other Dispositions of Capital Assets

This is where you report each individual capital asset transaction. You list the description of the property, date acquired, date sold, proceeds, cost basis, and the resulting gain or loss for each sale. Transactions are separated into short-term and long-term categories. Each category has boxes for transactions with and without basis reported to the IRS on Form 1099-B.

Schedule D: Capital Gains and Losses

Schedule D summarizes the totals from Form 8949 and calculates your net capital gain or loss for the year. It separates short-term and long-term totals, nets gains and losses, applies the $3,000 ordinary income loss limitation, and calculates the amount to carry forward to future years. The net capital gain from Schedule D transfers to your Form 1040.

Form 4797: Sales of Business Property

Used when selling business property, including depreciation recapture from rental real estate. This form separates Section 1245 property (personal property and certain depreciable real property) from Section 1250 property (real property). Depreciation recapture is calculated here and flows to Schedule D.

Form 8824: Like-Kind Exchanges (1031 Exchanges)

If you completed a 1031 exchange of real estate, you must file Form 8824 to report the details of the exchange. This form reports the relinquished property, the replacement property, the realized gain, and the deferred gain. Failure to file this form can result in the IRS treating the transaction as a taxable sale.

Capital Gains Tax Quick Reference Table

2025-2026 Federal Capital Gains Tax Rates at a Glance
Tax RateTypeSingle Income RangeMFJ Income RangeHolding Period
10-37%Short-termAll incomesAll incomes1 year or less
0%Long-termUp to $48,350Up to $96,700More than 1 year
15%Long-term$48,351 - $533,400$96,701 - $600,050More than 1 year
20%Long-termOver $533,400Over $600,050More than 1 year
+3.8%NIIT surtaxMAGI over $200,000MAGI over $250,000All gains

Income ranges shown are approximate thresholds for 2025. Consult the IRS for the most current brackets.

Capital Gains Tax Calculation FAQ

What is the formula for calculating capital gains tax?

The basic capital gains tax formula is: Capital Gain = Net Sale Proceeds - Adjusted Cost Basis. The tax owed is then: Capital Gains Tax = Capital Gain x Applicable Tax Rate. Your net sale proceeds are the sale price minus selling expenses (commissions, fees). Your adjusted cost basis is the purchase price plus acquisition costs minus depreciation (if applicable). The applicable tax rate depends on your holding period (short-term = ordinary income rates; long-term = 0%, 15%, or 20%) and your total taxable income for the year.

How do I determine my cost basis for inherited property?

When you inherit property, your cost basis is generally stepped up (or stepped down) to the fair market value of the property on the date of the deceased person's death. This is known as the stepped-up basis rule. For example, if your parent bought a stock for $10,000 and it was worth $50,000 when they passed away, your basis would be $50,000, not $10,000. If you later sell the stock for $55,000, your capital gain would only be $5,000. This rule can eliminate years of accumulated appreciation from taxation.

What is the difference between realized and unrealized capital gains?

A realized capital gain occurs when you actually sell an asset for a profit. Only realized gains are taxable. An unrealized capital gain (also called a paper gain) is the increase in value of an asset you still own. For example, if you bought a stock for $5,000 and it is now worth $8,000 but you have not sold it, you have a $3,000 unrealized gain. Unrealized gains are not taxable. The tax is only triggered when you sell the asset and realize the gain.

How do I calculate capital gains tax on cryptocurrency?

Cryptocurrency is treated as property by the IRS, so capital gains tax applies when you sell, trade, or use crypto at a gain. The calculation is the same as for stocks: subtract your cost basis (what you paid for the crypto plus fees) from your proceeds. Each transaction is a separate taxable event, including trading one cryptocurrency for another. If you buy Bitcoin for $20,000 and later trade it for Ethereum worth $35,000, you have a $15,000 capital gain. Use specific identification where possible to optimize your cost basis across multiple purchases.

Can capital losses offset ordinary income?

Capital losses can offset capital gains dollar-for-dollar, but the treatment of excess losses is limited. If your total capital losses exceed your total capital gains for the year, you can deduct up to $3,000 ($1,500 if married filing separately) of the net capital loss against your ordinary income. Any unused losses carry forward to future years indefinitely until they are fully utilized. This makes tax-loss harvesting a powerful strategy for reducing your tax bill by intentionally selling investments at a loss to offset gains.

What IRS forms do I need to report capital gains?

Reporting capital gains typically requires two forms. Form 8949 is where you report each individual capital asset transaction, including the date acquired, date sold, proceeds, cost basis, and gain or loss for each transaction. Schedule D summarizes all the transactions from Form 8949 and calculates your total net capital gain or loss. The net figure from Schedule D then transfers to Form 1040. Your broker provides Form 1099-B with transaction details, which you use to complete Form 8949. For real estate sales of business property, you may also need Form 4797.

Does the Net Investment Income Tax (NIIT) apply to all capital gains?

The 3.8% NIIT applies to net investment income for taxpayers whose modified adjusted gross income exceeds $200,000 for single filers, $250,000 for married filing jointly, or $125,000 for married filing separately. The tax applies to the lesser of your net investment income or the amount by which your MAGI exceeds the threshold. Net investment income includes capital gains, dividends, interest, rental income, and royalty income. Not all taxpayers are subject to the NIIT, but those with higher incomes may find their effective capital gains tax rate increased by this additional surcharge.

How does capital gains tax work with mutual fund distributions?

Mutual funds distribute capital gains to shareholders when the fund manager sells securities within the fund at a profit. These distributions are taxable in the year received, even if you reinvest them. The distributions are reported on Form 1099-DIV and can be classified as short-term or long-term. When you sell your mutual fund shares, you also calculate your own gain or loss based on your adjusted cost basis, which includes reinvested distributions. This means you are taxed twice: once on fund distributions and again on your own sale gains, so tracking your basis carefully is essential.

How do state taxes affect my total capital gains tax bill?

Most states tax capital gains as part of your state income tax. Some states treat capital gains the same as ordinary income, while others offer partial deductions or lower rates. States with no income tax, such as Florida, Texas, Nevada, Washington, Wyoming, South Dakota, Alaska, Tennessee, and New Hampshire, do not impose state capital gains tax. In high-tax states like California (up to 13.3%) and New York (up to 10.9%), state taxes can add substantially to your total capital gains tax bill. Always factor in both federal and state taxes when estimating your total liability.

How do capital gains affect my tax bracket?

Capital gains are included in your taxable income when determining which tax bracket you fall into. However, long-term capital gains are taxed at their own preferential rates (0%, 15%, or 20%) rather than ordinary income rates. Your taxable income is calculated by adding your ordinary income and your net capital gains together, then applying the appropriate rate to each type of income. Long-term capital gains are stacked on top of your ordinary income to determine which capital gains rate applies. For example, if your ordinary income is $40,000 as a single filer, and you have $30,000 in long-term capital gains, part of your gains would be taxed at 0% (up to $48,350) and the remainder at 15%.

Skip the Manual Math - Use Our Free Calculator

Our capital gains tax calculator handles all the steps automatically: cost basis, holding period, tax rate stacking, NIIT, and state taxes. Get your estimate in seconds.