webdevpuneet.com

Mortgage Payment Breakdown — Free PITI Calculator with Real Amortization

Mortgage Payment Breakdown · Charts · Plain HTML, CSS & JS · Live preview

CategoryCharts

Copy & paste

Source Code

<div class="mpb-card">
  <div class="mpb-head">
    <h3>Monthly payment breakdown</h3>
    <p>Adjust the inputs — the donut and totals recalculate with the real amortization formula.</p>
  </div>

  <div class="mpb-grid">
    <div class="mpb-inputs">
      <label class="mpb-field">
        <span>Home price</span>
        <input type="number" id="mpbPrice" value="420000" min="0" step="1000">
      </label>
      <label class="mpb-field">
        <span>Down payment</span>
        <input type="number" id="mpbDown" value="84000" min="0" step="1000">
      </label>
      <label class="mpb-field">
        <span>Interest rate (APR %)</span>
        <input type="number" id="mpbRate" value="6.5" min="0" step="0.05">
      </label>
      <label class="mpb-field">
        <span>Term (years)</span>
        <select id="mpbTerm">
          <option value="15">15</option>
          <option value="30" selected>30</option>
        </select>
      </label>
      <label class="mpb-field">
        <span>Annual property tax</span>
        <input type="number" id="mpbTax" value="5200" min="0" step="50">
      </label>
      <label class="mpb-field">
        <span>Annual insurance</span>
        <input type="number" id="mpbIns" value="1400" min="0" step="50">
      </label>
    </div>

    <div class="mpb-result">
      <svg class="mpb-donut" viewBox="0 0 120 120" aria-hidden="true">
        <circle class="mpb-track" cx="60" cy="60" r="50" />
        <circle class="mpb-seg" id="mpbSegPrincipal" cx="60" cy="60" r="50" />
        <circle class="mpb-seg" id="mpbSegInterest" cx="60" cy="60" r="50" />
        <circle class="mpb-seg" id="mpbSegTax" cx="60" cy="60" r="50" />
        <circle class="mpb-seg" id="mpbSegIns" cx="60" cy="60" r="50" />
      </svg>
      <div class="mpb-total" id="mpbTotal">$0</div>
      <div class="mpb-total-label">per month</div>

      <ul class="mpb-legend" id="mpbLegend"></ul>
    </div>
  </div>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Real amortization formula
The standard fixed-rate M = P[r(1+r)^n]/[(1+r)^n-1] equation.
Accurate P&I split
Interest computed from the actual outstanding balance, not a guess.
Live donut chart
Four SVG arcs recompute their dasharray/dashoffset on every input change.
Full PITI breakdown
Principal, interest, tax, and insurance shown as distinct slices.
Editable term
15 or 30-year terms recompute the whole schedule.
Zero-rate safe
The formula degrades to a simple division when rate is 0.
Instant recalculation
Every field listens on both input and change events.
Zero dependencies
Pure vanilla JS and SVG, no chart library.

About this UI Snippet

Mortgage Payment Breakdown — A Real PITI Donut Calculator

Screenshot of the Mortgage Payment Breakdown snippet rendered live

Most "mortgage calculator" widgets show a single monthly number and stop there. This one shows the four pieces that number is actually made of — principal, interest, taxes, and insurance (PITI) — on a donut chart that redraws live as home price, down payment, rate, and term change, using the real fixed-rate amortization formula rather than an approximation.

The actual amortization formula

The principal-and-interest portion comes from M = P × [r(1+r)^n] / [(1+r)^n - 1], where P is the loan principal (home price minus down payment), r is the monthly interest rate (annual rate ÷ 12), and n is the total number of monthly payments (years × 12). This is the standard closed-form fixed-rate mortgage payment formula — the same one a bank's own amortization schedule is built from, not a simplified stand-in.

Splitting one payment into principal and interest

A fixed monthly payment doesn't split evenly between principal and interest — early in the loan, interest dominates because the outstanding balance is largest. This snippet computes the first month's actual interest portion as principal × monthlyRate, then derives that month's principal portion as whatever's left of the payment. That's why, on a 30-year loan, the interest slice of the donut is often larger than the principal slice even though both come from the exact same fixed payment.

Tax and insurance, averaged monthly

Property tax and homeowner's insurance are typically billed annually or escrowed, so this snippet takes the annual figures you enter and divides each by 12 to get its monthly share — the same math a loan servicer uses to build a monthly escrow payment. Together with principal and interest, these four pieces sum to the full "PITI" payment shown in the center of the donut.

A donut driven by real dasharray math

The donut is four overlapping SVG circles sharing one center and radius, each using stroke-dasharray (visible arc length, visible-gap) and a stroke-dashoffset that accumulates from the previous segment's share — so the four arcs always tile the full circle exactly, with no gaps or overlaps, regardless of how the underlying dollar amounts shift.

Customizing it

Add PMI (private mortgage insurance, typically required below a 20% down payment) as a fifth slice, or swap the amortization formula for a variable-rate schedule. Pair it with mortgage calculator for a payment-only version, or property listing card for the listing this payment would apply to.

Step by step

How to Use

  1. 1
    Paste HTML, CSS, and JSA donut chart and input panel render with example values.
  2. 2
    Change the home price or down paymentThe loan principal and every slice recalculate.
  3. 3
    Adjust the interest rate or termWatch the principal/interest split shift accordingly.
  4. 4
    Edit tax or insuranceThose two slices grow or shrink independently of the loan math.
  5. 5
    Read the legendEach slice's exact monthly dollar amount is listed below the donut.
  6. 6
    Verify the totalThe center number is the sum of all four slices, PITI in full.

Real-world uses

Common Use Cases

Real estate listing sites
Show buyers the full monthly cost under a property listing card, split into principal, interest, taxes and insurance rather than one unexplained number.
Mortgage lender tools
Give prospects a transparent payment breakdown using the standard fixed-rate formula, so the figures stand up to scrutiny.
First-time buyer education
Demonstrate why interest dominates early payments: the interest portion is computed from the actual outstanding balance, so the donut makes the proportion obvious.
Home affordability checks
Let people change the down payment, rate and term and watch the four arcs recompute live, showing how each input shifts the total.
Refinance comparisons
Toggle rate or term to compare scenarios, and point visitors to the simpler mortgage calculator when they only need a single payment figure.
Related: Seller Rating Breakdown
See the Seller Rating Breakdown for a related charts pattern worth pairing with this one.

Got questions?

Frequently Asked Questions

It's the real, standard fixed-rate amortization formula used by lenders: M = P × [r(1+r)^n] / [(1+r)^n − 1], where P is the loan principal, r is the monthly interest rate, and n is the total number of monthly payments. It is not simplified or approximated.

Because a fixed-rate loan's interest is calculated on the outstanding balance each month, and that balance is largest at the very start of the loan. Early payments are interest-heavy by design — as the balance shrinks over the loan's life, later payments become principal-heavy, even though the total monthly payment stays the same.

PITI stands for Principal, Interest, Taxes, and Insurance — the four components that typically make up a homeowner's full monthly mortgage payment when property tax and insurance are escrowed by the lender. This snippet computes and displays all four as separate donut slices rather than one combined number.

Not by default — PMI is typically required when the down payment is below 20% of the home price and would be a fifth slice. Add it by computing a monthly PMI estimate (commonly 0.5-1% of the loan annually) and including it in the total and the donut's slice list.

Move monthlyPrincipalAndInterest() and the slice-splitting logic into pure functions that take the input values and return the four amounts, then bind those to your framework's state and re-render the SVG stroke-dasharray/dashoffset values reactively instead of writing to the DOM directly.