
How to Calculate Capital Gains Tax
How Long You Hold an Investment Changes Everything
Capital gains tax applies when you sell an investment for more than you paid -- but the rate depends heavily on how long you held it before selling, and that single detail (whether the holding period crosses the one-year mark) can meaningfully change how much of a gain you actually keep. It's one of the more consequential timing decisions in personal finance, and one that's entirely within an investor's own control, unlike most other variables affecting how much tax is owed on a given sale.
Short-Term Capital Gains
If you held the asset for one year or less, the gain is taxed as ordinary income, at your regular marginal tax bracket -- the same rate as your wages, stacked on top of whatever other income you have for the year. For anyone in a higher tax bracket, this can mean a substantial portion of a short-term gain going to tax, which is exactly why short-term trading carries a real, often underappreciated tax cost beyond just the risk of the trade itself.
Long-Term Capital Gains
If you held the asset for more than one year, the gain qualifies for preferential long-term capital gains rates, which are meaningfully lower than ordinary income rates for most taxpayers -- one of the more significant tax-planning incentives built into the tax code to hold investments longer rather than trading frequently. This is a large part of why "buy and hold" investing strategies are often more tax-efficient than frequent trading, independent of whatever investment merits either approach might have.
Estimating Your Tax

Use the Capital Gains Tax Calculator to estimate the tax on a specific gain based on your holding period and income -- entering your actual numbers gives a far more useful estimate than trying to apply a general percentage rule of thumb to your specific tax bracket and gain amount.
Don't Forget NIIT
Higher earners may owe an additional 3.8% Net Investment Income Tax on top of regular capital gains tax, once MAGI exceeds a statutory threshold ($200,000 single / $250,000 married filing jointly) -- a real additional cost that's easy to overlook if you're only thinking about the headline capital gains rate. See the NIIT Calculator and our full NIIT guide for the details of how this stacks on top of the regular capital gains calculation.
Timing a Sale Around the One-Year Threshold
If a position is approaching its one-year holding anniversary and you're considering selling, it's worth checking exactly how close you are to crossing that threshold before finalizing the sale date -- selling even a few days early, while still within the short-term window, can mean a meaningfully higher tax bill than waiting until the long-term threshold is crossed. This isn't relevant to every sale (sometimes there's a good non-tax reason to sell immediately), but for a sale that isn't time-sensitive for other reasons, checking the exact holding period first is a simple, worthwhile step.
Keeping Good Records From the Start
Accurately calculating capital gains tax depends on knowing your cost basis -- what you originally paid for the investment, including any reinvested dividends or additional purchases -- which can be surprisingly hard to reconstruct years later without good records. Keeping purchase confirmations, brokerage statements, and a running log of your cost basis from the moment you first buy an investment saves real time and reduces error risk whenever that investment eventually gets sold, especially for an asset held many years across multiple separate purchases.
A Worked Example With Illustrative Numbers

Say you bought 100 shares at $50 each, so your cost basis is $5,000. Later you sell all 100 shares at $80 each, receiving $8,000. Your capital gain is the sale proceeds minus your basis: $8,000 minus $5,000 equals $3,000. Those numbers are purely hypothetical, but the steps are the same for any sale. If you held the shares for more than a year, that $3,000 is taxed at long-term rates; if not, it's added to your ordinary income for the year.
Now imagine you also sold a different position at a $1,200 loss in the same year. Losses of the same type net against gains first, so your net gain drops to $1,800. That netting happens before any rate is applied, which is why reviewing your whole year of sales, not just one trade, gives the most accurate picture.
Common Mistakes to Avoid
- Forgetting reinvested dividends when figuring basis. Each reinvestment is effectively a new purchase that adds to your basis, and skipping it means you pay tax on money you already paid tax on once.
- Using the wrong holding period for shares bought at different times. Each lot has its own purchase date, so a single sale can be part long-term and part short-term.
- Assuming the brokerage's 1099-B is always complete. Basis for older purchases, transfers between brokers, or gifted shares is sometimes missing or wrong, so compare it against your own records.
- Selling near year-end without checking your other income. A large gain can push part of your income into a higher bracket in that year.
Special Cases Worth Knowing About
Inherited assets and gifted assets follow different basis rules than assets you bought yourself. In general, inherited property receives a basis tied to its value at the time of the original owner's death, while gifted property can carry over the giver's original basis. The details matter and depend on the situation, so confirm the current rules on IRS.gov or with a tax professional before selling.
When to Talk to a Professional
Consider getting help if you sold a business, real estate that wasn't your main home, cryptocurrency across many wallets, or stock from an employer compensation plan. Records for those are harder to reconstruct, and mistakes can be costly.
Frequently Asked Questions
Can capital losses offset capital gains?
Yes -- losses can offset gains, and a limited amount of net capital loss can even offset ordinary income each year, with any excess carried forward to future years. This is a real, commonly used tax-planning strategy known as tax-loss harvesting.
Does the holding period reset if I sell and immediately rebuy the same investment?
Yes -- selling and rebuying starts a new holding period for the newly purchased shares. Be especially careful of the "wash sale" rule, which can disallow claiming a loss if you rebuy a substantially identical investment within a specific window around the sale -- this is a genuinely technical area worth understanding before attempting a loss-harvesting strategy.
Are capital gains on a primary residence taxed the same way?
Not exactly -- selling a primary residence has its own specific rules, including a substantial exclusion amount most homeowners qualify for on gain from selling their main home, which is separate from the general short-term/long-term investment framework described here.
Do dividends get taxed like capital gains?
It depends on the type -- qualified dividends are generally taxed at the same preferential rates as long-term capital gains, while non-qualified (ordinary) dividends are taxed as regular income. Confirming which category a given dividend falls into matters for accurately estimating the tax owed on investment income.
Does selling investments inside a retirement account trigger capital gains tax?
Generally no -- buying and selling within a tax-advantaged retirement account like a 401(k) or traditional IRA doesn't trigger capital gains tax at the time of the sale; tax treatment instead applies when funds are eventually withdrawn, under that account's own specific rules rather than the capital gains framework described here.
Do capital gains rates change from year to year?
The bracket thresholds are typically adjusted periodically, and tax law changes can alter the rates themselves -- always check current-year figures via the calculator or the IRS's own published guidance rather than relying on a number from a prior year, especially around a major tax decision.
Does state tax apply to capital gains on top of federal tax?
In most states with an income tax, yes -- state tax on capital gains is generally calculated separately from and in addition to federal capital gains tax, using each state's own specific rules and rates, some of which differ significantly from how the federal system treats short-term versus long-term gains.
What is cost basis in simple terms?
Cost basis is what you paid for an investment, generally including purchase fees and reinvested dividends. Your gain or loss is the sale price minus that basis.
Do I owe capital gains tax if I never sell?
Generally no. An increase in value you haven't realized by selling is called an unrealized gain, and it typically isn't taxed until the sale, though dividends or distributions along the way can still be taxable.
Can I choose which shares to sell to reduce the tax?
Many brokers let you specify which lots to sell, which can change your gain and holding period. The default method varies, so check your brokerage settings before placing the order.

Comments (0)
No comments yet. Be the first to share your thoughts.