Wiki.Credit Logo
Taxes & Planning

Capital Gains Tax: What You Owe When You Sell an Investment

Author

Diana Lowe

Date Published

When you sell an investment for more than you paid, the profit is a capital gain and you owe tax on it. The rate depends entirely on how long you held the asset before selling. Hold for more than one year and you qualify for long-term capital gains rates — 0%, 15%, or 20% depending on your taxable income. Sell within a year and the gain is short-term, taxed as ordinary income at your marginal rate, which can be as high as 37%. That one-year threshold is one of the most impactful numbers in personal finance.

Capital gains taxes only apply in taxable brokerage accounts. Inside a traditional IRA, Roth IRA, 401k, or HSA, you can buy and sell freely with no capital gains tax due at the time of the transaction. This is a significant advantage of tax-advantaged accounts that often gets overlooked when people compare investment options across account types.


Long-term capital gains rates by income bracket

For 2024, single filers with taxable income below $47,025 pay 0% on long-term capital gains. From $47,026 to $518,900, the rate is 15%. Above $518,900, it's 20%. For married filing jointly, the 0% bracket extends to $94,050, and the 15% bracket runs to $583,750. High earners may also owe an additional 3.8% net investment income tax (NIIT), bringing the top rate to 23.8%. Qualified dividends are taxed at these same long-term capital gains rates.

The 0% long-term capital gains bracket is underutilized. A couple in a low-income year — perhaps early in retirement, between jobs, or during a gap year — with taxable income below $94,050 can sell appreciated investments and pay nothing in federal capital gains tax. This strategy, sometimes called capital gains harvesting, lets you reset your cost basis upward without a tax bill. The shares can be immediately repurchased at the higher price, locking in the tax-free gain for future use.


Tax-loss harvesting — using losses to offset gains

Tax-loss harvesting sells an investment that has declined in value to realize a capital loss, which can then offset capital gains dollar-for-dollar. If you have $15,000 in gains from selling one stock and $8,000 in losses from selling another, your net taxable gain is $7,000. Losses that exceed gains can offset up to $3,000 in ordinary income per year, with any remaining losses carried forward indefinitely to future tax years. In a volatile year with significant market swings, tax-loss harvesting can materially reduce your tax bill.

The wash sale rule limits this strategy: you cannot repurchase the same or substantially identical security within 30 days before or after the sale that generated the loss. If you sell an S&P 500 index fund at a loss and buy an identical fund from a different provider within that window, the IRS may disallow the loss. The workaround is buying a similar but not identical fund — selling a total market fund and buying a large-cap fund, for example — to maintain market exposure while preserving the tax loss.


Step-up in basis at death — the estate planning angle

When an investor dies, inherited assets receive a 'step-up in basis' to the fair market value at the date of death. An heir who inherits stock originally purchased for $20,000 now worth $120,000 has a cost basis of $120,000 — meaning they can sell it immediately with no capital gains tax owed on the $100,000 in appreciation that occurred during the decedent's lifetime. This rule effectively eliminates capital gains taxes on assets held until death and transferred to heirs.

The practical implication: holding highly appreciated assets in a taxable account until death is a deliberate estate planning strategy. Selling those same assets during your lifetime at today's prices triggers a large tax bill; holding and passing them through your estate eliminates that liability. This is why financial planners often advise spending down lower-basis assets first during retirement and preserving highly appreciated positions for potential step-up treatment — the tax savings can be substantial on positions held for decades.


Specific identification and lot selection

When you've purchased the same stock or fund at different prices over time, you have multiple 'lots' with different cost bases. When you sell, the IRS allows you to specify which shares you're selling — a method called specific identification. Selling your highest-cost shares first minimizes the taxable gain. Most brokerages default to FIFO (first in, first out), which sells your oldest — often lowest-cost — shares first, maximizing your gain and your tax bill. Changing your cost basis method or using specific identification at the time of each sale is legal and often beneficial.

For mutual fund and ETF investors, average cost basis — a method that averages all purchase prices — is a common default and a reasonable choice for simplicity. Specific identification produces better tax outcomes but requires tracking individual lots. Fidelity, Schwab, and Vanguard all offer tools to view and select specific lots at the time of sale. The decision matters most for large taxable accounts with significant embedded gains accumulated over many years.


Related posts

Taxes & Planning

A donor-advised fund lets you make a large charitable contribution in a single year for an immediate tax deduction, then distribute the money to charities over time. Combined with bunching, appreciated stock donations, and qualified charitable distributions, it's the most tax-efficient giving structure available to most donors.