Capital Gains Tax Calculator
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.
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.
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.
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.
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.
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.
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.
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:
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:
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.
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.
High-income taxpayers may owe an additional 3.8% Net Investment Income Tax. This applies when your modified adjusted gross income exceeds:
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.
Below are fully worked examples showing the complete capital gains tax calculation for stocks, real estate, and cryptocurrency.
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%)
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
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.
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
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.
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.
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 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.
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.
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.
| Tax Rate | Type | Single Income Range | MFJ Income Range | Holding Period |
|---|---|---|---|---|
| 10-37% | Short-term | All incomes | All incomes | 1 year or less |
| 0% | Long-term | Up to $48,350 | Up to $96,700 | More than 1 year |
| 15% | Long-term | $48,351 - $533,400 | $96,701 - $600,050 | More than 1 year |
| 20% | Long-term | Over $533,400 | Over $600,050 | More than 1 year |
| +3.8% | NIIT surtax | MAGI over $200,000 | MAGI over $250,000 | All gains |
Income ranges shown are approximate thresholds for 2025. Consult the IRS for the most current brackets.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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%.