Capital Gains

Image source: www.stockmonkeys.com via Flickr.

If you sell stock for more than you originally paid for it, then you may have to pay taxes on your profits, which are considered to be a form of income in the eyes of the IRS. Specifically, profits resulting from the sale of stock are known as capital gains and have their own unique tax implications. Here's what you need to know about selling stock and the taxes you may have to pay.

How to calculate your profits
When you sell stock, you are only responsible for paying taxes on the profits -- not the entire sale amount. In order to determine your profits, you need to subtract your cost basis (also known as "tax basis"), which consists of the amount you paid to buy the stock in the first place plus the commissions you paid to buy and sell the shares.

Profit From Sale

Once you've determined your profits, the tax you'll have to pay depends on your marginal tax rate (tax bracket) and the length of time you held the shares.

Short-term gains are taxed just like income
If you hold your stock for one year or less, then it will be taxed as short-term capital gains. This is pretty straightforward to determine: Short-term capital gains tax rates are equal to your marginal tax rate, or tax bracket. Your marginal tax rate depends on your taxable income, and you can get an idea of what yours might be here.

Long-term gains have lower rates
The IRS encourages long-term investing as opposed to trading, as capital gains tax rates are lower if you've held your stock for over a year. The exact capital gains tax rate you'll pay is based on your tax bracket, and it can range from 0% to 20%.

Tax Bracket

Short-Term Capital Gains Tax Rate

Long-Term Capital Gains Tax Rate

10%

10%

0%

15%

15%

0%

25%

25%

15%

28%

28%

15%

33%

33%

15%

35%

35%

15%

39.6%

39.6%

20%

Data source: IRS (current as of 2016 tax year).

So, to calculate your tax liability for selling stock, determine your profit and multiply by the appropriate percentage in the table.

How to avoid paying taxes when you sell stock
The only (legal) way to avoid tax liability when you sell stock, other than being in one of the 0% long-term capital gains brackets, is to buy stocks in a tax-deferred or tax-free account.

A tax-deferred account is an investment account such as a 401(k), 403(b), or traditional IRA, just to name a few examples. In these accounts, your contributions may be tax-deductible, but your qualified withdrawals will typically count as income. Meanwhile, a Roth account is tax-free; you can't get a tax deduction for contributing, but all of your qualified withdrawals won't count as income and therefore will not be taxed.

With any of these accounts, you will not be responsible for paying tax on capital gains, or dividends for that matter, so long as you keep the money in the account. The drawback is that these are retirement accounts, and you generally have to leave your money alone until you turn 59-1/2 years old, but there are exceptions. If you're interested in tax-advantaged investing options, here are some in-depth articles about IRAs and 401(k) accounts to help you determine the best way to save and invest for your future. To compare the features of standard investment accounts and retirement accounts offered by different brokers, visit our online broker tool.

This article is part of The Motley Fool's Knowledge Center, which was created based on the collected wisdom of a fantastic community of investors. We'd love to hear your questions, thoughts, and opinions on the Knowledge Center in general or this page in particular. Your input will help us help the world invest, better! Email us at knowledgecenter@fool.com. Thanks -- and Fool on!

Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.