How Our Calculators Work

Calculator Methodology

Every calculation on TaxGainsCalc is based directly on formulas defined in the Internal Revenue Code and Treasury Regulations. This page documents exactly how each calculator works, which code sections it implements, and where the data comes from.

Our Core Calculation Principle

Every TaxGainsCalc calculator follows one principle: implement the formula exactly as defined in the relevant section of the Internal Revenue Code, using the exact rate tables and thresholds published by the IRS for the applicable tax year. We do not round, approximate, or simplify any calculation. If the IRC specifies a progressive rate structure with specific income thresholds, our calculator implements that structure exactly.

All calculations are performed entirely within your browser. No personal or financial data you enter into any calculator ever leaves your device. We never collect, store, transmit, or have access to your inputs or results. This is not a privacy policy promise — it is a technical fact. The calculators run as client-side JavaScript, and there is no server endpoint that receives your data.

Long-Term Capital Gains Tax Calculator

Primary Source:

Internal Revenue Code Section 1(h) — which defines the preferential tax rates for net capital gain (long-term capital gains). The rates are 0%, 15%, and 20%, applied based on the taxpayer's total taxable income and filing status.

The calculator determines the applicable rate by adding the capital gain to the taxpayer's other taxable income and then applying the rate brackets defined in IRC Section 1(h). The brackets are inflation-adjusted each year. For tax year 2026, the thresholds are:

RateSingle FilersMarried Filing Jointly
0%Up to ~$48,350Up to ~$96,700
15%~$48,350 to ~$525,000~$96,700 to ~$583,750
20%Above ~$525,000Above ~$583,750

The calculator also factors in the 3.8% Net Investment Income Tax (NIIT) defined in IRC Section 1411, which applies when modified adjusted gross income exceeds $200,000 (single) or $250,000 (married filing jointly). The NIIT is calculated on the lesser of (a) net investment income or (b) the excess of MAGI over the threshold.

Our long-term capital gains calculator implements this full progressive structure with NIIT stacking, producing an effective combined federal rate that accounts for both the regular capital gains rate and the NIIT surtax.

Short-Term Capital Gains Tax Calculator

Primary Source:

Internal Revenue Code Section 1(a)-(d) — which defines the ordinary income tax brackets. Short-term capital gains (held for one year or less) are taxed at ordinary income rates, the same brackets that apply to wages and salary.

The calculator applies the ordinary income tax brackets to the taxpayer's total taxable income, including the short-term gain. The 2026 ordinary income brackets are: 10%, 12%, 22%, 24%, 32%, 35%, and 37%. Each bracket has specific income thresholds that vary by filing status and are inflation-adjusted annually.

The NIIT also applies to short-term capital gains under IRC Section 1411 when income exceeds the threshold. Our short-term capital gains calculator computes both the ordinary income tax on the gain and the additional NIIT if applicable.

Stock Capital Gains Calculator

Primary Source:

IRC Section 1001 (determination of gain or loss), IRC Section 1011 (adjusted basis), IRC Section 1012 (cost basis), and IRC Section 1(h) (preferential rates). Cost basis for stocks is established under the regulations implementing IRC Section 1012.

The stock calculator computes gain as: Net Sale Proceeds - Adjusted Cost Basis = Capital Gain. Net sale proceeds account for broker commissions and selling fees. Adjusted cost basis includes the purchase price, purchase commissions, and any adjustments for stock splits, dividend reinvestments, or wash sale disallowed losses.

The holding period (short-term vs. long-term) is determined by IRC Section 1222, which defines a long-term capital gain as gain from the sale of a capital asset held for more than one year. Our stock capital gains calculator implements the full calculation including commission deductions, basis adjustments, and rate determination.

Real Estate Capital Gains Calculator

Primary Source:

IRC Section 121 (home sale exclusion — up to $250,000 single / $500,000 married), IRC Section 1031 (like-kind exchange deferral), IRC Section 1(h)(1)(E) (25% depreciation recapture rate), and IRC Section 1016 (adjustments to basis for depreciation).

The real estate calculator handles three distinct calculations that apply to property sales:

Section 121 exclusion: For primary residences occupied for at least 2 of the 5 years before sale, the calculator applies the $250,000/$500,000 exclusion before calculating the taxable gain.
Depreciation recapture: For investment properties, the calculator separates the depreciation recapture portion (taxed at 25% under IRC Section 1(h)(1)(E)) from the remaining capital gain (taxed at the regular 0%/15%/20% rates).
Cost basis adjustments: The calculator adjusts basis upward for capital improvements (IRC Section 1016) and downward for depreciation deductions claimed over the holding period (IRC Section 1016(a)(2)).

Our real estate calculator and home sale calculator each implement these rules with detailed step-by-step output so you can verify the calculation.

Cryptocurrency Capital Gains Calculator

Primary Source:

IRS Notice 2014-21 (which classifies virtual currency as property for federal tax purposes), IRC Section 1001 (gain/loss determination), IRC Section 1012 (cost basis), and IRC Section 1(h) (preferential rates for long-term holdings).

Under IRS Notice 2014-21, cryptocurrency is treated as property — not currency — for tax purposes. This means every sale, trade, or conversion of cryptocurrency is a taxable event that produces a capital gain or loss. The crypto calculator implements the same gain formula (proceeds minus cost basis) as the stock calculator, with the same rate determination based on holding period and total taxable income.

State Capital Gains Tax Calculations

Primary Source:

State tax codes and revenue department publications for each state. The state rate data on our state rates page is sourced directly from each state's official tax agency website and current year tax forms/instructions.

Most states tax capital gains at the same rate as ordinary income, with no preferential rate for long-term gains. A few states (such as Arizona, Montana, and New Mexico) offer partial exclusions or lower rates. Nine states (Florida, Texas, Nevada, Wyoming, Washington, Alaska, South Dakota, Tennessee, and New Hampshire) have no state income tax at all, meaning your combined rate on long-term gains is simply the federal rate plus the NIIT if applicable.

Our calculators add the state rate to the federal rate and NIIT to show your true combined effective rate. The state data is updated annually from each state's official revenue department publications. The full list of state sources is on our Sources page.

How to Verify Our Calculations

We encourage you to verify our calculator results independently. Here is how:

Check the IRC section: Each calculator page displays the specific IRC section it implements. You can read that section directly at law.cornell.edu/uscode/text/26 (the Legal Information Institute at Cornell University hosts the full text of the Internal Revenue Code).
Compare with IRS publications: IRS Publications 550 and 523 contain the same formulas we implement. You can download them free at irs.gov/forms-instructions.
Test with known results: Use a simple scenario (for example, a $100,000 long-term gain for a single filer with $50,000 other income) and compare our calculator output with your own manual calculation using the 2026 rate brackets.
Report discrepancies: If you find a number that does not match the IRS source, email us at taxgainscalc@gmail.com with the URL and the source document. We will investigate and correct it if we got it wrong. See our Editorial Policy for our full corrections process.