Finance & Economics · Taxation · Tax Planning
Capital Gains Tax Calculator
Calculates short-term and long-term capital gains tax owed based on purchase price, sale price, holding period, and filing status.
Calculator
Formula
P_{sale} is the net sale proceeds; P_{cost} is the adjusted cost basis (purchase price plus fees); r_{CGT} is the applicable capital gains tax rate, which depends on the taxpayer's filing status, taxable income, and holding period. Gains on assets held 12 months or less are short-term and taxed as ordinary income. Gains on assets held more than 12 months are long-term and subject to preferential rates of 0%, 15%, or 20%.
Source: IRS Publication 550 — Investment Income and Expenses; IRC §1(h); IRS Revenue Procedure 2023-34 (2024 inflation-adjusted brackets).
How it works
When you sell a capital asset for more than you paid, the profit is called a capital gain. The Internal Revenue Service taxes this gain at one of two rate structures depending on how long you held the asset. Assets held for 12 months or less produce a short-term capital gain, which is taxed as ordinary income using the same progressive brackets that apply to your wages and salary. Assets held for more than 12 months produce a long-term capital gain, which is taxed at the preferential rates of 0%, 15%, or 20% depending on your taxable income and filing status.
The core formula is straightforward: Capital Gain = Sale Proceeds − Cost Basis. The cost basis is your original purchase price plus any transaction costs, commissions, or improvements (in the case of real estate). The applicable tax rate is then multiplied by the gain to determine the gross tax liability. For short-term gains, this calculator uses your ordinary taxable income plus the gain to determine which marginal bracket applies. For long-term gains, only your ordinary income (before the gain) is used to determine the bracket, consistent with IRS stacking rules.
Investors, traders, and financial planners use capital gains tax calculations for a wide range of decisions: deciding whether to hold an asset past the 12-month threshold, executing tax-loss harvesting strategies to offset gains, structuring installment sales, or estimating quarterly estimated tax payments. Real estate investors frequently use this tool to evaluate whether a 1031 like-kind exchange is economically worthwhile compared to paying CGT outright.
Worked example
Suppose you are a single filer with $75,000 of ordinary taxable income. You purchased 100 shares of a stock for $10,000 (including fees) and sold them for $18,000 (net of fees). You held the shares for 18 months, making this a long-term gain.
Step 1 — Calculate the capital gain:
Capital Gain = $18,000 − $10,000 = $8,000
Step 2 — Determine the applicable long-term rate:
For a single filer in 2024, the 0% rate applies up to $47,025 of ordinary income, and the 15% rate applies from $47,025 to $518,900. Your ordinary income of $75,000 already exceeds the 0% threshold, so the entire $8,000 gain is taxed at 15%.
Step 3 — Calculate tax owed:
Tax Owed = $8,000 × 0.15 = $1,200
Step 4 — Calculate net after-tax profit:
Net Profit = $8,000 − $1,200 = $6,800
Had you sold after only 10 months instead (short-term), your $8,000 gain would be added to your $75,000 income for a combined $83,000. This places the gain in the 22% marginal bracket, producing a tax bill of $1,760 — an additional $560 compared to the long-term scenario, a clear incentive to hold past the 12-month mark.
Limitations & notes
This calculator estimates federal capital gains tax only and does not include state or local income taxes, which can range from 0% (Florida, Texas, Nevada) to over 13% (California). It also excludes the 3.8% Net Investment Income Tax (NIIT) that applies to high earners with modified adjusted gross income above $200,000 (single) or $250,000 (married filing jointly). The calculator does not account for the alternative minimum tax (AMT), capital loss carryforwards, wash-sale rule disallowances, or the depreciation recapture rules that apply to real estate under IRC §1250. Cryptocurrency tax treatment follows the same capital gains principles but may involve additional complexity around cost basis accounting methods (FIFO, LIFO, specific identification). Always consult a qualified tax professional for personalized advice before making tax-motivated financial decisions.
Frequently asked questions
What is the difference between short-term and long-term capital gains tax?
Short-term capital gains apply to assets held for 12 months or less and are taxed as ordinary income at rates ranging from 10% to 37% depending on your total income. Long-term capital gains apply to assets held more than 12 months and benefit from preferential rates of 0%, 15%, or 20%. Holding an asset just one day past the 12-month mark can substantially reduce your tax bill.
What counts as cost basis for capital gains tax purposes?
Your cost basis is generally what you paid for the asset, including commissions and transaction fees. For inherited assets, basis is typically stepped up to the fair market value at the date of death. For gifted assets, you generally inherit the original donor's basis. For real estate, capital improvements increase your basis while depreciation deductions reduce it.
Do I owe capital gains tax if I reinvest the proceeds?
Yes. Under U.S. federal tax law, a capital gain is recognized the moment you sell the asset, regardless of what you do with the proceeds. The only common exception is a 1031 like-kind exchange for investment real estate, which allows you to defer — but not eliminate — the gain by rolling proceeds into a qualifying replacement property.
How does the Net Investment Income Tax (NIIT) affect capital gains?
High-income taxpayers may owe an additional 3.8% NIIT on net investment income, including capital gains. This applies if your modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married filing jointly. This calculator does not include the NIIT, so your actual federal liability could be up to 23.8% on long-term gains at the top bracket.
Can capital losses offset capital gains?
Yes. Capital losses can be used to offset capital gains dollar-for-dollar in the same tax year. If your losses exceed your gains, you can deduct up to $3,000 of net losses against ordinary income annually, with any remaining losses carried forward to future tax years. This is the basis of the tax-loss harvesting strategy used by many investors and wealth managers.
Last updated: 2025-01-15 · Formula verified against primary sources.