Finance

Stock Tax Calculator

Calculate capital gains tax on stock sales. Estimate federal tax on short-term and long-term gains based on your income and filing status.

$
$
Holding period

Long-term: held more than 1 year. Short-term: 1 year or less.

$
Estimated capital gains tax
$750

15.0% effective tax rate

You'll keep $4,250 of your $5,000 gain after paying $750 in federal taxes.

Purchase price
$10,000
Sale price
$15,000
Capital gain/loss
$5,000
Federal tax (15%)
$750
Total tax
$750
Effective tax rate
15.0%
Net profit after tax
$4,250
Total proceeds
$14,250

Tax breakdown

This is an estimate for federal taxes only. State taxes may apply. Consult a tax professional for personalized advice.

What is capital gains tax on stocks?

Capital gains tax is a federal tax on the profit you make when selling stocks or other investments for more than you paid. When you sell a stock at a higher price than your purchase price, the difference is your capital gain, and the IRS requires you to pay tax on this profit.

The tax system distinguishes between two types of capital gains based on how long you held the investment:

  • Short-term capital gains: Profits from stocks held for one year or less, taxed at ordinary income rates (10-37%)
  • Long-term capital gains: Profits from stocks held for more than one year, taxed at preferential rates (0%, 15%, or 20%)

This distinction creates a significant tax incentive to hold investments for longer periods. A high-income investor selling stock after 11 months might pay 37% tax on their gain, while waiting just one more month could reduce their rate to 20% or even 15%.

How capital gains tax is calculated

The capital gains tax calculation involves several steps:

Capital Gain=Sale PriceCost BasisTax Owed=Capital Gain×Tax Rate\begin{aligned} \text{Capital Gain} &= \text{Sale Price} - \text{Cost Basis} \\[0.5em] \text{Tax Owed} &= \text{Capital Gain} \times \text{Tax Rate} \end{aligned}

Your cost basis is the original purchase price of the stock plus any transaction costs like commissions or fees. If you've reinvested dividends or made additional purchases, your cost basis becomes more complex and may require specific accounting methods like FIFO (first in, first out) or specific identification.

The tax rate depends on:

  1. Whether the gain is short-term or long-term
  2. Your total taxable income for the year
  3. Your filing status (single, married filing jointly, etc.)

Long-term capital gains rates

Long-term capital gains enjoy preferential tax rates that are significantly lower than ordinary income rates:

Tax RateSingle Filers (2025)Married Filing Jointly (2025)Head of Household (2025)
0%Up to $48,350Up to $96,700Up to $64,750
15%$48,351 - $533,400$96,701 - $600,050$64,751 - $566,700
20%Over $533,400Over $600,050Over $566,700

These thresholds are based on your total taxable income, not just your capital gains. If your regular income plus your capital gains pushes you into a higher bracket, part of your gain may be taxed at a higher rate.

Short-term capital gains rates

Short-term gains are added to your ordinary income and taxed at your marginal tax rate. For 2025, the ordinary income brackets are:

Tax RateSingle FilersMarried Filing Jointly
10%Up to $11,925Up to $23,850
12%$11,926 - $48,475$23,851 - $96,950
22%$48,476 - $103,350$96,951 - $206,700
24%$103,351 - $197,300$206,701 - $394,600
32%$197,301 - $250,525$394,601 - $501,050
35%$250,526 - $626,350$501,051 - $751,600
37%Over $626,350Over $751,600

Net Investment Income Tax (NIIT)

High-income investors may also owe an additional 3.8% Net Investment Income Tax on their capital gains. This surtax applies when your modified adjusted gross income exceeds:

  • $200,000 for single filers
  • $250,000 for married filing jointly
  • $125,000 for married filing separately

The NIIT is calculated on the lesser of your net investment income or the amount by which your income exceeds the threshold. This means a single filer with $250,000 in total income and $30,000 in capital gains would owe 3.8% NIIT on $30,000 (the full gain, since it's less than the $50,000 excess over the threshold).

Understanding cost basis

Your cost basis is crucial for accurately calculating capital gains. It includes:

  • Purchase price: The amount you paid for the shares
  • Transaction costs: Commissions, fees, and other purchase-related expenses
  • Reinvested dividends: If you enrolled in a DRIP, those reinvested amounts increase your basis
  • Stock splits and mergers: Corporate actions may adjust your basis

Cost basis methods

When you've purchased the same stock at different times and prices, you need a method to determine which shares you're selling:

FIFO (First In, First Out): The default method assumes you sell your oldest shares first. This often results in higher gains if the stock has appreciated over time.

Specific identification: You choose exactly which shares to sell, potentially minimizing your tax liability by selling higher-cost shares first.

Average cost: Primarily used for mutual funds, this method averages the cost of all shares purchased.

Capital losses and tax-loss harvesting

Not every stock sale results in a gain. When you sell a stock for less than your cost basis, you have a capital loss. These losses can be valuable for tax purposes:

  1. Offset gains: Capital losses first offset capital gains dollar-for-dollar
  2. Deduct against income: If losses exceed gains, you can deduct up to $3,000 per year against ordinary income
  3. Carry forward: Excess losses carry forward to future tax years indefinitely

Tax-loss harvesting is the strategy of intentionally selling losing positions to realize losses that offset gains. This can reduce your current-year tax bill while maintaining your investment position by purchasing a similar (but not identical) investment.

The wash sale rule

The IRS prevents you from claiming a tax loss if you buy "substantially identical" securities within 30 days before or after the sale. This 61-day window (30 days before, the sale day, and 30 days after) is called the wash sale period.

If you trigger a wash sale, your loss is disallowed, but it's added to the cost basis of the replacement shares. You don't lose the benefit permanently—it's deferred until you eventually sell the replacement shares.

Strategies to minimize stock taxes

Hold for more than one year

The most straightforward strategy is simply holding investments for at least one year and one day to qualify for long-term rates. The difference between short-term and long-term rates can be substantial—potentially 17 percentage points for high earners (37% vs. 20%).

Use tax-advantaged accounts

Stocks held in retirement accounts like 401(k)s, IRAs, and Roth IRAs aren't subject to capital gains tax when sold:

  • Traditional accounts: No tax on gains until withdrawal, then taxed as ordinary income
  • Roth accounts: No tax on qualified withdrawals, including gains

Time your sales strategically

Consider your income in any given year when planning sales:

  • Sell in lower-income years when your tax bracket is lower
  • Spread large gains across multiple tax years
  • Realize losses in high-income years for maximum benefit

Gift appreciated stock

Donating appreciated stock to charity allows you to:

  1. Deduct the full fair market value as a charitable contribution
  2. Avoid paying capital gains tax on the appreciation

This is often more tax-efficient than selling the stock, paying the tax, and donating cash.

Qualified Opportunity Zones

Investing capital gains in Qualified Opportunity Zone funds can defer and potentially reduce capital gains taxes, though these investments carry their own risks and require holding periods of at least 10 years for maximum benefit.

Reporting stock sales on your tax return

Stock sales are reported on Schedule D of your tax return, with detailed information on Form 8949. Your broker provides Form 1099-B showing your sales proceeds, and you're responsible for reporting the correct cost basis and calculating gains or losses.

Key forms include:

  • Form 1099-B: Reports gross proceeds from sales
  • Form 8949: Details each sale transaction
  • Schedule D: Summarizes capital gains and losses

Most brokerages now report cost basis to the IRS for stocks purchased after 2011, but you should verify this information and maintain your own records for accuracy.

Special situations

Inherited stock

Stock inherited from a deceased person receives a "stepped-up basis" to the fair market value at the date of death. This eliminates capital gains tax on appreciation that occurred during the decedent's lifetime—a significant tax benefit for heirs.

Gifted stock

When you receive stock as a gift, you generally take the donor's cost basis. However, if the stock's fair market value at the time of the gift is less than the donor's basis, special rules apply to prevent you from claiming a loss.

Employee stock options and RSUs

Stock compensation has unique tax treatment:

  • Incentive Stock Options (ISOs): May qualify for long-term capital gains treatment if holding requirements are met, but may trigger Alternative Minimum Tax
  • Non-Qualified Stock Options (NQSOs): Spread at exercise is taxed as ordinary income
  • Restricted Stock Units (RSUs): Taxed as ordinary income at vesting, with subsequent gains taxed as capital gains

State taxes on stock sales

Federal taxes are just one component of your total tax liability. Many states also tax capital gains:

  • Some states tax at ordinary income rates: California, New Jersey, Oregon
  • Some states have preferential rates: Arizona, New Mexico
  • Some states have no income tax: Florida, Texas, Nevada, Washington, Wyoming

State tax treatment can significantly affect your total tax bill, especially for large gains.

Limitations of this calculator

This calculator provides estimates for federal capital gains tax only. Actual tax liability may vary based on:

  • State income taxes
  • Alternative Minimum Tax (AMT) exposure
  • Specific cost basis of shares sold
  • Other income, deductions, and credits
  • Complex investment structures or corporate actions
  • Wash sale rule implications

For significant investment decisions or complex tax situations, consult a qualified tax professional who can consider your complete financial picture and provide personalized guidance.