Use this calculator to estimate how much you can afford for a mortgage based on your income, debts, and estimated interest rate.
.calculator-container {
font-family: Arial, sans-serif;
max-width: 500px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
margin-bottom: 15px;
color: #333;
}
.calculator-container p {
text-align: center;
margin-bottom: 20px;
color: #555;
font-size: 0.9em;
}
.input-section {
display: grid;
grid-template-columns: 1fr;
gap: 15px;
margin-bottom: 20px;
}
.input-section label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #333;
}
.input-section input[type="number"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box; /* Important for consistent sizing */
}
button {
width: 100%;
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
.result-section {
margin-top: 25px;
padding: 15px;
border-top: 1px solid #eee;
text-align: center;
background-color: #e9ecef;
border-radius: 4px;
color: #333;
font-size: 1.1em;
min-height: 50px; /* To prevent layout shift */
}
.result-section p {
margin: 5px 0;
}
function calculateMortgageAffordability() {
var annualIncome = parseFloat(document.getElementById("annualIncome").value);
var monthlyDebt = parseFloat(document.getElementById("monthlyDebt").value);
var downPayment = parseFloat(document.getElementById("downPayment").value);
var estimatedInterestRate = parseFloat(document.getElementById("estimatedInterestRate").value);
var loanTerm = parseFloat(document.getElementById("loanTerm").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
// Basic validation
if (isNaN(annualIncome) || isNaN(monthlyDebt) || isNaN(downPayment) || isNaN(estimatedInterestRate) || isNaN(loanTerm) ||
annualIncome < 0 || monthlyDebt < 0 || downPayment < 0 || estimatedInterestRate < 0 || loanTerm <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
// Common affordability rule: Debt-to-income ratio (DTI)
// Lenders often look at two ratios:
// 1. Front-end DTI (housing costs only) < 28%
// 2. Back-end DTI (housing costs + all other debts) < 36%
// We'll use the back-end DTI for a more conservative estimate of the *maximum* allowable total monthly payment.
var maxTotalMonthlyPaymentPercentage = 0.36; // 36% DTI
var maxTotalMonthlyPayment = (annualIncome / 12) * maxTotalMonthlyPaymentPercentage;
var maxMonthlyHousingPayment = maxTotalMonthlyPayment – monthlyDebt;
if (maxMonthlyHousingPayment <= 0) {
resultDiv.innerHTML = "Based on your income and existing debts, it may be difficult to qualify for additional housing payments.";
return;
}
// Now, let's estimate the maximum loan amount based on the maximum monthly housing payment.
// We need to use a mortgage payment formula (M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1])
// where:
// M = Monthly payment
// P = Principal loan amount
// i = Monthly interest rate
// n = Total number of payments
var monthlyInterestRate = (estimatedInterestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
var maxLoanAmount = 0;
// Check if interest rate is 0 to avoid division by zero
if (monthlyInterestRate === 0) {
// If interest rate is 0, the loan amount is simply monthly payment * number of payments
maxLoanAmount = maxMonthlyHousingPayment * numberOfPayments;
} else {
// Rearranging the formula to solve for P:
// P = M [ (1 + i)^n – 1] / [ i(1 + i)^n ]
var numerator = Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1;
var denominator = monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments);
maxLoanAmount = maxMonthlyHousingPayment * (numerator / denominator);
}
// The total affordable home price is the loan amount plus the down payment.
var affordableHomePrice = maxLoanAmount + downPayment;
// Format results for display
var formattedMaxLoanAmount = affordableHomePrice.toLocaleString(undefined, { style: 'currency', currency: 'USD' });
var formattedDownPayment = downPayment.toLocaleString(undefined, { style: 'currency', currency: 'USD' });
var formattedMaxMonthlyHousingPayment = maxMonthlyHousingPayment.toLocaleString(undefined, { style: 'currency', currency: 'USD' });
resultDiv.innerHTML =
"Estimated Maximum Affordable Home Price: " + formattedMaxLoanAmount + "" +
"(This includes your estimated loan of " + maxLoanAmount.toLocaleString(undefined, { style: 'currency', currency: 'USD' }) + " and your down payment of " + formattedDownPayment + ")" +
"Estimated Maximum Monthly Housing Payment (Principal & Interest): " + formattedMaxMonthlyHousingPayment + "";
}
Understanding Mortgage Affordability
Buying a home is one of the most significant financial decisions you'll make. Understanding how much you can realistically afford for a mortgage is the crucial first step. This calculator helps estimate your borrowing power by considering your income, existing debts, and the terms of the potential loan.
Key Factors Influencing Affordability:
Annual Gross Income: This is your total income before taxes and other deductions. Lenders use this as a primary indicator of your ability to repay a loan.
Existing Monthly Debt Payments: This includes all recurring monthly payments for debts other than your potential mortgage, such as car loans, student loans, personal loans, and credit card minimum payments. These contribute to your overall debt-to-income ratio (DTI).
Down Payment: The upfront cash you contribute towards the purchase price of the home. A larger down payment reduces the amount you need to borrow, lowering your loan-to-value (LTV) ratio and potentially your monthly payments and interest costs.
Interest Rate: The annual rate at which interest accrues on your loan. Even small differences in interest rates can significantly impact your monthly payment and the total interest paid over the life of the loan.
Loan Term: The number of years you have to repay the mortgage. Common terms are 15 or 30 years. Shorter terms typically mean higher monthly payments but less interest paid overall. Longer terms have lower monthly payments but more interest paid over time.
How the Calculator Works:
This calculator employs a common lending guideline based on the Debt-to-Income (DTI) ratio. Lenders often assess two DTI ratios:
Front-end ratio: The percentage of your gross monthly income that goes towards housing costs (principal, interest, property taxes, homeowner's insurance, and HOA fees). A common target is 28%.
Back-end ratio: The percentage of your gross monthly income that goes towards all monthly debt obligations, including housing costs and all other listed debts. A common target is 36%.
This calculator uses the back-end DTI (36% in this example) to determine the maximum total monthly debt you can handle. It then subtracts your existing monthly debt payments to find the maximum amount you can allocate to your new mortgage payment (Principal & Interest). Using the loan term and estimated interest rate, it calculates the maximum loan principal you could support with that monthly payment. Finally, it adds your down payment to estimate the total affordable home price.
Important Considerations:
This calculator provides an estimation only. Actual mortgage approval depends on many factors, including your credit score, lender-specific guidelines, the type of loan, property taxes, homeowner's insurance, and potential Private Mortgage Insurance (PMI). It's always best to consult with a mortgage professional for a personalized assessment.