Capital gains tax is the federal tax on the profit you make when you sell something you own — a stock, a fund, a piece of real estate — for more than your basis in it, which is usually what you paid. How much tax you owe turns mainly on one question: how long did you hold the asset? Sell after one year or less and the profit is a short-term gain, taxed like wages at your ordinary rates. Sell after more than one year and it is a long-term gain, taxed at lower preferential rates of 0%, 15% or 20%, depending on your taxable income and filing status.

Short-term gain Long-term gain
Holding period One year or less More than one year
How it is taxed As ordinary income, at your regular graduated rates At 0%, 15% or 20% for most assets, based on taxable income
Who sets the rate Your ordinary income bracket The capital gains thresholds for your status

Everything below follows the IRS’s own guidance, starting with Topic No. 409, Capital Gains and Losses. This article covers federal tax only — many states tax capital gains on top, under their own rules — and it is general education, not personal tax advice.

What is a capital gain?

The IRS treats almost everything you own for personal or investment purposes as a capital asset — your home, household furnishings, and stocks or bonds held as investments are the examples it gives. When you sell a capital asset, the difference between what you receive and your adjusted basis is a capital gain or a capital loss. Your basis is generally what the asset cost you; special rules apply to property received as a gift or an inheritance.

Three consequences follow from that definition:

  • The tax starts with a sale. An investment that has gone up in value but is still sitting in your account has an unrealized gain, and no tax is due on it. The gain only counts when you sell or otherwise dispose of the asset.
  • Only the profit is taxed, not the whole sale price. If you sell stock for $30,000 that cost you $20,000, the gain is $10,000; the return of your own $20,000 is not income.
  • Personal-use losses do not count. If you sell your car or your home for less than you paid, that loss is not deductible, even though a gain on the same property would have been taxable.
  • Inherited assets start from a reset basis. Topic No. 409 sends you to Publication 551 for the basis of anything you received as a gift or an inheritance. For an inheritance, that basis is generally the asset’s fair market value on the date the previous owner died — so growth that built up during their lifetime is not taxed to you when you sell.

How is capital gains tax calculated?

The calculation has four steps:

  1. Work out the gain on each sale: amount received minus your adjusted basis.
  2. Sort every gain and loss by holding period — short-term (a year or less) and long-term (more than a year).
  3. Net within each group, then combine. Short-term gains and losses are netted against each other, long-term against long-term, and the two results combined into one net figure.
  4. Apply the right rates. A net short-term gain is taxed as ordinary income. A net long-term gain is taxed under the 0%, 15% and 20% thresholds below, worked out on Schedule D.

A worked example

Suppose you are single and buy shares in an index fund for $20,000. Fourteen months later you sell them for $30,000. Your capital gain is $30,000 − $20,000 = $10,000, and because you held the shares more than one year, it is long-term.

Now the rate. The thresholds apply to your total taxable income, with the gain sitting on top of your other income. Say your taxable income from your job, after deductions, is $60,000. For tax year 2027, a single filer’s 0% band ends at $51,050 of taxable income — your salary alone is already past it — so the whole $10,000 gain lands in the 15% band. Tax on the gain: $10,000 × 15% = $1,500.

Change one number and the bands work in layers. If your other taxable income were $45,000 instead, the first $6,050 of the gain would fill the space up to the $51,050 ceiling and be taxed at 0%, and only the remaining $3,950 would be taxed at 15% — about $593 on the same $10,000 profit.

And if you had sold after eight months instead? The $10,000 would be a short-term gain, added to your ordinary income. At an assumed 22% marginal rate, that is $2,200 of tax — $700 more than the long-term bill, purely because of the calendar.

Short-term vs long-term: the one-year line

The holding period is where readers most often trip, because the line is more than one year, not “a year or more.” Per the IRS, you begin counting the day after you acquire the asset, and you count up to and including the day you dispose of it. Sell on the exact one-year anniversary and the gain is still short-term; you have to hold past that date for long-term treatment.

A net short-term gain is taxed at the same graduated rates as wages — there is no special rate for it at all. A net long-term gain gets the preferential schedule, and the IRS notes the rate on most net capital gains is no higher than 15% for most individuals. Holding period, not the size of the profit, is usually the biggest lever in the final bill.

Capital gains tax rates and thresholds for 2027

For most long-term gains, three rates apply — 0%, 15% and 20% — and which one hits your gain depends on where your taxable income falls relative to two ceilings for your filing status. The table below uses the figures for taxable years beginning in 2027, from Revenue Procedure 2026-35, the most recent year the IRS has published.

Filing status 0% rate: taxable income up to 15% rate: taxable income up to 20% rate
Single $51,050 $563,200 Above $563,200
Married filing jointly / qualifying surviving spouse $102,100 $633,600 Above $633,600
Married filing separately $51,050 $316,800 Above $316,800
Head of household $68,350 $598,400 Above $598,400

Read the table as layers, not as a single rate for your whole gain. Your other income fills the lower layers first, and the gain stacks on top, so one gain can be split across two bands — exactly what happened in the worked example above. A gain is never taxed at 20% just because your income crosses the 15% ceiling by a dollar; only the part above the ceiling gets the higher rate.

One practical note: the year of the sale is the year that matters. If you sell in 2026, the slightly lower 2026 ceilings apply (for a single filer, the 0% band ended at $49,450), not the 2027 figures above.

Exceptions: when the rate is not 0%, 15% or 20%

A few kinds of long-term gain have their own maximum rates, set out in Topic No. 409:

  • Collectibles — art, antiques, coins and stamps: a maximum rate of 28%.
  • Unrecaptured section 1250 gain — broadly, the part of a gain on depreciated real estate corresponding to depreciation previously claimed: a maximum rate of 25%.
  • Certain qualified small business stock (section 1202): the taxable part can face a maximum rate of 28%.

“Maximum” is the word that matters. These are ceilings, not flat rates — if your ordinary rate is lower, the lower figure applies.

The 3.8% net investment income tax

Higher-income taxpayers can owe one more layer: the net investment income tax (NIIT), an additional 3.8% tax described in IRS Topic No. 559. Capital gains count as net investment income, so a large sale can attract the NIIT on top of the 15% or 20% rate.

The tax applies when your modified adjusted gross income (MAGI) passes a threshold for your filing status:

  • $250,000 — married filing jointly or qualifying surviving spouse
  • $200,000 — single or head of household
  • $125,000 — married filing separately

The 3.8% is charged on the lesser of your net investment income or the amount by which your MAGI exceeds the threshold — so crossing the line by a small amount produces a small tax, not 3.8% of everything. Unlike the capital gains ceilings, these thresholds are not adjusted for inflation, so they catch more people each year. Note that the NIIT uses MAGI, while the 0%, 15% and 20% bands use taxable income — two different measures, and a big sale can push you over one line without the other.

What if you sell at a loss?

Losses are the mirror image of gains, and they are valuable in a specific order. Capital losses first offset capital gains — short-term against short-term, long-term against long-term, then across. If losses exceed gains, you have a net capital loss, and you can deduct up to $3,000 of it against other income each year ($1,500 if married filing separately). Any loss left over is not wasted: it carries forward to the next year, keeping its short-term or long-term character, and can offset future gains plus another $3,000 a year until it is used up.

Remember the personal-use rule: a loss on something you owned for your own use, like your car or your main home, is not deductible at all. The $3,000 deduction and the carryforward apply to losses on investment and other capital property, not to personal items sold at a loss.

One rule catches people who sell and immediately change their minds: the wash sale rule. If you sell a stock or security at a loss and buy substantially identical stock or securities within 30 days before or after the sale, the IRS does not let you deduct that loss now — Publication 550 sets the rule out. The loss is usually postponed rather than destroyed: it is added to the cost of the new shares, so it returns when you eventually sell them. Selling to bank a tax loss and buying the same thing back the following week does not work.

Selling your main home

The biggest exception in the whole system is the sale of your main home. If you meet the IRS’s ownership and use tests, you can exclude up to $250,000 of gain — $500,000 on a joint return in most cases. Topic No. 701 states the tests plainly:

  • Ownership test: you owned the home for at least two years during the five years before the sale.
  • Use test: you lived in it as your main home for at least two years during the same five-year window. The two years do not have to be continuous.
  • On a joint return, generally either spouse can meet the ownership test but both must meet the use test, and neither spouse can have used the exclusion on another sale within the previous two years.

Gain above the exclusion is taxed as a capital gain — long-term, for anyone who has owned the home that long — and partial exclusions exist for sales forced by a job change, health reasons or unforeseen circumstances, all covered in IRS Publication 523. The mirror rule still applies: sell your main home at a loss and the loss is personal, so it is not deductible.

Gains you can owe tax on without selling anything

There is one common exception to “the tax starts with a sale.” If you own a mutual fund, the fund itself sells holdings during the year, and when it sells at a profit it can pass your share to you as a capital gain distribution. You owe tax on it even though you sold nothing — and even if it was automatically reinvested. The IRS’s mutual fund guidance treats these distributions as long-term capital gains no matter how long you have owned your fund shares, because what matters is how long the fund held the asset it sold. The amount arrives in box 2a of Form 1099-DIV and is reported on Schedule D.

How gains are reported

Most sales of capital assets are reported one by one on Form 8949 and summarized on Schedule D, which is where the netting and the rate worksheet happen. Your broker’s year-end statement is the usual source for the sale price and basis figures, but the responsibility for a correct basis is yours — for assets bought long ago, or received as a gift or inheritance, the number on a statement may need adjusting. Keep one distinction straight while you report: the bands run off taxable income, the NIIT off modified adjusted gross income — what adjusted gross income is explains that second number.

The short version to keep: the tax is on profit, not proceeds; more than one year is the line that matters; the 2027 ceilings decide whether a long-term gain is taxed at 0%, 15% or 20%; the 3.8% NIIT can sit on top for higher incomes; losses are worth up to $3,000 a year against ordinary income with the rest carried forward, unless a wash sale postpones them; a fund can hand you a taxable distribution in a year you sold nothing; and a main-home sale can exclude $250,000 or $500,000 of gain entirely. A large sale also moves how your net worth is calculated — the profit is real wealth, minus this tax.

This article is general education about how US federal capital gains tax works, based on the IRS sources linked above. It is not personal tax advice. Situations involving gifts, inheritances, business property or large one-off sales deserve a qualified tax professional.