To determine your capital gain, subtract your adjusted basis (what you paid, plus certain costs) from the sale price of the asset. The result is your gain or loss. From there, two factors shape your tax bill: how long you held the asset and your taxable income for the year. Here’s how to work through each step.
The Basic Capital Gains Formula
Every capital gains calculation starts with three numbers:
- Sale price: The total amount you received when you sold or disposed of the asset.
- Cost basis: What you originally paid for the asset, including the purchase price, sales tax, commissions, and recording or transfer fees.
- Adjustments: Any increases or decreases to your basis after the original purchase.
Your adjusted basis equals your original cost basis plus improvements minus items like depreciation or insurance reimbursements for losses. Once you have that number, the math is straightforward: sale price minus adjusted basis equals your capital gain (or loss, if the number is negative).
For example, if you bought stock for $10,000 and paid a $50 commission, your cost basis is $10,050. If you later sold that stock for $14,000, your capital gain is $3,950. For real estate, the same logic applies but the adjustments tend to be larger. A $20,000 kitchen renovation increases your basis, while depreciation you claimed on a rental property decreases it.
Short-Term vs. Long-Term Holding Periods
How long you held the asset before selling determines whether your gain is short-term or long-term, and the tax difference is significant. If you held the asset for one year or less, the gain is short-term and taxed at your ordinary income rate, which can be as high as 37%. If you held it for more than one year, the gain is long-term and qualifies for lower tax rates.
The IRS counts your holding period starting the day after you acquired the asset, up to and including the day you sold it. So if you bought shares on March 1, 2025, you would need to hold them until at least March 2, 2026, for any gain to qualify as long-term. Selling on March 1, 2026, would still be short-term by one day.
Long-Term Capital Gains Tax Rates for 2026
Long-term gains are taxed at 0%, 15%, or 20% depending on your taxable income and filing status. For 2026, the thresholds are:
- Single filers: 0% on taxable income up to $49,450, 15% from $49,451 through $545,500, and 20% above $545,500.
- Married filing jointly: 0% up to $98,900, 15% from $98,901 through $613,700, and 20% above $613,700.
- Head of household: 0% up to $66,200, 15% from $66,201 through $579,600, and 20% above $579,600.
These thresholds are based on your total taxable income, not just your capital gains. So if you’re a single filer with $40,000 in wages and a $15,000 long-term gain, part of that gain falls in the 0% bracket and the rest gets taxed at 15%. Your taxable income determines which rate applies to each dollar of gain.
How to Identify Your Cost Basis When You Own Multiple Lots
If you bought shares of the same stock or fund at different times and different prices, you need a method to determine which shares you’re selling. The method you choose directly affects the size of your gain and the tax you owe.
First in, first out (FIFO) is the default method most brokerages use. It assumes the oldest shares you own are sold first. If your earliest purchases were at the lowest prices, FIFO tends to produce the largest gains.
Specific identification gives you the most control. When placing a sell order, you manually select which shares (or “lots”) to sell. This lets you cherry-pick higher-cost shares to minimize your gain, or lower-cost shares if you want to realize a gain while your income is low enough to qualify for the 0% rate.
Average cost is available for mutual funds, certain ETFs, and unit investment trusts. You take the total amount you’ve invested and divide by the number of shares you own. This is the simplest approach if you’ve been making regular purchases over time and don’t want to track individual lots.
Other options include last in, first out (LIFO), which sells the most recently purchased shares first, and high-cost or low-cost lot methods that automatically prioritize shares by price. Some brokerages also offer tax-optimization tools that sequence sales to minimize your overall tax impact, selling losses first and deferring gains where possible.
The method you choose generally needs to be consistent for a given account, so it’s worth selecting one deliberately rather than accepting the default without thinking about it.
Determining Capital Gains on a Home Sale
Real estate follows the same basic formula, but with more adjustments and a valuable exclusion. Your cost basis for a home starts with the purchase price and includes closing costs like title insurance, recording fees, and transfer taxes you paid at purchase. Over the years, permanent improvements such as a new roof, added bathroom, or finished basement increase your basis. Routine maintenance and repairs do not.
When you sell, your gain equals the sale price minus selling expenses (agent commissions, closing costs) minus your adjusted basis. On a home you bought for $300,000, put $40,000 of improvements into, and sold for $500,000 with $30,000 in selling costs, your gain would be $130,000.
If the home was your primary residence, you may be able to exclude up to $250,000 of that gain from your income, or up to $500,000 if you’re married filing jointly. To qualify, you must pass two tests. The ownership test requires that you (or your spouse, if filing jointly) owned the home for at least two of the five years before the sale. The use test requires that you lived in the home as your primary residence for at least two of those five years. The two-year periods don’t need to overlap, but both tests must be met within that five-year window.
One additional rule: you generally can’t claim this exclusion if you already excluded a gain on a different home sale within the previous two years.
Putting It All Together
Working through a capital gains calculation step by step looks like this:
- Step 1: Find your original cost basis, including purchase price, commissions, and transaction fees.
- Step 2: Add any improvements or additional costs that increase your basis. Subtract any depreciation or reimbursements that decrease it. This gives you your adjusted basis.
- Step 3: Subtract your adjusted basis from the net sale price (after selling costs) to get your capital gain or loss.
- Step 4: Determine your holding period. Count from the day after acquisition through the day of sale to see if you cross the one-year threshold.
- Step 5: If the gain is long-term, apply the 0%, 15%, or 20% rate based on your taxable income. If it’s short-term, the gain is added to your ordinary income and taxed at your regular rate.
You report capital gains and losses on Schedule D of your federal tax return (Form 1040). Your brokerage will typically send you a Form 1099-B showing proceeds and cost basis for securities you sold during the year, which gives you the raw numbers you need. For real estate and other assets, you’ll need to compile your own records of purchase price, improvements, and selling costs.

