About the Rent vs. Buy Calculator

Should you buy, or keep renting and invest the difference? A side-by-side net-worth projection.

What This Is

Enter a home price, your down payment, the mortgage rate, and what you would otherwise pay in rent. The calculator tells you whether buying or renting-and-investing leaves you with more money, and the year buying pulls ahead. It assumes both paths put the same cash in on the same schedule (your down payment up front, then the difference between owning and renting each month); the only thing that differs is where the money ends up: home equity for the buyer, an investment portfolio for the renter.

Under the hood it runs a full month-by-month mortgage and a 35-year projection of home value, property tax, insurance, maintenance, the mortgage-interest and SALT tax benefit, and the after-tax return a renter would earn on the same money. Everything runs in your browser. Nothing is typed, stored, or sent anywhere.

Architecture at a Glance

1. resolved inputs 2. 35-year projection Your inputs ~20 fields, $ / % toggles computeModel() 360-month amortization, 35-year cash flow, tax, net worth + IRR per side Live results summary cards, net-worth chart, cash-flow & amortization tables
Browser (UI) Calculation engine

Single-headed arrows show one-way data flow. The numbers match the steps below. Every box runs in the same browser tab; there is no server.

What Happens When You Change an Input

  1. The component reads every field and resolves the $ / % toggles into consistent numbers (a percent entry becomes a fraction of the purchase price), then passes those resolved inputs to the model.
  2. computeModel() builds a 360-month amortization schedule: each month's interest is the balance times the monthly rate, the rest of the payment pays down principal, and any extra monthly payment shortens the loan.
  3. It walks 35 years forward: the home appreciates, carrying costs and the equivalent rent compound, the mortgage-interest and property-tax write-off (property tax limited by the SALT cap, measured against the standard deduction) becomes a tax saving, and a renter invests the identical cash at the expected return.
  4. It derives each side's net worth, money-weighted return (IRR), and the break-even year, then hands the 35-year projection back to the page, which redraws the summary cards, the net-worth chart, and the two detail tables together.

Where the Computation Happens

All of it happens client-side, in one JavaScript file. There is no API call, no database, and no build step beyond copying the file into the site. The model is plain arithmetic (an Excel-equivalent PMT, an amortization loop, annual compounding, and a bisection solver for the IRR), so a full recompute on every keystroke takes well under a millisecond. The result is that the chart, the verdict, and both tables update instantly as you drag a slider or flip a toggle.

Tech Stack

LayerTools
ComponentOne vanilla <rent-vs-buy> custom element (Web Components, Shadow DOM); no framework
MathPlain JavaScript: Excel-equivalent PMT, amortization, compounding, and a bisection IRR solver
ChartHTML5 Canvas, hand-drawn (no charting library)
HostingStatic files on an Eleventy site; no backend, near-zero cost
OriginPorted from a macro-enabled Excel workbook and verified against the workbook's own computed values

Who This Is For

This is built for one person: someone renting their primary residence who is weighing buying a home to live in as an economic alternative. It is not a tool for high-income earners with complex tax situations, and it is not for investment or rental property (no rental income, depreciation, or passive-activity rules are modeled). A few deliberate simplifications follow from that scope: the high-income SALT phase-out is not modeled (lower the SALT input by hand to approximate it), interest on the full loan is treated as deductible (federal rules cap this at the first $750,000 of debt), and the home sale is assumed tax-free under the primary-residence exclusion while the renter's investment gains are taxed. Treat the break-even year as a directional signal, not a guarantee.

Source Code

The entire calculator (model and UI) lives in a single file: github.com/JackVance/rent-vs-buy-calculator/blob/main/src/rent-vs-buy.js