how to calculate tax on investments

Investment Tax Calculator

Estimate federal and state taxes on stock, ETF, or mutual fund gains, plus dividends.

Educational estimate only. Actual taxes depend on filing status, income, carryforwards, and current tax law.

Quick Answer: The Basic Formula

To calculate tax on investments, you first compute your gain or loss, then apply the right tax rate based on the type of income and how long you held the asset.

Taxable Gain = Net Sale Proceeds - Cost Basis

Investment Tax = (Capital Gain Tax) + (Dividend/Interest Tax) + (State Tax) + (NIIT, if applicable)

The most common mistake is treating all investment income the same. In reality, short-term gains, long-term gains, qualified dividends, non-qualified dividends, and interest can each be taxed differently.

Step 1: Determine Your Cost Basis

Your cost basis is generally what you paid to acquire the investment, plus certain transaction costs.

Cost basis usually includes:

  • Purchase price
  • Commissions and trading fees on the buy
  • Reinvested dividends (for many brokerage accounts and mutual funds)
  • Corporate action adjustments (splits, spin-offs, mergers)

If your basis is wrong, your tax estimate will be wrong. Always compare your numbers with brokerage 1099 forms and account statements.

Step 2: Calculate Net Sale Proceeds

Net proceeds are what you actually received from the sale after selling costs.

Net Sale Proceeds = (Sale Price × Shares) - Selling Fees

Then:

Capital Gain (or Loss) = Net Sale Proceeds - Cost Basis

If the result is positive, you have a gain. If negative, you have a capital loss.

Step 3: Classify the Holding Period

Holding period affects tax rate:

  • Short-term capital gain: Held 1 year or less; generally taxed at ordinary income rates.
  • Long-term capital gain: Held more than 1 year; generally taxed at preferential capital gains rates.

This is why holding a position for a few extra months can materially change your after-tax return.

Step 4: Apply the Correct Tax Rates

Federal capital gains rates

Short-term gains are typically taxed at your marginal ordinary tax rate. Long-term gains usually receive lower rates (often 0%, 15%, or 20% in the U.S., depending on income).

Dividend and interest taxation

  • Qualified dividends: Usually taxed like long-term capital gains.
  • Ordinary dividends and interest: Usually taxed at ordinary income rates.

If you invest in bonds, CDs, or money market funds, interest can be a major part of your tax bill even when you do not sell principal.

Step 5: Add NIIT and State Taxes

High-income investors may owe the Net Investment Income Tax (NIIT), commonly 3.8% on eligible investment income. Many states also tax capital gains and dividends, often at ordinary income rates.

That means your total effective rate can be significantly higher than just the headline federal long-term rate.

Worked Example

Suppose you bought 100 shares at $50 and sold at $72, paid $5 to buy and $5 to sell, held for 18 months, and received $120 qualified dividends plus $80 ordinary dividends:

  • Cost basis = (100 × 50) + 5 = $5,005
  • Net sale proceeds = (100 × 72) - 5 = $7,195
  • Capital gain = $7,195 - $5,005 = $2,190
  • Holding period = long-term, so gain uses long-term rate
  • Total taxable investment income also includes dividends

The calculator above automates this full flow and gives you an estimated total tax and after-tax return.

What If You Have a Loss?

Capital losses may offset capital gains. If losses exceed gains, you may be able to deduct a limited amount against ordinary income, with remaining losses carried forward to future years (subject to tax rules).

Important rule: wash sales

If you sell at a loss and buy a substantially identical security too soon, the loss may be disallowed for current-year tax purposes. This can surprise new investors who harvest losses without tracking replacement trades.

Tax by Account Type

  • Taxable brokerage account: Annual taxes on realized gains, dividends, and interest.
  • Traditional retirement account: Tax-deferred growth; later withdrawals are generally taxed as ordinary income.
  • Roth account: Contributions are after-tax; qualified withdrawals are generally tax-free.
  • Health savings account (if eligible): May provide triple tax advantages under qualifying rules.

Asset location matters: tax-inefficient assets are often better placed in tax-advantaged accounts when possible.

Common Mistakes to Avoid

  • Ignoring cost basis adjustments after reinvested dividends
  • Forgetting trading fees when computing gain/loss
  • Using long-term rates for short-term trades
  • Ignoring state tax and NIIT in planning
  • Not planning around year-end distributions in funds
  • Selling without considering tax-loss harvesting opportunities

Simple Year-End Checklist

  • Download your realized gain/loss report from your broker
  • Confirm short-term vs. long-term classifications
  • Separate qualified dividends from ordinary dividends
  • Review carryforward losses from prior years
  • Estimate federal + state tax impact before executing large sales

Final Thoughts

Learning how to calculate tax on investments is one of the highest-value skills for long-term wealth building. Two portfolios with identical pre-tax returns can end up with very different outcomes after taxes. Keep good records, classify income correctly, and make tax-aware investment decisions throughout the year—not just at filing time.

🔗 Related Calculators