Use this calculator to estimate how much mortgage you can afford. Understanding your potential borrowing power is a crucial first step in your home-buying journey. Several factors influence how much a lender will be willing to lend you, including your income, debts, credit score, and the current interest rates. This calculator provides an estimate based on common lending guidelines.
.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;
color: #333;
margin-bottom: 15px;
}
.calculator-container p {
color: #555;
line-height: 1.6;
margin-bottom: 20px;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-group input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
.calculator-container button {
display: block;
width: 100%;
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 1.1rem;
cursor: pointer;
transition: background-color 0.3s ease;
}
.calculator-container button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 20px;
padding: 15px;
background-color: #e9ecef;
border: 1px solid #ced4da;
border-radius: 4px;
text-align: center;
font-size: 1.2rem;
color: #333;
}
function calculateAffordability() {
var annualIncome = parseFloat(document.getElementById("annualIncome").value);
var monthlyDebtPayments = parseFloat(document.getElementById("monthlyDebtPayments").value);
var downPayment = parseFloat(document.getElementById("downPayment").value);
var interestRate = parseFloat(document.getElementById("interestRate").value) / 100;
var loanTerm = parseFloat(document.getElementById("loanTerm").value);
var resultDiv = document.getElementById("result");
if (isNaN(annualIncome) || isNaN(monthlyDebtPayments) || isNaN(downPayment) || isNaN(interestRate) || isNaN(loanTerm) ||
annualIncome <= 0 || monthlyDebtPayments < 0 || downPayment < 0 || interestRate < 0 || loanTerm <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
// Common lending guidelines suggest a Debt-to-Income (DTI) ratio of around 36% for front-end (housing costs)
// and 43% for back-end (total debt). We'll use the 36% for housing affordability estimation.
var maxMonthlyHousingPayment = (annualIncome / 12) * 0.36;
// Subtract existing debt payments from the total allowed debt payment to find what's left for mortgage
var maxMortgagePayment = maxMonthlyHousingPayment – monthlyDebtPayments;
if (maxMortgagePayment 0) {
// Formula for maximum loan amount based on payment, rate, and term
// M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
// P = M [ (1 + i)^n – 1] / [ i(1 + i)^n ]
maxLoanAmount = maxMortgagePayment * (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1) / (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments));
} else {
// If interest rate is 0, the loan amount is simply the payment times the number of payments
maxLoanAmount = maxMortgagePayment * numberOfPayments;
}
// The total affordable home price is the maximum loan amount plus the down payment
var affordableHomePrice = maxLoanAmount + downPayment;
resultDiv.innerHTML = "Estimated Maximum Affordable Home Price: $" + affordableHomePrice.toFixed(2);
}