First decide whether this sale is taxable at all
This workflow is for a US taxpayer selling stock in a taxable brokerage account. A sale inside an IRA, 401(k), or another tax-advantaged account follows different rules, and an investor who is not a US tax resident needs the rules of the country where they file.
The estimate below starts with federal income tax. State and local taxes can materially change the result, so treat them as a separate input instead of assuming that a federal estimate is the final bill.
Calculate the gain before applying a tax rate
Start with net sale proceeds: sale price multiplied by shares sold, minus selling commissions and fees. Then subtract the adjusted cost basis assigned to those shares. The result is the capital gain or loss; tax is not charged on the full sale value.
Adjusted basis usually begins with purchase price plus acquisition costs, but it can change after stock splits, return-of-capital distributions, reinvested dividends, gifts, inheritances, option assignments, or prior wash-sale adjustments. The IRS requires investors to maintain records that support basis, especially when a broker reports a security as noncovered.
Choose the shares being sold, not just the ticker
If you bought the same stock on several dates, each purchase is a tax lot with its own basis and holding period. Proper specific identification can assign the sale to chosen lots; otherwise the broker and tax rules may apply a default such as first-in, first-out. Confirm the lot instruction with the broker when the order is placed.
The lot choice can change both the size and character of the gain. A high-basis lot may create a smaller gain, while an older lot may qualify as long-term. A useful pre-sale estimate therefore needs quantity, acquisition date, basis, and intended sale quantity for every lot that may be sold.
Separate short-term and long-term results
The IRS generally treats an asset held for more than one year as long-term and an asset held for one year or less as short-term. Net short-term gains are taxed at ordinary income rates, while net long-term gains may receive lower capital-gains rates based on taxable income.
Do not multiply one sale by a headline rate and call it exact. Capital gains are netted across the year, prior capital-loss carryovers may apply, and a large gain can cross income thresholds. High investment income may also trigger the 3.8% Net Investment Income Tax, while state rules vary by residence.
Net the whole tax year before estimating the bill
Add year-to-date realized gains and losses, separating short-term from long-term amounts, then include any capital-loss carryover. The federal return nets these categories in stages before arriving at the net capital gain or loss reported through Form 8949 and Schedule D.
If losses exceed gains, the federal deduction against other income is generally limited to $3,000, or $1,500 for married filing separately, with the remaining loss carried forward. That means a loss can reduce the estimate, but it does not always create an immediate cash tax benefit of the same size.
Check for a wash sale before counting a loss
A loss may be disallowed for the current year if substantially identical stock or securities are purchased within 30 days before or after the loss sale. The disallowed loss is generally added to the replacement shares' basis rather than disappearing permanently.
Look across accounts, automatic dividend reinvestments, and a spouse's transactions where relevant. A calculator that sees only the proposed sale cannot reliably detect every wash sale, so the user must confirm replacement purchases before treating the loss as available.
Worked example: the same gain can have two estimates
Assume net proceeds of $4,800 and an adjusted basis of $3,000. The capital gain is $1,800. At an illustrative 15% long-term federal rate, estimated federal tax is $270 and cash remaining from the sale after that estimate is $4,530.
If the same $1,800 is short-term and the investor uses an illustrative 24% ordinary rate, estimated federal tax is $432 and cash remaining is $4,368. NIIT, state tax, other gains and losses, and income thresholds are still excluded, so these are planning scenarios rather than a filed-tax result.
What a useful pre-sale screen should ask and show
Inputs should include tax residence, account type, filing status, estimated taxable income, state, shares to sell, sale price, selling fees, tax lots, year-to-date short- and long-term gains or losses, carryovers, and possible replacement purchases. The result should show proceeds, assigned basis, gain or loss, holding-period mix, assumed rates, estimated federal tax, NIIT and state placeholders, and after-tax sale cash.
Official references: IRS Topic No. 409, Capital Gains and Losses (irs.gov/taxtopics/tc409); IRS Stocks FAQ on basis records and Form 1099-B (irs.gov/faqs/capital-gains-losses-and-sale-of-home/stocks-options-splits-traders/stocks-options-splits-traders-1); and IRS Publication 550. This guide is an educational estimate, not tax advice or a substitute for a return prepared from complete records.
