Mortgage Affordability Calculator
Use this calculator to estimate how much home you can afford based on your income, debts, and estimated down payment. This is a helpful tool to understand your potential mortgage limit before you start house hunting.
function calculateAffordability() {
var annualIncome = parseFloat(document.getElementById("annualIncome").value);
var monthlyDebt = parseFloat(document.getElementById("monthlyDebt").value);
var downPayment = parseFloat(document.getElementById("downPayment").value);
var interestRate = parseFloat(document.getElementById("interestRate").value);
var loanTerm = parseFloat(document.getElementById("loanTerm").value);
var propertyTaxesInsurance = parseFloat(document.getElementById("propertyTaxesInsurance").value);
var pmi = parseFloat(document.getElementById("pmi").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(annualIncome) || isNaN(monthlyDebt) || isNaN(downPayment) || isNaN(interestRate) || isNaN(loanTerm) || isNaN(propertyTaxesInsurance) || isNaN(pmi)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
// Lender typically allows PITI (Principal, Interest, Taxes, Insurance) + PMI + other debts to be up to 28%-36% of gross monthly income.
// We'll use a common guideline of 30% for this calculation.
var maxMonthlyHousingPaymentRatio = 0.30; // 30% of gross monthly income
var monthlyIncome = annualIncome / 12;
var maxMonthlyPayment = monthlyIncome * maxMonthlyHousingPaymentRatio;
// Calculate the maximum PITI + PMI that can be afforded
var maxPITI_PMI = maxMonthlyPayment – monthlyDebt;
if (maxPITI_PMI < 0) {
resultDiv.innerHTML = "Your existing monthly debts are too high to qualify for a mortgage based on these figures.";
return;
}
// Components of PITI + PMI
var monthlyTaxesInsurance = propertyTaxesInsurance / 12;
var monthlyPMI = pmi / 12;
// We need to find the maximum loan amount that fits within maxPITI_PMI
// maxPITI_PMI = monthlyPrincipalInterest + monthlyTaxesInsurance + monthlyPMI
var maxMonthlyPrincipalInterest = maxPITI_PMI – monthlyTaxesInsurance – monthlyPMI;
if (maxMonthlyPrincipalInterest < 0) {
resultDiv.innerHTML = "Your estimated taxes, insurance, and PMI are too high for your income and debt to afford any principal and interest payments.";
return;
}
// Mortgage Payment Formula: M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
// Where:
// M = Monthly Payment (maxMonthlyPrincipalInterest)
// P = Principal Loan Amount (what we need to find)
// i = Monthly Interest Rate (annualInterestRate / 12 / 100)
// n = Total number of payments (loanTerm * 12)
var monthlyInterestRate = (interestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
// Rearranging the formula to solve for P:
// P = M * [ (1 + i)^n – 1] / [ i(1 + i)^n ]
var principalLoanAmount = maxMonthlyPrincipalInterest * (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1) / (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments));
var affordableHomePrice = principalLoanAmount + downPayment;
resultDiv.innerHTML =
"Based on your inputs, your estimated maximum affordable home price is:" +
"
$" + affordableHomePrice.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" +
"
This estimate includes your down payment and is based on a guideline of spending up to 30% of your gross monthly income on housing costs (PITI + PMI), minus your existing monthly debt. Lender approval may vary.";
}
.calculator-container {
font-family: sans-serif;
max-width: 600px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
margin-bottom: 15px;
color: #333;
}
.calculator-container p {
line-height: 1.6;
color: #555;
margin-bottom: 20px;
}
.calculator-form .form-group {
margin-bottom: 15px;
display: flex;
flex-direction: column;
}
.calculator-form label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.calculator-form input[type="number"] {
width: calc(100% – 20px);
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
}
.calculator-form button {
width: 100%;
padding: 12px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
font-size: 1.1em;
cursor: pointer;
transition: background-color 0.3s ease;
}
.calculator-form button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 25px;
padding: 15px;
border: 1px solid #e0e0e0;
border-radius: 5px;
background-color: #fff;
text-align: center;
}
.calculator-result p {
margin-bottom: 10px;
color: #333;
}
.calculator-result strong {
font-size: 1.3em;
color: #28a745;
}
.calculator-result em {
font-size: 0.9em;
color: #666;
}
Understanding Mortgage Affordability
Deciding to buy a home is a significant financial decision, and understanding how much you can realistically afford is the crucial first step. A mortgage affordability calculator helps you estimate this by considering various financial factors that lenders and you yourself will use to gauge your borrowing capacity.
Key Factors Influencing Affordability:
- Annual Gross Income: This is the total income you earn before taxes and other deductions. Lenders look at this as the primary source of funds for loan repayment.
- Existing Monthly Debt Payments: This includes all your recurring monthly financial obligations outside of your potential mortgage, such as car loans, student loans, credit card minimum payments, and personal loans. Lower existing debt generally means more capacity for a mortgage.
- Down Payment: The upfront amount you pay towards the home's purchase price. A larger down payment reduces the loan amount needed, which can increase affordability and potentially help you avoid Private Mortgage Insurance (PMI).
- Interest Rate: The percentage charged by the lender on the loan amount. Even small differences in interest rates can significantly impact your monthly payments and the total interest paid over the life of the loan. This calculator uses an estimated annual interest rate.
- Loan Term: The duration over which you agree to repay the loan, typically 15 or 30 years. Shorter loan terms usually result in higher monthly payments but less interest paid overall.
- Property Taxes and Homeowners Insurance: These are essential ongoing costs associated with homeownership. Lenders often include these in your monthly mortgage payment (forming part of PITI: Principal, Interest, Taxes, and Insurance) to ensure they are covered.
- Private Mortgage Insurance (PMI): If your down payment is less than 20% of the home's purchase price, lenders typically require PMI. This protects the lender in case you default on the loan. PMI adds to your monthly housing cost.
How the Calculator Works:
This calculator uses common lending guidelines to estimate your affordability. A widely used rule of thumb is that your total monthly housing expenses (PITI + PMI) should not exceed 28% to 36% of your gross monthly income. For simplicity, this calculator uses a 30% guideline. It first determines the maximum amount you can afford for housing each month, then subtracts your existing monthly debts and estimated annual property taxes, insurance, and PMI (divided by 12 to get the monthly cost). The remaining amount is what's available for your principal and interest payment. Using a standard mortgage payment formula, the calculator then calculates the maximum loan amount you can handle with that principal and interest budget. Finally, it adds your down payment to this loan amount to provide an estimate of the maximum home price you can afford.
Important Considerations:
- This is an ESTIMATE. Actual loan approval depends on a lender's detailed underwriting process, credit score, debt-to-income ratio, employment history, and other financial factors.
- The interest rate you qualify for can vary significantly. It's advisable to get pre-approved by a lender to know your exact borrowing power and interest rate.
- Don't forget other homeownership costs like utilities, maintenance, potential HOA fees, and closing costs, which are not included in this affordability calculation.
Using this mortgage affordability calculator is a smart way to set realistic expectations and prepare for your home-buying journey.