Mortgage Affordability Calculator
Understanding how much house you can afford is a crucial first step in the home-buying process. This mortgage affordability calculator helps you estimate your potential borrowing capacity based on your income, debts, and estimated interest rates. It's important to remember that this is an estimate, and your final loan approval will depend on a lender's specific criteria.
How Mortgage Affordability is Calculated
Lenders typically use debt-to-income ratios (DTI) to assess your ability to manage mortgage payments. There are generally two DTI ratios considered:
- Front-end DTI (Housing Ratio): This ratio compares your estimated total monthly housing costs (principal, interest, taxes, insurance, and HOA fees) to your gross monthly income. A common guideline is for this ratio to be no more than 28%.
- Back-end DTI (Total Debt Ratio): This ratio compares your total monthly debt obligations (including the estimated mortgage payment, plus all other recurring debts like car loans, student loans, and credit card minimum payments) to your gross monthly income. A common guideline is for this ratio to be no more than 36%, though some lenders may go higher.
This calculator uses a simplified approach to estimate affordability. It takes your annual income, subtracts your existing monthly debt payments, and then estimates the maximum mortgage payment you could likely afford based on typical DTI limits. It also factors in your down payment to suggest the maximum loan amount you might qualify for.
Assumptions:
- The calculator assumes a maximum front-end DTI of 28% and a maximum back-end DTI of 36% for illustrative purposes. These are general guidelines and can vary significantly between lenders and loan programs.
- Property taxes and homeowner's insurance are not explicitly calculated but are implicitly considered within the DTI guidelines.
- The calculation for maximum loan amount from the estimated maximum monthly payment assumes a fixed-rate mortgage.
Disclaimer: This calculator provides an estimate for informational purposes only. It is not a loan offer or a guarantee of loan approval. Consult with a mortgage lender for accurate pre-qualification and loan terms.
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; // Convert percentage to decimal
var loanTerm = parseInt(document.getElementById("loanTerm").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = "; // Clear previous results
// Input validation
if (isNaN(annualIncome) || annualIncome <= 0) {
resultDiv.innerHTML = "Please enter a valid annual income.";
return;
}
if (isNaN(monthlyDebtPayments) || monthlyDebtPayments < 0) {
resultDiv.innerHTML = "Please enter a valid monthly debt payment amount.";
return;
}
if (isNaN(downPayment) || downPayment < 0) {
resultDiv.innerHTML = "Please enter a valid down payment amount.";
return;
}
if (isNaN(interestRate) || interestRate <= 0) {
resultDiv.innerHTML = "Please enter a valid interest rate.";
return;
}
if (isNaN(loanTerm) || loanTerm <= 0) {
resultDiv.innerHTML = "Please enter a valid loan term.";
return;
}
var monthlyIncome = annualIncome / 12;
// Guideline DTI ratios (common but can vary)
var maxFrontEndDTIRatio = 0.28; // 28% for housing costs
var maxBackEndDTIRatio = 0.36; // 36% for total debt
// Calculate maximum affordable monthly housing payment based on front-end DTI
var maxMonthlyHousingPayment = monthlyIncome * maxFrontEndDTIRatio;
// Calculate maximum affordable total monthly debt payment based on back-end DTI
var maxTotalMonthlyDebt = monthlyIncome * maxBackEndDTIRatio;
// Calculate maximum allowed monthly mortgage payment (considering existing debts)
var maxAllowedMortgagePayment = maxTotalMonthlyDebt – monthlyDebtPayments;
// Determine the most restrictive maximum monthly mortgage payment
var estimatedMaxMortgagePayment = Math.min(maxMonthlyHousingPayment, maxAllowedMortgagePayment);
// Ensure estimatedMaxMortgagePayment is not negative
if (estimatedMaxMortgagePayment 0 && monthlyInterestRate > 0 && numberOfPayments > 0) {
// Mortgage payment formula: M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
// Rearranged to solve for P (Principal/Loan Amount): P = M [ (1 + i)^n – 1] / [ i(1 + i)^n ]
maxLoanAmount = estimatedMaxMortgagePayment * (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1) / (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments));
} else if (estimatedMaxMortgagePayment == 0) {
maxLoanAmount = 0;
} else {
// Handle cases where calculation might fail (e.g., 0 interest rate for long term)
// For a 0% interest rate, the loan amount would simply be the monthly payment * number of payments
if (monthlyInterestRate === 0) {
maxLoanAmount = estimatedMaxMortgagePayment * numberOfPayments;
} else {
resultDiv.innerHTML = "Could not calculate maximum loan amount. Please check inputs.";
return;
}
}
var estimatedMaxHomePrice = maxLoanAmount + downPayment;
// Display Results
resultDiv.innerHTML = "
Estimated Affordability
" +
"Based on your inputs and common lending guidelines (approx. 28% front-end DTI and 36% back-end DTI):" +
"
Estimated Maximum Monthly Mortgage Payment You Can Afford: $" + estimatedMaxMortgagePayment.toFixed(2) + "" +
"
Estimated Maximum Loan Amount: $" + maxLoanAmount.toFixed(2) + "" +
"
Estimated Maximum Home Price (Loan + Down Payment): $" + estimatedMaxHomePrice.toFixed(2) + "" +
"
This estimate excludes property taxes, homeowner's insurance, and potential HOA fees, which will increase your actual monthly housing cost.";
}
.calculator-container {
font-family: sans-serif;
max-width: 700px;
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: 20px;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 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[type="number"],
.form-group input[type="text"] {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
}
.form-group input::placeholder {
color: #aaa;
}
.calculator-container button {
grid-column: 1 / -1; /* Span all columns */
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 18px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.calculator-container button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 20px;
padding: 15px;
border: 1px solid #eee;
border-radius: 4px;
background-color: #fff;
text-align: center;
}
.calculator-result h3 {
margin-top: 0;
color: #333;
}
.calculator-result p {
font-size: 16px;
line-height: 1.5;
color: #444;
}
.calculator-result .highlight {
font-weight: bold;
color: #28a745;
font-size: 1.1em;
}
.calculator-explanation {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #eee;
font-size: 14px;
color: #666;
line-height: 1.6;
}
.calculator-explanation h3 {
color: #333;
margin-bottom: 10px;
}
.calculator-explanation ul {
padding-left: 20px;
margin-bottom: 10px;
}
.calculator-explanation li {
margin-bottom: 5px;
}