Mortgage Affordability Calculator
Understanding Mortgage Affordability
Determining how much house you can afford is a crucial step in the home-buying process.
This mortgage affordability calculator helps you estimate the maximum loan amount you might qualify for,
considering your income, existing debts, down payment, and current interest rates.
How it Works:
Lenders typically use a debt-to-income (DTI) ratio to assess your ability to repay a mortgage.
There are two main DTI ratios they consider:
- Front-end DTI (Housing Ratio): This ratio looks at your potential housing expenses (principal, interest, property taxes, and homeowner's insurance – often called PITI) and compares them to your gross monthly income. Lenders generally prefer this to be no more than 28%.
- Back-end DTI (Total Debt Ratio): This ratio includes all your monthly debt obligations (including the potential mortgage payment) and compares them to your gross monthly income. Lenders often prefer this to be no more than 36%, though some may go higher.
This calculator primarily focuses on the back-end DTI to give you a broad estimate of affordability.
It calculates your maximum allowable monthly mortgage payment by subtracting your existing monthly debt payments
from a percentage of your gross monthly income (often capped at 36% of gross income for total debt).
Then, it uses the loan term and interest rate to determine the maximum loan amount you can borrow with that payment.
Key Factors:
- Annual Income: Your total income before taxes. This is the primary source of repayment for your loan.
- Existing Monthly Debt Payments: This includes credit card minimum payments, auto loans, student loans, personal loans, and any other recurring debts.
- Down Payment: The amount of money you pay upfront towards the purchase price of the home. A larger down payment reduces the loan amount needed.
- Interest Rate: The annual interest rate on the mortgage. Higher rates mean higher monthly payments for the same loan amount.
- Loan Term: The number of years you have to repay the loan. Shorter terms have higher monthly payments but less interest paid over time.
Important Note: This calculator provides an *estimate* only. It does not account for all factors lenders consider,
such as credit score, employment history, lender-specific DTI limits, closing costs, or private mortgage insurance (PMI).
Always consult with a mortgage professional for a personalized assessment.
function calculateMortgageAffordability() {
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 resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
// Input validation
if (isNaN(annualIncome) || isNaN(monthlyDebt) || isNaN(downPayment) || isNaN(interestRate) || isNaN(loanTerm) ||
annualIncome <= 0 || monthlyDebt < 0 || downPayment < 0 || interestRate <= 0 || loanTerm <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
// Assume a maximum DTI ratio for total debt (e.g., 36%)
var maxTotalDTI = 0.36;
var grossMonthlyIncome = annualIncome / 12;
var maxTotalMonthlyDebtPayment = grossMonthlyIncome * maxTotalDTI;
var maxMonthlyMortgagePayment = maxTotalMonthlyDebtPayment – monthlyDebt;
// Ensure the max monthly mortgage payment is not negative
if (maxMonthlyMortgagePayment 0) {
// Formula for present value of an ordinary annuity (loan amount)
maxLoanAmount = maxMonthlyMortgagePayment * (1 – Math.pow(1 + monthlyInterestRate, -numberOfPayments)) / monthlyInterestRate;
} else {
// If interest rate is 0, loan amount is simply max payment * number of payments
maxLoanAmount = maxMonthlyMortgagePayment * numberOfPayments;
}
// The actual home price affordability is the loan amount plus the down payment
var estimatedHomePrice = maxLoanAmount + downPayment;
// Display results
resultDiv.innerHTML =
"
Your Estimated Affordability:
" +
"Maximum Estimated Monthly Mortgage Payment (Principal & Interest): $" + maxMonthlyMortgagePayment.toFixed(2) + "" +
"Estimated Maximum Loan Amount: $" + maxLoanAmount.toFixed(2) + "" +
"Estimated Maximum Affordable Home Price (including down payment): $" + estimatedHomePrice.toFixed(2) + "";
}
.calculator-container {
font-family: sans-serif;
max-width: 700px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
.calculator-form {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 15px;
margin-bottom: 20px;
}
.form-group {
display: flex;
flex-direction: column;
}
.form-group label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.form-group input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
}
.calculator-form button {
grid-column: 1 / -1;
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 1.1em;
cursor: pointer;
transition: background-color 0.3s ease;
}
.calculator-form button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 20px;
padding: 15px;
background-color: #e7f3ff;
border-left: 5px solid #007bff;
border-radius: 4px;
}
.calculator-result h3 {
color: #0056b3;
margin-top: 0;
}
.calculator-explanation {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #eee;
font-size: 0.95em;
line-height: 1.6;
color: #444;
}
.calculator-explanation h3, .calculator-explanation h4 {
color: #333;
margin-bottom: 10px;
}
.calculator-explanation ul {
margin-left: 20px;
list-style: disc;
}
.calculator-explanation li {
margin-bottom: 8px;
}
/* Responsive adjustments */
@media (max-width: 600px) {
.calculator-form {
grid-template-columns: 1fr;
}
.calculator-form button {
grid-column: 1 / 1;
}
}