Use this calculator to estimate how much house you can afford based on your income, debts, and down payment. It's important to remember that this is an estimate, and lenders will consider many other factors when determining your actual loan amount.
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) / 100;
var loanTerm = parseInt(document.getElementById("loanTerm").value);
var propertyTaxRate = parseFloat(document.getElementById("propertyTaxRate").value) / 100;
var homeInsuranceRate = parseFloat(document.getElementById("homeInsuranceRate").value) / 100;
var pmiRate = parseFloat(document.getElementById("pmiRate").value) / 100;
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = "";
if (isNaN(annualIncome) || isNaN(monthlyDebt) || isNaN(downPayment) || isNaN(interestRate) || isNaN(loanTerm) || isNaN(propertyTaxRate) || isNaN(homeInsuranceRate) || isNaN(pmiRate)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
// Lender's DTI (Debt-to-Income) Ratio Guidelines (common benchmarks)
// Front-end DTI (housing costs) typically around 28% of gross income
// Back-end DTI (all debts) typically around 36-43% of gross income
var maxHousingPaymentRatio = 0.28;
var maxTotalDebtRatio = 0.36; // Example, can vary
var grossMonthlyIncome = annualIncome / 12;
var maxMonthlyHousingPayment = grossMonthlyIncome * maxHousingPaymentRatio;
var maxTotalMonthlyObligations = grossMonthlyIncome * maxTotalDebtRatio;
var maxMonthlyMortgagePayment = maxTotalMonthlyObligations – monthlyDebt;
// Determine the most limiting monthly payment
var maxAffordableMonthlyPayment = Math.min(maxMonthlyHousingPayment, maxMonthlyMortgagePayment);
if (maxAffordableMonthlyPayment <= 0) {
resultDiv.innerHTML = "Based on your income and existing debts, you may not qualify for a mortgage at this time. Consider reducing debt or increasing income.";
return;
}
// We need to work backwards from the monthly payment to find the loan amount.
// The monthly payment includes P&I (Principal & Interest), Taxes, Insurance, and PMI.
// M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
// Where:
// M = Monthly Payment
// P = Principal Loan Amount
// i = monthly interest rate (annual rate / 12)
// n = total number of payments (loan term in years * 12)
var monthlyInterestRate = interestRate / 12;
var numberOfPayments = loanTerm * 12;
var loanAmount = 0;
// Iterative approach to find loan amount because taxes, insurance, and PMI are based on the home price/loan amount.
// We'll assume an initial loan amount and refine it.
var estimatedHomePrice = (downPayment + 100000); // Initial guess for home price
var maxIterations = 100;
var tolerance = 0.01;
for (var i = 0; i < maxIterations; i++) {
var currentLoanAmount = estimatedHomePrice – downPayment;
if (currentLoanAmount 0 && downPayment / estimatedHomePrice < 0.20) {
monthlyPMI = (currentLoanAmount * pmiRate) / 12;
}
var totalMonthlyCosts = monthlyPropertyTax + monthlyHomeInsurance + monthlyPMI;
var remainingForPI = maxAffordableMonthlyPayment – totalMonthlyCosts;
if (remainingForPI 0 && numberOfPayments > 0) {
calculatedPI = remainingForPI * (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1) / Math.pow(1 + monthlyInterestRate, numberOfPayments) / monthlyInterestRate;
} else if (remainingForPI > 0) {
calculatedPI = remainingForPI * numberOfPayments; // Simple interest if rate is 0
}
var newLoanAmount = calculatedPI;
var newHomePrice = newLoanAmount + downPayment;
if (Math.abs(newHomePrice – estimatedHomePrice) < tolerance) {
estimatedHomePrice = newHomePrice;
loanAmount = newLoanAmount;
break;
}
estimatedHomePrice = newHomePrice;
if (i === maxIterations – 1) {
// If loop finishes without convergence, use the last estimate
loanAmount = estimatedHomePrice – downPayment;
if (loanAmount < 0) loanAmount = 0;
}
}
var affordableHomePrice = loanAmount + downPayment;
if (affordableHomePrice <= downPayment) {
resultDiv.innerHTML = "It appears that with your current income, debts, and the estimated costs (taxes, insurance, PMI), your maximum affordable home price is less than or equal to your down payment. Please review your inputs or consider a larger down payment or lower estimated costs.";
return;
}
resultDiv.innerHTML = `