The Handy Calculators logoTheHandyCalculators

    Capital Gains Tax Calculator

    Estimate capital gains tax on stocks or property with basis, holding period, recapture, and state tax.

    Autosave on
    Total gain
    $120,000
    Long-term
    Total tax owed
    $18,000
    Federal capital gains tax
    $18,000
    Depreciation recapture tax
    $0
    State tax
    $0
    Adjusted basis
    $300,000
    Effective rate on gain
    15.0%
    Net cash after tax
    $402,000

    Capital gains tax is what you owe on the profit when you sell an asset for more than you paid for it — a stock, a mutual fund, a rental property, a business interest, or a second home. The rate depends almost entirely on one thing: how long you held it. Sell within a year and the gain is taxed as ordinary income. Hold longer and it qualifies for the preferential long-term rate. This calculator estimates your gain, separates any depreciation recapture on real estate, and shows the federal tax, state tax, and net cash you actually keep.

    How capital gains are calculated

    The gain is the amount realized minus your adjusted basis. Amount realized is the sale price less selling costs — commissions, transfer taxes, title fees, and closing costs on real estate; commissions and fees on securities. Adjusted basis starts with what you paid, then adds capital improvements and certain acquisition costs, and subtracts any depreciation you claimed.

    Basis is the single most under-tracked number in personal finance. Every capital improvement you made to a property — a new roof, an addition, a full kitchen remodel — raises basis and lowers the taxable gain dollar for dollar. Ordinary repairs and maintenance do not. Keeping receipts for improvements over the years is worth real money at sale.

    Selling costs are not deductions in the usual sense; they reduce the amount realized, which produces the same outcome. On a real estate sale, agent commissions alone commonly run 5% to 6% of the price, so including them changes the answer materially.

    If the result is negative you have a capital loss. Losses offset capital gains dollar for dollar, and a net loss can offset up to $3,000 of ordinary income per year, with the remainder carried forward indefinitely.

    Short-term versus long-term: the holding period

    An asset held more than one year produces a long-term capital gain, taxed at preferential federal rates of 0%, 15%, or 20% depending on your taxable income and filing status. An asset held one year or less produces a short-term gain, taxed at your ordinary income rate, which can be roughly double.

    The holding period starts the day after you acquire the asset and ends on the day you dispose of it. Waiting a few extra weeks to cross the one-year line can be one of the highest-value decisions available to an investor — on a $100,000 gain, the difference between a 32% ordinary rate and a 15% long-term rate is $17,000.

    High earners may also owe the 3.8% net investment income tax on top of the capital gains rate once modified adjusted gross income exceeds a threshold that depends on filing status. Add it to your federal rate input if it applies to you.

    Some assets have their own rules. Collectibles are taxed at up to 28%. Section 1202 qualified small business stock can be excluded entirely under specific conditions. Cryptocurrency is treated as property and follows the standard short- and long-term rules.

    Real estate: exclusions, recapture, and 1031 exchanges

    The primary residence exclusion is the largest tax break most households will ever use. If you owned and lived in the home as your main residence for at least two of the five years before the sale, you may exclude up to $250,000 of gain if single and $500,000 if married filing jointly. The two years do not need to be consecutive, and the exclusion is generally available once every two years.

    The exclusion applies to the gain, not the sale price, and it applies before any tax is calculated. A couple with a $400,000 gain on a qualifying primary residence typically owes nothing federally. Partial exclusions are available for sales driven by a work relocation, health reasons, or certain unforeseen circumstances.

    Investment property is different. Depreciation you claimed — or were entitled to claim — while renting the property must be recaptured at sale, taxed at up to 25% rather than the lower long-term capital gains rate. This surprises many landlords, because the recapture is owed even if the property barely appreciated. Enter your accumulated depreciation so the calculator separates it from the rest of the gain.

    A 1031 like-kind exchange lets an investor defer the entire tax bill by rolling the proceeds into another investment property, subject to strict timelines: 45 days to identify replacement property and 180 days to close. It is a deferral, not forgiveness — the deferred gain follows into the new property's basis. Primary residences do not qualify.

    Heirs generally receive a stepped-up basis to the fair market value at the date of death, which erases the built-in gain entirely. That single provision is why some long-held, highly appreciated property is best not sold during the owner's lifetime.

    Legal ways to reduce the bill

    Hold for more than a year whenever you have the choice. It is the simplest and largest lever available, and it requires nothing but patience.

    Harvest losses. Selling losing positions to offset gains in the same tax year directly reduces taxable gain. Watch the wash sale rule, which disallows the loss if you buy the same or a substantially identical security within thirty days before or after the sale.

    Time the sale into a low-income year. The 0% long-term capital gains bracket is real: a household with modest taxable income can realize meaningful long-term gains at no federal tax at all. A gap year, a sabbatical, or early retirement before Social Security begins is often the cheapest window to realize gains you have been deferring.

    Use tax-advantaged accounts. Gains inside an IRA, 401(k), or HSA are not taxed as they are realized, so rebalancing inside those accounts costs nothing. Keep your highest-turnover strategies there and your most tax-efficient holdings in taxable accounts.

    Consider donating appreciated assets. Giving long-held appreciated stock directly to a qualified charity generally avoids the capital gains tax entirely while allowing a deduction for full fair market value if you itemize — better on both counts than selling and donating cash.

    Installment sales spread the gain across multiple tax years, which can keep you in a lower bracket. This calculator estimates the tax on a single-year sale; confirm multi-year strategies with a CPA.

    State taxes and payment timing

    Most states tax capital gains as ordinary income, with no preferential rate. A few states have no income tax at all, and a small number apply a distinct rate or surtax to investment income. State treatment can move the total bill by ten percentage points or more, so enter your state rate rather than assuming federal-only.

    State residency at the time of sale generally controls, but real estate is usually taxed by the state where the property sits regardless of where you live. Selling an out-of-state rental commonly means filing a non-resident return in that state, with a credit against your home state's tax.

    Capital gains are not withheld the way wages are. A large gain can create an underpayment penalty even if you pay in full by April. Make an estimated tax payment in the quarter of the sale, or increase withholding elsewhere, to satisfy the safe harbor.

    The safe harbor is generally met by paying 100% of last year's tax liability, or 110% if your prior-year adjusted gross income was high. Meeting it protects you from penalties even if this year's bill turns out to be much larger.

    How to use this calculator

    Enter the sale price and your original purchase price. Add capital improvements separately so they raise your basis, and enter selling costs — commissions, closing costs, and transfer taxes — so they reduce the amount realized.

    Set the holding period in months. Anything over twelve is treated as long term. Enter the federal rate that applies to you: 0%, 15%, or 20% for long-term gains, or your marginal ordinary rate for short-term gains, plus 3.8% if the net investment income tax applies.

    For a rental or other depreciated property, enter accumulated depreciation. The calculator reduces basis by that amount and taxes it separately at the 25% recapture rate, which is how the IRS treats it.

    Enter your state rate if your state taxes capital gains. Leave it at zero for a no-income-tax state.

    The results show the total gain, the split between recapture and capital gain, each tax component, the effective rate on your gain, and the net cash you keep after tax. This is a planning estimate, not tax advice — the primary residence exclusion, 1031 exchanges, loss carryforwards, and bracket-straddling gains all need a professional review before you rely on a number.

    Frequently asked questions

    How is capital gains tax calculated?

    Subtract your adjusted basis — purchase price plus improvements minus depreciation — from the sale price less selling costs. The resulting gain is taxed at the long-term rate if you held the asset more than a year, or your ordinary income rate if not.

    What are the long-term capital gains tax rates?

    Federal long-term rates are 0%, 15%, or 20% depending on taxable income and filing status. High earners may add the 3.8% net investment income tax, and most states tax the gain as ordinary income on top.

    How long do I have to hold an asset for the lower rate?

    More than one year. The clock starts the day after acquisition. Selling at day 366 instead of day 365 can cut the federal tax rate roughly in half on the same gain.

    Do I pay capital gains tax when I sell my home?

    Often not. If you owned and lived in the home for at least two of the last five years, you can exclude up to $250,000 of gain if single or $500,000 if married filing jointly. Gain above the exclusion is taxable.

    What is depreciation recapture?

    When you sell a rental property, the depreciation you claimed is recaptured and taxed at up to 25%, separate from the capital gains rate. It applies even to depreciation you were entitled to claim but did not.

    How do I lower my capital gains tax?

    Hold more than a year, harvest offsetting losses, realize gains in a low-income year to use the 0% bracket, keep high-turnover strategies inside tax-advantaged accounts, and donate appreciated assets instead of cash.

    What is tax-loss harvesting?

    Selling losing positions to offset realized gains in the same year. Net losses can offset up to $3,000 of ordinary income annually with the rest carried forward. The wash sale rule disallows the loss if you repurchase within 30 days.

    Does a 1031 exchange eliminate capital gains tax?

    No, it defers it. Rolling proceeds from one investment property into another within the 45-day identification and 180-day closing windows postpones the tax; the deferred gain carries into the new property's basis. Primary residences do not qualify.

    What counts as a capital improvement?

    Work that adds value or extends the life of the property — an addition, new roof, HVAC replacement, or full remodel. Ordinary repairs and maintenance do not add to basis, so keep receipts separated.

    How are cryptocurrency gains taxed?

    Crypto is treated as property, so the same short- and long-term capital gains rules apply. Every sale, trade, or purchase using crypto is a taxable disposition that must be reported.

    Do I owe state capital gains tax?

    Most states tax capital gains as ordinary income. A handful have no income tax at all. Real estate is generally taxed by the state where the property is located, which may require a non-resident return.

    When do I have to pay the tax on a large gain?

    Capital gains are not withheld, so a large gain usually calls for an estimated tax payment in the quarter of the sale. Meeting the safe harbor — 100% of last year's tax, or 110% for high earners — avoids underpayment penalties.

    What happens to capital gains when someone inherits an asset?

    Heirs generally receive a stepped-up basis equal to the fair market value at the date of death, which eliminates the built-in gain accumulated during the owner's lifetime.

    Is this calculator a substitute for tax advice?

    No. It is a planning estimate based on the figures you enter. Exclusions, carryforwards, bracket-straddling gains, and state rules all affect the real number — confirm with a CPA before acting on it.

    By Larius software engineer, NC real estate broker & CRE/business appraiserLast reviewed: August 2026Reviewed by the Handy Calculators editorial teamHow we build calculators

    More in Retirement Accounts & Investing

    Compare tax-advantaged growth: Roth IRA projections, 401(k) balance with employer match, compounding, ROI, and margin math.

    See hub →
    Browse all Money →