Quick Summary
A guide to capital gains tax calculations - how short-term and long-term rates differ, the calculation formula, and common strategies for managing tax impact.
Selling an investment at a profit feels good until the tax bill arrives. The gap between what you paid and what you sold for is a capital gain, and the government wants its share. How much depends on one surprisingly simple factor: how long you held the thing before selling it.
The Capital Gains Tax Calculator estimates what you will owe. No signup required.
The One-Year Line
The tax code draws a hard line at 12 months of ownership. Everything on one side of that line is taxed one way. Everything on the other side is taxed very differently.
Under 12 months (short-term): Gains are taxed at your ordinary income tax rate. If you are in the 24% bracket, you pay 24% on the gain. At the highest bracket, it is 37%.
12 months or longer (long-term): Gains qualify for preferential rates. For most people, that means 15%. For lower incomes, it can be 0%. For very high incomes, it tops out at 20%.
The practical difference is striking. A $10,000 gain on a stock sold at 11 months costs $2,400 in taxes for someone in the 24% bracket. Wait one more month and the same gain costs $1,500 at the 15% long-term rate. That is $900 saved by waiting 30 days. Few financial moves offer that kind of return for doing nothing.
How the Math Works
The formula is simple: subtract what you paid from what you received, then apply the appropriate tax rate.
Sale price - cost basis = capital gain
Cost basis includes the original purchase price plus any commissions or fees. For stocks bought in multiple lots over time, the basis depends on which shares you sell - you can use specific identification (choosing the exact shares), FIFO (first in, first out), or average cost.
Choosing the right method matters. Selling the shares with the highest cost basis first produces a smaller gain and less tax. This is one of those details that is easy to overlook and expensive to ignore.
Losses Are a Tool, Not Just Bad Luck
When an investment drops below what you paid for it, selling it creates a capital loss. Losses offset gains dollar-for-dollar. This is tax-loss harvesting, and it is one of the few ways to directly reduce your tax bill from investments.
Say you sold Fund A for a $5,000 gain this year. Fund B in your portfolio is currently down $3,000. Selling Fund B creates a $3,000 loss that offsets part of the gain. Instead of paying tax on $5,000, you pay on $2,000. At the 15% rate, that saves $450.
If your losses exceed your gains in a given year, up to $3,000 of the excess can offset ordinary income. Any remaining losses carry forward to future years - they do not expire.
One catch: the wash sale rule. If you sell an investment to harvest a loss and buy something “substantially identical” within 30 days (before or after the sale), the loss is disallowed. Buying a similar but not identical fund - like swapping one S&P 500 index fund for a total market fund - typically avoids this.
Real Estate Has Its Own Rules
Selling a home is the one capital gains event where many people owe nothing. The primary residence exclusion lets single filers exclude up to $250,000 in gains and married couples exclude up to $500,000, as long as the home was a primary residence for at least two of the last five years.
For a home purchased at $300,000 and sold at $500,000, the $200,000 gain is fully excluded. No tax. This exclusion is one of the more generous provisions in the tax code, and it applies automatically for qualifying homes.
Investment properties are a different story. No exclusion applies. All gains are taxable, and any depreciation claimed during ownership is recaptured at up to 25%. A 1031 exchange can defer the tax by reinvesting the proceeds into another investment property within specific timeframes, but the rules are strict and the process involves coordination with a qualified intermediary.
The Extra 3.8% Nobody Expects
For someone selling a large position - say, concentrated stock from an employer - the NIIT can add thousands to the tax bill. It is worth accounting for in the estimate.
Timing as Strategy
Capital gains tax is one of the few taxes where you have meaningful control over timing.
Holding period management. If a stock has gained value and you are close to the one-year mark, waiting a few weeks to sell can drop the rate significantly. Not every situation allows for patience, but when it does, the savings are real.
Income-year planning. Expecting lower income next year due to a sabbatical, career change, or retirement? Pushing a sale into the low-income year could move the long-term rate from 15% to 0%. The 0% bracket for long-term gains covers a meaningful amount of taxable income.
Charitable giving. Donating appreciated stock directly to charity avoids capital gains entirely. Instead of selling the stock, paying the tax, and donating the cash - you donate the stock and get a deduction for its full market value. The charity sells it tax-free. Both sides come out ahead compared to donating cash.
The Annual Tax Planner Template helps track gains and losses throughout the year so tax decisions are not made in a year-end rush.
Tax-Aware Investing Guides
- After-Tax Return Calculator - What investments really earn after taxes
- Tax Drag Calculator: The Hidden Cost - How taxes compound against portfolio growth over decades
- Income Tax Calculator: Understanding Your Tax Bill - How brackets and deductions work