Stocks, funds and ETFs

Stock Capital Gains Tax Calculator: What Selling Stock Really Costs You

Short answer: stock held more than a year is taxed at 0%, 15% or 20% in 2027 depending on your total taxable income. Stock held a year or less is taxed as ordinary income, up to 37%. Add the 3.8% net investment income tax for higher incomes and your state.

The part most stock calculators miss is what a large sale does to a retiree's Social Security and Medicare. The gain is income, so it can make more of your benefit taxable and lift your Medicare premiums two years later. This calculator shows the tax and the full cost.

By Hans Goldstein, EA, Enrolled Agent, enrolled to practice before the IRS. Updated December 2026.

2027 federal brackets (IRS Rev. Proc. 2026-35), SSA Section 86 thresholds, CMS 2027 Medicare premiums and IRMAA tiers, state rates as of December 2026. Estimates, not tax advice.

Worked example

A married couple, 68 and 66, sell stock for $600,000 that cost $150,000. They collect $52,000 of Social Security and have $70,000 of other income.

Worked exampleAmount
Taxable gain$450,000
Federal tax on the gain$65,265
Net investment income tax (3.8%)$11,940
California tax on the gain$38,885
Tax most calculators show$116,090
Extra tax on Social Security the sale makes taxable ($0 more taxable)$0
Medicare Part B + D surcharge two years later$13,174
Real cost$129,263

Short-term vs long-term stock gains

The holding period decides the rate. Shares held more than one year are long-term: 0% up to $51,050 of taxable income (single) or $102,100 (married) in 2027, 15% up to $563,200 or $633,600, and 20% above. Shares held one year or less are short-term and taxed as ordinary income at 10% to 37%. Use the how long did you own it option above to see the difference.

The extra costs: NIIT, state and the retirement stack

Stock gains are net investment income, so the 3.8% NIIT applies once modified adjusted gross income passes $200,000 (single) or $250,000 (married). A few states tax stock gains specially: Washington has a separate capital gains excise tax on large gains, and California taxes the whole gain at ordinary rates. For retirees, the sale also lifts provisional income, so more Social Security becomes taxable, and it raises the income that sets Medicare Part B and D premiums two years later.

Why this page has no installment sale option

Publicly traded stock is not eligible for installment-sale treatment under IRC Section 453, so the whole gain lands in the year of sale. Spreading it means actually selling in different years. For a concentrated position with a very low basis, there are other tools; see selling concentrated stock.

Frequently asked questions

How much is capital gains tax on stock?

In 2027, long-term gains are taxed at 0%, 15% or 20% depending on taxable income, plus 3.8% NIIT for higher incomes and your state tax. Short-term gains, from stock held a year or less, are taxed as ordinary income up to 37%.

How do I calculate capital gains on stock?

Subtract your cost basis (what you paid plus fees, adjusted for reinvested dividends and splits) from the proceeds. The difference is the gain. Your broker's Form 1099-B reports both.

Do I pay capital gains tax if I reinvest the proceeds?

Yes. Reinvesting in other stock does not defer the tax. The gain is taxable in the year of sale regardless of what you buy next.

What is the 0% long-term capital gains bracket for 2027?

Taxable income up to $51,050 for single filers and $102,100 for married couples filing jointly. Long-term gains that fall inside that range pay no federal tax.

Does selling stock affect Social Security and Medicare?

A gain adds to your adjusted gross income, which can make up to 85% of your Social Security taxable and raise your Medicare Part B and D surcharge two years later.

Can I avoid capital gains by gifting stock?

A gift to charity avoids the gain and gives you a deduction for the fair market value. A gift to a family member passes your basis and holding period to them, so they owe the tax when they sell, possibly at a lower rate.

Run it on your real return

A free 15-minute call with Hans Goldstein: which levers fit your sale, what the Social Security and Medicare effects look like on your actual numbers, and what to ask your CPA.

Book 15 minutes 213-414-2808

Educational estimate, not tax, legal or financial advice. Figures use 2027 federal brackets and thresholds (IRS Rev. Proc. 2026-35), the Social Security benefit-taxation rules in IRC Section 86, CMS 2027 Medicare premiums and IRMAA tiers, and state rates as of December 2026 (California uses the FTB 2026 schedule until the 2027 schedule is published). Later Medicare years hold the 2027 tiers flat. Your CPA should confirm any figure before you act. By Hans Goldstein, EA, Enrolled Agent (enrolled to practice before the IRS), reviewed December 2026.

Run my numbers Book 15 min Call

Hans Goldstein is an Enrolled Agent, enrolled to practice before the Internal Revenue Service. Not affiliated with or endorsed by the IRS. General education, not tax or legal advice for your situation.