Skip to content
CalculatorAI
CalculatorsTrackersDocuments
Open tools
All guidesInvesting

How to Calculate Capital Gains Tax (US Stock & Crypto)

How is capital gains tax calculated in the US? Learn short-term vs. long-term rates, wash-sale rules, and how to report stock and crypto sales.

By CalculatorAI TeamPublished Jul 29, 20268 min read
Modern desktop workstation showing portfolio tax planning screens and documents

When you sell an asset like a stock, exchange-traded fund (ETF), or cryptocurrency for more than you paid for it, the profit is considered a capital gain. In the United States, these gains are subject to capital gains tax.

Understanding how the IRS classifies, nets, and taxes these transactions is essential for planning your tax liability. This guide covers how to distinguish between short-term and long-term gains, how crypto is treated for tax purposes, the rules of netting losses, and the wash-sale restriction.

Realized vs. unrealized gains

Before calculating your tax, you must understand the difference between paper profits and taxable profits:

  • Unrealized gains (Paper profits): If you buy shares of a stock for $1,000 and they rise in value to $1,500, you have a $500 unrealized gain. You do not owe any tax on this amount as long as you keep holding the asset.
  • Realized gains: If you sell those shares for $1,500, you have officially realized a $500 capital gain. This transaction triggers a taxable event that must be reported to the IRS.

Short-term vs. long-term capital gains

The rate at which your capital gains are taxed depends entirely on your holding period — how long you owned the asset before selling it:

  • Short-term capital gains: If you hold an asset for one year or less before selling, your profits are taxed at your standard ordinary income tax rate. These federal rates range from 10% to 37% depending on your total income bracket.
  • Long-term capital gains: If you hold an asset for more than one year before selling, you qualify for discounted tax rates. Long-term capital gains rates are 0%, 15%, or 20%, depending on your taxable income.
Holding PeriodTax RateIncome Bracket Impact
1 Year or LessOrdinary Income Rate (10% – 37%)Taxes match your standard tax bracket
More Than 1 YearDiscounted Rate (0%, 15%, or 20%)Significantly lower tax drag on growth

For most investors, holding an asset past the 12-month mark to qualify for long-term rates is the simplest way to reduce tax liability.

How cryptocurrency is taxed by the IRS

The IRS classifies cryptocurrency as property rather than currency for tax purposes. This means every crypto transaction follows capital gains tax rules:

  • Taxable crypto events:
    • Selling cryptocurrency for fiat currency (USD, EUR, etc.).
    • Trading one cryptocurrency for another (e.g., swapping Bitcoin for Ethereum triggers a tax event on the growth of the swapped Bitcoin).
    • Spending cryptocurrency to buy goods or services (the transaction is treated as selling your crypto at market value to buy the item).
  • Non-taxable crypto events:
    • Purchasing cryptocurrency with fiat currency.
    • Holding cryptocurrency in a wallet.
    • Transferring cryptocurrency between your own wallets (you must track the original cost basis across transfers).

The netting rule: offsetting gains with losses

If you have some winning trades and some losing trades in the same tax year, you do not have to pay tax on the gross gains. The IRS allows you to offset gains with capital losses through a process called "netting":

  1. Net short-term transactions: Offset short-term gains with short-term losses to find your net short-term gain or loss.
  2. Net long-term transactions: Offset long-term gains with long-term losses to find your net long-term gain or loss.
  3. Combine the results: If you have a net loss in one category and a net gain in the other, combine them.

If your total capital losses exceed your total capital gains for the year, you have a net capital loss. You can use up to $3,000 of this net loss to offset ordinary income (like salary) on your tax return. Any remaining losses above $3,000 can be carried forward to offset gains in future tax years indefinitely.

The wash-sale rule: avoid losing tax deductions

If you sell a stock or mutual fund at a loss to harvest a tax deduction, you must watch out for the Wash-Sale Rule under IRS tax codes.

A wash sale occurs if you sell an investment at a loss and buy a "substantially identical" security within 30 days before or after the sale. If you violate this rule:

  • You are not allowed to claim the capital loss on your tax return for that year.
  • Instead, the disallowed loss is added to the cost basis of the new stock you purchased, which delays the tax benefit until you sell the new position.

Note: While the wash-sale rule currently applies to stocks, ETFs, and mutual funds, Congress has proposed legislation to extend it to cryptocurrency. Be sure to consult the official IRS Investment Income and Expenses Guidelines for the latest rules.

Three steps to calculate and track your liability

  • Step 1: Determine your cost basis. Your cost basis is the price you paid to acquire the asset, including any transaction fees. For stocks, your broker will report this on Form 1099-B. For crypto, you must extract this from exchange trade history.
  • Step 2: Run the netting math. Open the Capital Gains Calculator. Enter your purchase price, selling price, transaction fees, and holding period. The calculator will automatically classify your gains and compute the net capital gain or loss.
  • Step 3: Track your portfolios actively. Use the Portfolio Tracker to monitor your asset allocation and unrealized gains. Keeping an eye on your holding periods allows you to avoid accidental short-term sales when waiting a few extra days would cut your tax rate in half.

Frequently asked questions

What is tax-loss harvesting? Tax-loss harvesting is the practice of selling losing investment positions before the end of the calendar year to realize capital losses. These losses are then used to offset taxable capital gains realized on winning trades, lowering your overall tax bill.

How do I report capital gains on my US tax return? You must report individual transactions on IRS Form 8949 (Sales and Other Dispositions of Capital Assets). The totals from Form 8949 are then transferred to Schedule D of your Form 1040 tax return.

Do I owe capital gains tax if I inherit stock or crypto? If you inherit assets, you benefit from a "stepped-up basis." Your cost basis becomes the fair market value of the asset on the date of the previous owner's death, rather than their original purchase price. You do not owe tax until you decide to sell the inherited asset.

Is there a capital gains exemption for selling a primary home? Yes. Under the Section 121 exclusion, if you have owned and lived in your home as your primary residence for at least two of the five years before the sale, you can exclude up to $250,000 of capital gains if you are single, or up to $500,000 if you are married filing jointly.

Share this guide

Know someone who needs this?

Send it over — the guide and every tool in it stay free, no signup to read.

XFacebookLinkedInRedditWhatsAppTelegramPinterestEmail
Previous guideHow to Create a QR Code Menu for Your Restaurant (Free, No App)Next guideHow to Maximize Your 401(k): Match & Contribution Rules

8

Minutes

2

Tools

In this guide

Realized vs. unrealized gainsShort-term vs. long-term capital gainsHow cryptocurrency is taxed by the IRSThe netting rule: offsetting gains with lossesThe wash-sale rule: avoid losing tax deductionsThree steps to calculate and track your liabilityFrequently asked questions

Tools used here

Capital Gains CalculatorCalculate net capital gains or losses, estimate your tax liability, and check holding periods.Portfolio TrackerMonitor cost basis, allocation, and unrealized gains across your investments in real-time.