Man walking by NYSE
Eduardo Munoz Alvarez/Getty Images

The U.S. stock market this year has given total returns so far of close to 10 percent, which is a healthy harvest for investors.

But with the exception of savings in retirement accounts such as 401(k)s and individual retirement accounts (IRA), the taxman will probably take a cut of your newfound wealth. It’s called capital gains, and how much tax you pay depends on how long you hold the investments and how much you earn.

Long-term vs. short-term capital gains taxes

Long-term capital gains are those you earn on assets you’ve held for more than a year.

The current capital gains tax rates under the new 2018 tax law are zero, 15 percent and 20 percent, depending on your income.

2018 long-term capital gains tax brackets
Tax rate Single Joint Head of household
0% $0 to $38,600 $0-$77,200 $0-$51,700
15% $38,601-$425,800 $77,201-$479,000 $51,701-$452,400
20% $425,801 and up $479,001 and up $452,401 and up

For example, a married couple filing jointly pays no capital gains tax if their total taxable income is no more than $77,200. They’ll pay 15 percent on capital gains if their income is $77,201 to $479,000. For couples above that income level, the rate is 20 percent. In addition, capital gains may be subject to the net investment income tax (NIIT) of 3.8 percent if income is above certain amounts.

By contrast, short-term capital gains are from assets you buy and sell within one year. They are taxed as regular income, which is always higher than the long-term capital gains rate. The government gives you a break on long-term gains to encourage buy-and-hold investments (as opposed to speculating), which stabilize the economy. Check out the current tax brackets to see what you would pay on short-term capital gains.

How capital gains taxes work

Let’s say you buy $1,000 worth of stock in January and sell it in June for $1,200. You’ve made short-term capital gains of $200. You and your spouse have taxable income of $85,000 (including your stock gain), which puts you in the 24 percent income tax bracket. So you’ll give $48 of that $200 gain to Uncle Sam, leaving you with $152.

Consider, instead, that you hold on to your stock until the following January, at which point it has earned $400. Now it’s a long-term capital gain, and your family income puts you in the 15 percent bracket for that gain. Now you’ll pay $60 in tax, realizing a $340 profit. In other words, by doubling the length of your investment you have more than doubled your actual profit, by taking advantage of the favorable tax rate for long-term capital gains.

What counts as a capital gain?

Capital gains are basically any profits resulting from the sale of assets. That includes the sale of tangible assets such as artwork, a car or a boat, assuming you sell for more than you paid. (Most of the stuff you own, including everyday cars, will depreciate in value over time, so capital gains tax rarely applies to possessions.) It also includes the sale of real estate, with some tax exemptions for your principal residence.

Note that stock dividends also count as capital gains. If you have a lot of dividend gains (outside of retirement accounts), a financial planner can help reinvest those gains in ways to mitigate the tax bill. Many so-called robo-investment programs will do it automatically.

What if I lose money on investments?

Fortunately, the tax on capital gains, both long-term and short-term, is applied to your net investment income. That means the IRS looks at the total of your gain (or loss) when calculating tax.