This calculator helps you estimate the maximum mortgage you can afford, considering your income, debts, and desired down payment. Understanding your borrowing capacity is a crucial first step in the home-buying process.
How Mortgage Affordability is Calculated
Lenders typically use two main ratios to determine how much mortgage you can afford: the Debt-to-Income (DTI) ratio and the front-end DTI (housing ratio). While specific lender requirements vary, common guidelines suggest that your total monthly debt payments (including the new mortgage payment) should not exceed 43% of your gross monthly income (back-end DTI), and your housing costs alone (principal, interest, taxes, insurance – PITI) should not exceed 31% of your gross monthly income (front-end DTI).
This calculator simplifies the process by estimating the maximum loan amount you could qualify for based on a common lender guideline where total monthly debt payments, including the estimated mortgage principal and interest (P&I), should not exceed a certain percentage of your gross monthly income. It also factors in your down payment to give you an idea of the total home price you might be able to afford.
Key Factors:
Annual Gross Income: Your total income before taxes.
Monthly Debt Payments: Your existing recurring monthly debt obligations like car loans, student loans, and credit card payments.
Down Payment: The cash you put towards the purchase price of the home. A larger down payment reduces the loan amount needed.
Interest Rate: The annual percentage rate you'll pay on the mortgage loan. Higher rates mean higher monthly payments.
Loan Term: The duration of the mortgage, typically 15 or 30 years. Longer terms mean lower monthly payments but more interest paid over time.
Important Note: This is an estimate only. Actual mortgage approval depends on many factors, including your credit score, employment history, lender-specific policies, and the specific property you intend to buy. It's always best to speak with a mortgage professional for personalized advice.
.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-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: #555;
}
.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: 5px;
font-size: 1.1rem;
cursor: pointer;
transition: background-color 0.3s ease;
margin-top: 10px;
}
.calculator-container button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 25px;
padding: 15px;
background-color: #e7f3fe;
border-left: 5px solid #2196F3;
font-size: 1.2rem;
font-weight: bold;
text-align: center;
color: #333;
}
.calculator-explanation {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #eee;
color: #555;
line-height: 1.6;
}
.calculator-explanation h3 {
color: #333;
margin-bottom: 10px;
}
.calculator-explanation ul {
list-style: disc;
margin-left: 20px;
}
.calculator-explanation li {
margin-bottom: 8px;
}
function calculateMortgageAffordability() {
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);
var loanTerm = parseFloat(document.getElementById("loanTerm").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
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 lender guideline: Housing P&I should not exceed 28% of gross monthly income.
// This is a simplified assumption. Some use 31% for PITI, others are more flexible.
// We'll use 28% for Principal & Interest (P&I) to be conservative for this calculator.
var maxHousingRatio = 0.28; // Example: 28% for P&I
var monthlyIncome = annualIncome / 12;
var maxMonthlyPaymentAllowed = monthlyIncome * maxHousingRatio;
// Calculate maximum total monthly debt allowed (back-end DTI)
// Common guideline: Total Debt (including proposed P&I) <= 36% of gross monthly income
// We can also use this to constrain the loan, or simply present it.
// For this calculator, we'll prioritize the housing ratio, but it's good to be aware.
var maxTotalDebtRatio = 0.36; // Example: 36% for total debt
var maxTotalMonthlyDebtAllowed = monthlyIncome * maxTotalDebtRatio;
// Calculate the maximum P&I payment affordable after existing debts
var maxMortgagePAndI = maxMonthlyPaymentAllowed – monthlyDebtPayments;
if (maxMortgagePAndI <= 0) {
resultDiv.innerHTML = "Based on your income and existing debts, you may not qualify for an additional mortgage payment.";
return;
}
// 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 (annual rate / 12)
// n = total number of payments (loan term in years * 12)
// We need to find P, so rearrange the formula:
// P = M [ (1 + i)^n – 1] / [ i(1 + i)^n ]
var monthlyInterestRate = (interestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
var powerTerm = Math.pow(1 + monthlyInterestRate, numberOfPayments);
var maxLoanAmount = (maxMortgagePAndI * (powerTerm – 1)) / (monthlyInterestRate * powerTerm);
if (isNaN(maxLoanAmount) || !isFinite(maxLoanAmount) || maxLoanAmount < 0) {
resultDiv.innerHTML = "Calculation resulted in an invalid loan amount. Please check your inputs.";
return;
}
var affordableHomePrice = maxLoanAmount + downPayment;
// Format results for better readability
var formattedMaxLoan = maxLoanAmount.toLocaleString(undefined, { style: 'currency', currency: 'USD' });
var formattedHomePrice = affordableHomePrice.toLocaleString(undefined, { style: 'currency', currency: 'USD' });
var formattedMaxMonthlyPAndI = maxMortgagePAndI.toLocaleString(undefined, { style: 'currency', currency: 'USD' });
resultDiv.innerHTML = "Estimated Maximum Mortgage Loan: " + formattedMaxLoan + "" +
"Estimated Affordable Home Price (with down payment): " + formattedHomePrice + "" +
"(Based on estimated max P&I payment of " + formattedMaxMonthlyPAndI + "/month, assuming a " + (maxHousingRatio*100).toFixed(0) + "% housing ratio and " + (maxTotalDebtRatio*100).toFixed(0) + "% total debt ratio.)";
}