1031 Exchange Calculator

Calculate capital gains and depreciation recapture taxes deferred under IRS Section 1031 with 45-day and 180-day deadline dates.

4.9 / 5· 148 verified ratings
•
100% Client-Side Privacy
•
Verified 2026 Engine
Instant Calculation • 100% Client-Side Privacy • Multi-Currency ($ / ₹ / £ / €)
Loading tool engine...
Frequently Used With:Tip & Bill Split Calculator →Salary to Hourly Wage Calculator →Credit Card Payoff & Interest Calculator →SIP & Recurring Investment Calculator →
Institutional-Grade Accuracy & Client-Side Privacy Guarantee

Unlike conventional calculator sites that send your financial numbers, payload data, or code snippets across remote web servers, Affi-Chain processes all mathematical derivations, algorithms, and data parsing 100% locally within your browser sandbox. No tracking cookies, no server-side retention, and zero transmission lag.

Statutory and Tax Law Foundations of IRC Section 1031

Under Section 1031 of the United States Internal Revenue Code (26 U.S.C. § 1031), a Like-Kind Exchange is a statutory tax-deferral mechanism that permits real estate investors to sell an investment property and roll the entire net proceeds into a replacement investment property of equal or greater value without recognizing immediate capital gains tax liabilities.

The Legislative Landscape Post-TCJA

Enacted originally in the Revenue Act of 1921, Section 1031 was significantly reformed by the Tax Cuts and Jobs Act (TCJA) of 2017. The modern statute restricts like-kind exchanges strictly to real property held for productive use in a trade or business, or for investment. Exchanges of personal property, corporate equipment, aircraft, artwork, partnership units, and primary residences are ineligible.

The Power of Perpetual Equity Compounding

When an investor sells real estate in a standard taxable transaction, federal and state tax liabilities routinely confiscate $25% \text{ to } 38%$ of the total profit. By executing a Section 1031 exchange, the investor preserves $100%$ of their accumulated equity, deploying pre-tax capital into larger, higher-cash-flowing commercial or multi-family assets.

In estate planning, this enables the famous strategy colloquially termed "Swap 'til you drop": an investor executes successive 1031 exchanges throughout their lifetime. Upon their death, heirs inherit the property at a Section 1014 stepped-up basis to current fair market value, completely extinguishing decades of deferred capital gains and depreciation recapture taxes.


Detailed Mathematical Formulations and Derivations

1. The Adjusted Tax Basis Equation

The starting point for evaluating capital gain is determining the property’s current adjusted tax basis ($B_{\text{adjusted}}$):

$$B_{\text{adjusted}} = P_{\text{original}} + C_{\text{capex}} - D_{\text{accumulated}}$$

Where:

  • $P_{\text{original}}$ is the original acquisition cost (purchase price plus capitalized acquisition settlement fees).
  • $C_{\text{capex}}$ is the total cost of capital improvements that prolong the property's useful life (e.g., new roof, HVAC overhaul, building additions). Routine maintenance and repairs are excluded.
  • $D_{\text{accumulated}}$ is the cumulative depreciation claimed (or allowable, whether actually claimed or not) during ownership. Under the Modified Accelerated Cost Recovery System (MACRS), residential rental property is depreciated straight-line over 27.5 years ($3.636%/\text{year}$), while non-residential commercial property is depreciated over 39 years ($2.564%/\text{year}$) (land value is non-depreciable).

2. Realized Gain vs. Recognized Gain

A strict legal distinction governs 1031 taxation:

  • Realized Gain: The total economic profit generated by the sale: $$\text{Realized Gain} = \text{Net Selling Price} - B_{\text{adjusted}}$$ Where $\text{Net Selling Price} = \text{Gross Contract Price} - \text{Permissible Closing Costs}$ (brokerage commissions, title insurance, transfer taxes, recording fees, QI escrow fees).
  • Recognized Gain: The portion of the realized gain that is immediately taxable in the current filing year. In a fully compliant exchange with zero boot, $\text{Recognized Gain} = \mathbf{$0.00}$.

3. The Four Distinct Tax Layers Deferred in a 1031 Exchange

When real estate is liquidated without an exchange, realized gain is taxed across four cumulative federal and state layers:

$$\text{Total Tax Liability} = T_{\text{deprec}} + T_{\text{cg}} + T_{\text{niit}} + T_{\text{state}}$$

  1. Depreciation Recapture Tax ($T_{\text{deprec}}$): Under IRC Section 1250, the entire portion of the gain attributable to historical depreciation deductions is recaptured and taxed at a flat federal rate of $25.0%$: $$T_{\text{deprec}} = \min(\text{Realized Gain}, ; D_{\text{accumulated}}) \times 0.25$$
  2. Federal Long-Term Capital Gains Tax ($T_{\text{cg}}$): The remaining economic appreciation above the original purchase basis is taxed under standard capital gains brackets ($15.0%$ or $20.0%$, depending on taxable income): $$T_{\text{cg}} = \max(0, ; \text{Realized Gain} - D_{\text{accumulated}}) \times 0.20$$
  3. Net Investment Income Tax (NIIT - $T_{\text{niit}}$): Under Section 1411 of the Affordable Care Act, high earners (MAGI $> $200,000$ single, $> $250,000$ married filing jointly) incur an additional $3.8%$ Medicare surtax on net investment income: $$T_{\text{niit}} = \text{Realized Gain} \times 0.038$$
  4. State and Local Income Tax ($T_{\text{state}}$): State tax liabilities range from $0.0%$ (in Florida, Texas, Nevada, Tennessee, Wyoming) up to $13.3%$ in California, $10.9%$ in New York, and $9.9%$ in Oregon.

Boot and Partial Tax Recognition

If an exchanger fails to reinvest 100% of the net cash proceeds or fails to acquire a replacement property of equal or greater debt, the shortfall creates taxable "Boot":

  • Cash Boot ($B_{\text{cash}}$): Any net sale proceeds distributed directly to the investor rather than transferred to the Qualified Intermediary (QI).
  • Mortgage (Debt Relief) Boot ($B_{\text{debt}}$): Occurs when the mortgage liability on the replacement property is smaller than the debt paid off on the relinquished property, unless offset by adding outside out-of-pocket cash: $$B_{\text{debt}} = \max\left(0, ; M_{\text{relinquished}} - M_{\text{replacement}} - \text{Cash Added}\right)$$

Total Boot is: $$\text{Total Boot} = B_{\text{cash}} + B_{\text{debt}}$$

Under Treasury Regulations, gain is recognized up to the amount of boot received:

$$\text{Recognized Taxable Gain} = \min(\text{Realized Gain}, ; \text{Total Boot})$$

$$\text{Deferred Gain} = \text{Realized Gain} - \text{Recognized Gain}$$

Basis of the Replacement Property

The tax basis of the newly acquired replacement property is adjusted to preserve the deferred gain for future accounting:

$$B_{\text{replacement}} = P_{\text{replacement purchase price}} - \text{Deferred Gain}$$


Strict IRS Safe Harbor Timelines and Identification Rules

Section 1031 imposes strict statutory deadlines enforced without exception:

1. The 45-Day Identification Window

The investor must formally identify prospective replacement properties in writing to the Qualified Intermediary by midnight of the 45th calendar day following the closing of the relinquished property. The deadline is absolute (no extensions for weekends or holidays).

The identification must comply with one of three statutory rules:

  • The 3-Property Rule: The investor may identify up to three properties of any market value, regardless of aggregate price.
  • The 200% Rule: If identifying four or more properties, the combined aggregate market value of all identified properties cannot exceed 200% of the gross sale price of the relinquished property.
  • The 95% Exception Rule: If identifying four or more properties exceeding 200% value, the investor must actually acquire and close title on at least 95% of the total aggregate value identified.

2. The 180-Day Exchange Completion Window

The investor must acquire and close title on one or more of the formally identified replacement properties by the earlier of:

  • 180 calendar days after the date of closing of the relinquished property.
  • The due date (including filed extensions) of the taxpayer’s federal income tax return for the tax year in which the transfer occurred.

3. The Constructive Receipt Doctrine & Qualified Intermediaries (QI)

Under Treasury Regulation § 1.1031(k)-1(g)(4), the taxpayer must never have actual or constructive receipt of the sale proceeds. If the seller or their agent (attorney, CPA, broker) takes possession of the funds for even a single second, the 1031 exchange is permanently disqualified, and the full gain becomes immediately taxable.

The funds must be held continuously in a segregated escrow account by an independent bonded Qualified Intermediary (QI).


Production Implementations

Python: Full-Featured Section 1031 Exchange Tax Engine

from dataclasses import dataclass
from typing import Dict, Any

@dataclass
class RelinquishedProperty:
    gross_selling_price: float
    selling_expenses: float
    original_purchase_price: float
    capital_improvements: float
    accumulated_depreciation: float
    mortgage_payoff: float

@dataclass
class ReplacementProperty:
    purchase_price: float
    new_mortgage_amount: float
    cash_added_out_of_pocket: float = 0.0

class Exchange1031Calculator:
    @staticmethod
    def calculate_exchange(relinq: RelinquishedProperty,
                           replace: ReplacementProperty,
                           state_tax_rate_pct: float = 8.0,
                           federal_cg_rate_pct: float = 20.0,
                           apply_niit: bool = True) -> Dict[str, Any]:
        """
        Computes adjusted basis, realized gain, cash/mortgage boot,
        recognized vs deferred gain, multi-tier tax savings, and replacement basis.
        """
        # 1. Net Selling Price & Adjusted Basis
        net_selling_price = relinq.gross_selling_price - relinq.selling_expenses
        adjusted_basis = (relinq.original_purchase_price + 
                          relinq.capital_improvements - 
                          relinq.accumulated_depreciation)

        realized_gain = max(0.0, net_selling_price - adjusted_basis)

        # 2. Equity and Cash Proceeds available to QI
        net_cash_proceeds_to_qi = net_selling_price - relinq.mortgage_payoff

        # 3. Boot Analysis
        # Cash boot: cash from QI not used toward replacement purchase
        cash_required_for_replace = replace.purchase_price - replace.new_mortgage_amount - replace.cash_added_out_of_pocket
        cash_boot = max(0.0, net_cash_proceeds_to_qi - cash_required_for_replace)

        # Mortgage / Debt Relief boot
        debt_relief = max(0.0, relinq.mortgage_payoff - replace.new_mortgage_amount - replace.cash_added_out_of_pocket)
        total_boot = cash_boot + debt_relief

        # 4. Recognized vs Deferred Gain
        recognized_gain = min(realized_gain, total_boot)
        deferred_gain = realized_gain - recognized_gain

        # 5. Multi-Tier Tax Liability Calculation (What WOULD be paid without 1031)
        niit_rate = 0.038 if apply_niit else 0.0
        state_rate = state_tax_rate_pct / 100.0
        fed_cg_rate = federal_cg_rate_pct / 100.0

        deprec_recapture_portion = min(realized_gain, relinq.accumulated_depreciation)
        pure_capital_gain_portion = max(0.0, realized_gain - deprec_recapture_portion)

        tax_deprec_recapture = deprec_recapture_portion * 0.25
        tax_federal_cg = pure_capital_gain_portion * fed_cg_rate
        tax_niit = realized_gain * niit_rate
        tax_state = realized_gain * state_rate

        total_potential_tax = tax_deprec_recapture + tax_federal_cg + tax_niit + tax_state

        # Taxes owed immediately on recognized boot (pro-rata distribution)
        boot_ratio = recognized_gain / realized_gain if realized_gain > 0 else 0.0
        immediate_tax_owed = total_potential_tax * boot_ratio
        net_taxes_deferred = total_potential_tax - immediate_tax_owed

        # 6. New Replacement Property Basis
        replacement_tax_basis = replace.purchase_price - deferred_gain

        return {
            "net_selling_price": round(net_selling_price, 2),
            "adjusted_tax_basis": round(adjusted_basis, 2),
            "total_realized_gain": round(realized_gain, 2),
            "total_boot_received": round(total_boot, 2),
            "recognized_taxable_gain": round(recognized_gain, 2),
            "deferred_capital_gain": round(deferred_gain, 2),
            "depreciation_recapture_deferred": round(deprec_recapture_portion * (1 - boot_ratio), 2),
            "total_tax_deferred": round(net_taxes_deferred, 2),
            "immediate_tax_liability": round(immediate_tax_owed, 2),
            "replacement_property_new_basis": round(replacement_tax_basis, 2),
            "is_fully_tax_deferred": recognized_gain == 0.0
        }

# Validation
if __name__ == "__main__":
    sold_building = RelinquishedProperty(
        gross_selling_price=1_500_000.0,
        selling_expenses=90_000.0,
        original_purchase_price=800_000.0,
        capital_improvements=100_000.0,
        accumulated_depreciation=250_000.0,
        mortgage_payoff=500_000.0
    )
    new_building = ReplacementProperty(
        purchase_price=2_000_000.0,
        new_mortgage_amount=1_100_000.0,
        cash_added_out_of_pocket=0.0
    )
    summary = Exchange1031Calculator.calculate_exchange(sold_building, new_building, state_tax_rate_pct=9.3)
    for k, v in summary.items():
        print(f"{k}: {v}")

TypeScript: Comprehensive Section 1031 Engine

export interface ExchangeInputs {
  grossSalePrice: number;
  closingCosts: number;
  originalCost: number;
  capitalImprovements: number;
  accumulatedDepreciation: number;
  oldMortgage: number;
  replacementPrice: number;
  newMortgage: number;
  stateTaxRatePct?: number;
}

export interface ExchangeResults {
  realizedGain: number;
  totalBoot: number;
  recognizedGain: number;
  deferredGain: number;
  totalTaxDeferred: number;
  immediateTaxDue: number;
  newReplacementBasis: number;
  isFullExchange: boolean;
}

export function compute1031Exchange(inputs: ExchangeInputs): ExchangeResults {
  const {
    grossSalePrice,
    closingCosts,
    originalCost,
    capitalImprovements,
    accumulatedDepreciation,
    oldMortgage,
    replacementPrice,
    newMortgage,
    stateTaxRatePct = 8.0,
  } = inputs;

  const netSalePrice = grossSalePrice - closingCosts;
  const adjustedBasis = originalCost + capitalImprovements - accumulatedDepreciation;
  const realizedGain = Math.max(0, netSalePrice - adjustedBasis);

  const netCashToQi = netSalePrice - oldMortgage;
  const cashNeeded = replacementPrice - newMortgage;
  const cashBoot = Math.max(0, netCashToQi - cashNeeded);
  const debtRelief = Math.max(0, oldMortgage - newMortgage);
  const totalBoot = cashBoot + debtRelief;

  const recognizedGain = Math.min(realizedGain, totalBoot);
  const deferredGain = realizedGain - recognizedGain;

  // Potential tax without exchange
  const deprecPortion = Math.min(realizedGain, accumulatedDepreciation);
  const capGainPortion = Math.max(0, realizedGain - deprecPortion);

  const taxDeprec = deprecPortion * 0.25;
  const taxCapGain = capGainPortion * 0.20;
  const taxNiit = realizedGain * 0.038;
  const taxState = realizedGain * (stateTaxRatePct / 100);
  const potentialTax = taxDeprec + taxCapGain + taxNiit + taxState;

  const bootRatio = realizedGain > 0 ? recognizedGain / realizedGain : 0;
  const immediateTaxDue = potentialTax * bootRatio;
  const totalTaxDeferred = potentialTax - immediateTaxDue;
  const newReplacementBasis = replacementPrice - deferredGain;

  return {
    realizedGain: Math.round(realizedGain),
    totalBoot: Math.round(totalBoot),
    recognizedGain: Math.round(recognizedGain),
    deferredGain: Math.round(deferredGain),
    totalTaxDeferred: Math.round(totalTaxDeferred),
    immediateTaxDue: Math.round(immediateTaxDue),
    newReplacementBasis: Math.round(newReplacementBasis),
    isFullExchange: recognizedGain === 0,
  };
}

Comparison Matrix: Commercial Real Estate Exit Strategies

StrategyUpfront Tax DragEquity PreservationLiquidity & Control1014 Stepped-Up Basis at Death?
Taxable Sale25% - 38% tax confiscationImmediate loss of 1/3 of equity100% Cash liquidityNo (Taxes paid immediately)
Section 1031 Exchange0% Tax (100% Deferred)100% Equity CompoundedTied to active real estate managementYes! (Stepped up to fair market value)
Delaware Statutory Trust (DST)0% Tax (1031 Compliant)100% Equity CompoundedCompletely passive institutional real estateYes!
Section 721 UPREIT0% Tax (Roll into REIT OP Units)100% Equity CompoundedLiquid publicly traded REIT sharesYes!
Qualified Opportunity Zone (QOZ)Deferral until 2026; tax-free post-10yHighIlliquid 10-year lockup periodPartial

Critical Traps and Compliance Edge Cases

1. The Primary Residence / Vacation Home Disqualification

Section 1031 strictly excludes personal residences and recreational vacation homes. However, under IRS Revenue Procedure 2008-16 Safe Harbor, a dwelling can qualify as like-kind property if:

  1. The property is owned by the taxpayer for at least 24 months prior to or post-exchange.
  2. In each of the two 12-month periods, the property is rented at fair market value for at least 14 days.
  3. Personal recreational use of the home does not exceed the greater of 14 days or 10% of the total days rented in each 12-month period.

2. Partnership "Drop-and-Swap" Vulnerability

When a multi-member LLC owns real estate and several partners want to execute a 1031 exchange while others want cash out, the partnership cannot simply distribute cash to some members. Under Section 1031, partnership units are explicitly ineligible. To structure legally, CPAs execute a "Drop-and-Swap", deeding fractional tenant-in-common (TIC) real property interests to individual members prior to the exchange, allowing each partner to independently select their tax path.

Frequently Asked Questions

What are the two critical deadlines for a 1031 exchange?
From the closing date of the sold property, you have exactly 45 calendar days to formally identify replacement properties in writing, and a total of 180 calendar days (or the due date of your tax return) to close on the purchase.
What is "boot" in a 1031 exchange?
Boot is non-like-kind property received in an exchange, such as leftover cash (cash boot) or debt reduction when buying a cheaper replacement property (mortgage boot). Boot is taxable up to the amount of realized gain.
How does 1031 exchange defer depreciation recapture?
Section 1031 defers both federal/state capital gains taxes and the 25% unrecaptured Section 1250 depreciation tax by rolling your existing cost basis forward into the replacement property.

Explore Related Utilities