Updated: Mar 14, 2024

How to Calculate and Minimize Capital Gains Taxes on Your Investment Profits

Learn how capital gains taxes apply to investment profits and find out how to calculate and reduce short-term or long-term capital gains taxes.
Today's Rates
Super boost your savings with highest rates.
Savings Accounts up to:
5.35% APY

Investing in stocks, bonds, mutual funds or exchange-traded funds (ETFs) can result in large profits. As you can imagine, Uncle Sam might require you to pay taxes on those profits. 

You may have heard the term capital gains tax before. This is typically the tax you’ll have to pay when selling investments for a gain.

Depending on how long you held your investment, the gains may be subject to short-term capital gains tax or long-term capital gains tax.

As with everything with taxes, there are also exceptions and other rules to consider. Here’s the basic information you need to know about capital gains taxes on investments.

Before we get started, remember that tax law changes on a regular basis. Additionally, your specific situation may present unique planning opportunities or tax issues.

Consult a tax professional to determine how capital gains tax may or may not apply to your specific situation.

What Is Capital Gains Tax?

According to the Internal Revenue Service (IRS):

“Almost everything you own and use for personal or investment purposes is a capital asset.”

When you buy a capital asset, such as a stock, the amount you pay for it is called your basis in your investment. 

When you sell a capital asset, you might have what is called a capital gain or loss depending on if you sell it for more or less than your basis. 

Capital gains tax can apply to more than investments such as stocks and bonds. It can apply to selling your home, your car, or any other capital asset you own.

For some other types of assets, your basis may change over time.

For instance, your basis in a home may increase if you make improvements to it. Similarly, your basis in a rental property may decrease when you depreciate the building.

For more information on calculating the basis of your assets, consult IRS Publication 551, Basis of Assets.

If you sell the asset for less than your basis, you have a capital loss. These losses may be tax-deductible depending on the asset.

Unfortunately, capital losses related to personal use property such as your car or your primary residence aren’t tax-deductible.

Short-term capital gains taxes

A gain is generally considered short-term if you hold the asset for a year or less. Short-term capital gains are taxed the same as your ordinary income. 

In the 2021 tax year, your tax rate could be as low as 0% or as high as 37%. In some cases, you may be subject to an additional 3.8% Medicare surtax, as well.

Long-term capital gains taxes

Assets held for over a year normally result in a long-term capital gain or loss.

The tax rates you typically pay on most long-term capital gains are more favorable than those on short-term capital gains.

In general, you’ll pay 0%, 15% or 20% on long-term capital gains taxes depending on the top marginal tax bracket you fall in. The income for each marginal tax bracket varies based on your filing status, such as married filing jointly.

You may also have to pay the additional 3.8% Medicare surtax on long-term capital gains, as well. 

Watch out:

These favorable rates don’t apply to all assets that qualify for long-term capital gains tax treatment.

Collectibles, real estate gains attributable to depreciation and certain other situations may result in higher capital gains tax rates.

How to Determine Your Capital Gains Tax Owed

Figuring out the amount of capital gains tax you’ll owe can be extremely complex for the average taxpayer. It also depends on your entire tax situation for the year.

Generally, your capital gain taxes are calculated on your tax return.

While the main form of an individual tax return is Form 1040, capital gains and losses are calculated on Schedule D, Capital Gains and Losses.

To estimate how much you’ll owe in capital gains taxes, you can use tax software. Plug in your estimated tax information for the year to see how much you’ll owe.

Use a tax pro

If you’ll have a significant amount of capital gains taxes or you don’t feel comfortable estimating them yourself, consult a tax preparer or tax professional that can help you plan for these gains.

It’s important to consult a tax professional before you sell your assets. 

In general, tax professionals cannot change tax treatment after you sell an asset. If you consult a tax professional before you sell, they can help you come up with a method that results in the lowest amount of taxes owed. 

Ways to Minimize or Avoid Capital Gains Tax

There are a number of strategies you can use to minimize or completely avoid paying capital gains taxes. 

Making tax-efficient investing decisions using the methods below could save you some serious money.

1. Primary residence special exception

If you own your home and use it as your primary residence for at least two or more of the last five years, you may not owe capital gains tax on part of the gain from the sale. 

In general, you get to exclude $250,000 of capital gains if you’re single or $500,000 if you’re married filing jointly on the sale of your primary residence.

2. Hold assets for more than one year

One potential way to lower the amount of taxes you pay is holding your capital assets longer.

If you hold your capital asset for over a year, it usually qualifies for long-term capital gains tax treatment.

3. Offset capital gains with capital losses

If you have capital gains, you may be able to offset some or all of those gains with capital losses. 

In general, capital losses offset the same type of capital gains first.


Long-term capital losses would first offset long-term capital gains. Similarly, short-term losses would offset short-term gains.

If you had a $2,000 short-term capital gain and a $1,000 short-term capital loss, you’d have a $1,000 net capital gain.

If you have more losses than gains of the same type, the remaining losses can be used to offset the other type of capital gains. 

If your total capital losses exceed your total capital gains, you can deduct up to $3,000 of capital losses each year against other types of income, such as ordinary income. 

If you still have capital losses left over, you can roll them forward to use in future tax years.

4. Plan to take capital gains in low-income years

If you have an income that changes from year to year, you can take advantage of this.

If you sell your capital assets in years with lower income, your gains may fall in lower tax brackets. 

The capital gains do add to your taxable income, though, so you can’t use this strategy to put an unlimited amount of capital gains in the 0% long-term capital gains tax bracket. 

Instead, the capital gains increase your income and tax bracket.

5. Keep assets with large capital gains in tax-advantaged accounts

Some assets tend to increase in value more than others. For example, stock prices tend to increase in value more than less aggressive investments.

To avoid owing a large amount of capital gains taxes on these high growth assets, consider keeping them in tax-advantaged accounts. Then, keep your lower growth assets in your regular taxable accounts.

In particular, you could keep your highest growth assets in a Roth retirement account such as a Roth IRA or Roth 401(k). 

These accounts don’t give you a tax deduction today.

That said:

You don’t have to pay taxes on the money you withdraw after full retirement age. It’s tax-free when withdrawn according to the rules.

6. Selectively sell your investments to avoid large gains

When you sell your assets, you may get to pick which particular assets you sell. 

For instance, let’s say you own 1,000 shares of Company A. You bought 250 shares 10 years ago at $10 per share, 500 shares two years ago at $50 per share and 250 shares six months ago at $25 per share.

Today, Company A’s stock is worth $100 per share. You want to sell 250 shares. 

If you sell the shares you bought six months ago, the $100 sale price minus the $25 cost per share results in a $75 gain per share. Because you owned them less than a year, you’d have to pay short-term capital gains tax on the $18,750 gain.

Alternatively, you could sell the shares you bought 10 years ago. This would result in a $90 gain per share. Since you owned the shares for over a year, you’d pay long-term capital gains taxes on the $22,500 gain.

However, the lowest tax option is likely choosing to sell 250 of the shares you bought two years ago. These qualify for long-term capital gains taxes because you’ve held them for over a year. 

The gain is also the smallest because these shares have the highest basis. In total, you’d have to pay long-term capital gains tax on the $12,500 gain.

Keep in mind, you’re saving money today by selling the shares with the highest basis. Even so, when you sell the rest of your shares you will still have to pay the gain on the other shares based on the future sales price, too.

7. Tax-loss harvesting

If you have a large amount of taxable capital gains, you can reduce them by tax-loss harvesting.

In this case, you can sell investments that currently have a capital loss to reduce your capital gains.

Be careful:

If you purchase the same or a very similar asset within 30 days before or after the sale of a substantially equal asset at a loss, the loss may be disallowed due to wash sale rules. 

This rule exists to prevent people from selling a stock to claim a tax-deductible loss, then repurchasing it immediately to continue owning and benefiting from the investment.

Understanding Taxes Is Key

Understanding taxes, including capital gains taxes, is an important skill to improve your finances. 


There’s nothing wrong with minimizing your taxes by using the rules to your advantage. The capital gains tax rules give you an opportunity to lower your taxes. 

Make sure you only take advantage of the system as it stands.

Don’t cross the line and do anything that isn’t allowed to try to save money on taxes.

Each individual’s tax situation is typically unique. For that reason, it makes sense to consult a tax professional to determine how to best plan for your specific situation.