Mortgage and Rent Retirement Calculator
Is it better to rent or buy a home? This is a difficult question given that better is a subjective term. This calculator aims to clarify the tradeoffs and surface actionable retirement outcomes for users.
Motivation
A few years ago, I was trying to decide whether to rent or buy a home. Some tell you that buying is always better since renting causes you to throw away money on rent, while mortgage payments build equity. Others say that renting is better since investments in the stock market will outperform real estate over time. Both sides make compelling arguments, and I found myself confused about which option was actually better for me.
Approach - Value of Money
Let's say you have $200k to put down on a house. How valuable is having that money for an emergency? Or how about just spending the money on a boat? Or spending a third on a nice car, and investing the rest?
Because different people prefer to spend their money differently, it is helpful to pick a single point in time to compare the two options. This calculator uses your retirement date as that point in time.

The retirement outcome calculations assume the user invests every penny saved by not choosing the other option. You might not choose to invest all of your money this way, but the value to you of being able to spend it however you choose will be roughly equal to the potential investment gains you could have earned.
Short Term Considerations - Monthly Losses

In addition to comparing retirement outcomes, this calculator also shows the monthly asset losses of buying a home. Some of your mortgage goes back to you in the form of equity, but there are also many costs that do not. Property taxes, insurance, interest, and HOA take money from your pocket that you will never get back. These costs are summarized in the monthly losses section.
Math
You can see all the math in the GitHub README here! By using math tricks, this calculator avoids summing over every month from now until retirement date. Instead, it uses formulas to calculate the future value of investments and the amortization of a mortgage. This makes the calculator fast and reactive, even on mobile devices.