Understanding how much you can afford for a mortgage is a crucial first step in the home-buying process. This calculator helps you estimate your maximum affordable mortgage amount based on your income, debts, and desired loan terms. Remember, this is an estimate, and your actual pre-approval amount may vary based on lender criteria and market conditions.
How Mortgage Affordability is Calculated
Lenders typically use a set of debt-to-income (DTI) ratios to determine how much they are willing to lend you. The most common ratios are the front-end ratio (housing ratio) and the back-end ratio (total debt ratio).
Front-End Ratio (Housing Ratio): This measures the percentage of your gross monthly income that would go towards your potential mortgage payment (principal, interest, taxes, and insurance – PITI). Lenders often prefer this to be no more than 28%.
Back-End Ratio (Total Debt Ratio): This measures the percentage of your gross monthly income that would go towards all your monthly debt obligations, including your potential mortgage payment, credit cards, auto loans, student loans, etc. Lenders often prefer this to be no more than 36%, though this can sometimes be higher depending on your creditworthiness and other factors.
This calculator uses a simplified approach, focusing on the back-end ratio to estimate your maximum affordable mortgage payment. It then works backward to determine the maximum loan amount you could afford based on your desired interest rate and loan term, considering your existing debts and income.
Formula Breakdown:
Maximum Allowable Total Monthly Debt Payment: Gross Monthly Income * 0.36 (This is a common benchmark for the back-end DTI ratio).
Maximum Allowable Mortgage Payment: Maximum Allowable Total Monthly Debt Payment – Monthly Debt Payments.
Loan Amount Calculation: This is derived by solving the standard mortgage payment formula for the principal (loan amount). The formula for the monthly payment (M) is:
$M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]$
Where:
M = Monthly Payment (Maximum Allowable Mortgage Payment)
n = Total Number of Payments (Loan Term in Years * 12)
Rearranging to solve for P:
$P = M [ (1 + i)^n – 1 ] / [ i(1 + i)^n ]$
Maximum Affordable Home Price: Loan Amount + Down Payment.
function calculateMortgageAffordability() {
var grossMonthlyIncome = parseFloat(document.getElementById("grossMonthlyIncome").value);
var monthlyDebtPayments = parseFloat(document.getElementById("monthlyDebtPayments").value);
var downPayment = parseFloat(document.getElementById("downPayment").value);
var interestRate = parseFloat(document.getElementById("interestRate").value);
var loanTermYears = parseFloat(document.getElementById("loanTermYears").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(grossMonthlyIncome) || grossMonthlyIncome <= 0 ||
isNaN(monthlyDebtPayments) || monthlyDebtPayments < 0 ||
isNaN(downPayment) || downPayment < 0 ||
isNaN(interestRate) || interestRate <= 0 ||
isNaN(loanTermYears) || loanTermYears <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
// Define DTI ratio (e.g., 36% for back-end ratio)
var maxDtiRatio = 0.36;
var maxAllowableTotalMonthlyDebt = grossMonthlyIncome * maxDtiRatio;
var maxAllowableMortgagePayment = maxAllowableTotalMonthlyDebt – monthlyDebtPayments;
// Ensure the maximum allowable mortgage payment is not negative
if (maxAllowableMortgagePayment 0 && numberOfPayments > 0) {
var numerator = Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1;
var denominator = monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments);
loanAmount = maxAllowableMortgagePayment * (numerator / denominator);
} else if (numberOfPayments > 0) { // Case for 0% interest rate, though unlikely for mortgages
loanAmount = maxAllowableMortgagePayment * numberOfPayments;
}
// Ensure loan amount is not negative due to calculation issues or extreme inputs
if (loanAmount <= 0) {
resultDiv.innerHTML = "Could not calculate a valid loan amount. Please check your inputs.";
return;
}
var maxAffordableHomePrice = loanAmount + downPayment;
// Format currency for display
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 0,
maximumFractionDigits: 0,
});
resultDiv.innerHTML =
"
Mortgage Affordability Estimate:
" +
"Estimated Maximum Loan Amount: " + formatter.format(loanAmount) + "" +
"Estimated Maximum Affordable Home Price: " + formatter.format(maxAffordableHomePrice) + "" +
"This estimate is based on a 36% back-end Debt-to-Income ratio and does not include potential property taxes, homeowners insurance, or HOA fees in your monthly payment.";
}