Calculating long-term capital gains tax

Been trying to figure out long term capital gains tax. Multiple sources point to a rate of 0%, 15%, or 20% depending on your taxable income:

Seems simple. But suppose we’re married and filing jointly, and our taxable income is $83,351. Surely that doesn’t mean all of our LTCG are taxed at 15%, whereas if our taxable income had been $83,350, all of our LTCG would have been taxed at 0%. So maybe it’s a marginal-tax-rate scheme, like ordinary income tax?

I tried using the calculator on this website to see if I could make sense of how it all works:

I tinkered with different values of LTCG (sale price minus purchase price) and taxable income, and I can see that yes, the net LTCG tax rate doesn’t experience step-changes from 0-15-20% as you gradually adjust LTCG and/or ordinary income (they even show in the calculator section that portions of your LTCG are taxed at different rates. But I just can’t figure out the relationships. I’d like very much to build my own calculator in Excel to help get it sorted out in my head. Can someone explain in words how this works, or point me toward a source that does?

It’s in the chart you linked to. Your LTCG rate is dependent on your ordinary income level. Ordinary income does not include ANY capital gains, so it’s not going to step up with your gains.

This is so simplified that it doesn’t clarify anything for me, and now that I’ve tinkered with the NerdWallet calculator some more, I’m not even sure it’s correct.

Using the NerdWallet calculator for married-filing-jointly:

  • if I enter a LTCG of $20,000 and a 2021 taxable income (excluding LTCG) of $60,800, then the entire $20K of CG gets taxed at 0%.

  • if I enter a LTCG of $20,000 and a 2021 taxable income (excluding LTCG) of $70,800, then $10K of LTCG gets taxed at 0%, and the remaining $10K gets taxed at 15%.

  • if I enter a LTCG of $20,000 and a 2021 taxable income (excluding LTCG) of $80,800, then the entire $20K of CG gets taxed at 15%.

    So according to that calculator, the LTCG rate is dependent on the sum of ordinary income and LTCG, rather than just ordinary income as you’ve indicated. Are they wrong about that?

I am not an accountant.

Nerdwallet is correct. Your capital gains tax rate “steps up” as your capital gains are added to your income. However, capital gains will NOT cause your ordinary income to be taxed at a higher rate. Your ordinary income rate is calculated first, and then capital gains are “added on” to determine the tax rate on those gains. This article was helpful.

Add your long-term capital gains “on top of” your income, and then assess the tax rates. So, in your second example, when you add the $20,000 onto your income of $70,800, the first $10,000 in capital gains tax is at 0%, since 70,800 + 10,000 = 80,800, which is the top of the range for married filing jointly capital gains of 0%. The other $10,000 of your capital gains lies in the next range, at 15%.

Here’s another example, LTCG, married-filing-jointly:

2021 taxable income of $70,000, LTCG of $450,000.

The first $10,800 of the capital gains is taxed at 0%, and puts your “total income” at $80,800.
The next $420,800 of the capital gains is taxed at 15%, and puts your total income at $501,600.
The remaining $18,400 of the capital gains is taxed at 20%, since it puts your total income in the $501,601+ bracket.

Thanks, this makes sense. Between this and more tinkering with the NerdWallet calculator, I got a good enough grasp of it to write my own calculator in Excel, and its results match what I get with NerdWallet, so I think I’m good to go.

See the instructions for form 1040, specifically, “Qualified Dividends and Capital Gain Tax Worksheet” (page 36 for 2021 tax returns)