Mortgage Affordability Calculator
Use this calculator to estimate how much you can afford to borrow for a mortgage. This tool considers your income, debts, and desired down payment to provide a preliminary estimate of your purchasing power. Remember, this is an estimate, and your actual borrowing capacity will be determined by your lender.
Your Estimated Mortgage Affordability:
$0
$0
$0
.calculator-container {
font-family: Arial, sans-serif;
max-width: 600px;
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-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 #ddd;
border-radius: 4px;
font-size: 16px;
}
.calculator-container button {
grid-column: 1 / -1;
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-results {
text-align: center;
margin-top: 20px;
padding: 15px;
border-top: 1px solid #eee;
}
.calculator-results h3 {
margin-bottom: 10px;
color: #444;
}
#maxMortgageAmount, #maxHomePrice, #estimatedMonthlyPayment {
font-size: 20px;
font-weight: bold;
color: #28a745;
margin-bottom: 8px;
}
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);
// Basic validation
if (isNaN(annualIncome) || annualIncome <= 0 ||
isNaN(monthlyDebt) || monthlyDebt < 0 ||
isNaN(downPayment) || downPayment < 0 ||
isNaN(interestRate) || interestRate <= 0 ||
isNaN(loanTerm) || loanTerm <= 0) {
document.getElementById("maxMortgageAmount").textContent = "Please enter valid positive numbers.";
document.getElementById("maxHomePrice").textContent = "";
document.getElementById("estimatedMonthlyPayment").textContent = "";
return;
}
// Common lender guideline: Front-end ratio (PITI) up to 28% of gross monthly income
// Common lender guideline: Back-end ratio (PITI + other debts) up to 36% of gross monthly income
// We'll use a conservative combined approach, assuming PITI (Principal, Interest, Taxes, Insurance) can be around 30-35% of gross income minus existing debts.
// For simplicity here, we'll estimate maximum monthly housing payment based on a percentage of gross income, allowing for debt.
var grossMonthlyIncome = annualIncome / 12;
var maxTotalHousingPayment = grossMonthlyIncome * 0.36; // Using 36% as a guideline for total debt payments including housing
var maxPrincipalAndInterest = maxTotalHousingPayment – monthlyDebt;
if (maxPrincipalAndInterest <= 0) {
document.getElementById("maxMortgageAmount").textContent = "$0 (Debt exceeds affordability)";
document.getElementById("maxHomePrice").textContent = "";
document.getElementById("estimatedMonthlyPayment").textContent = "";
return;
}
// Calculate maximum mortgage amount based on P&I payment
var monthlyInterestRate = interestRate / 100 / 12;
var numberOfPayments = loanTerm * 12;
// Mortgage payment formula: M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
// Rearranged to solve for P (Principal): P = M [ (1 + i)^n – 1] / [ i(1 + i)^n ]
var maxMortgageAmount = maxPrincipalAndInterest * (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1) / (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments));
// Estimate property taxes and homeowner's insurance (very rough estimates)
// Typically 1% of home value for taxes per year, and ~0.5% for insurance per year. Let's use 1.5% of home value annually as a rough PITI base.
// PITI = Principal + Interest + Taxes + Insurance
// We'll assume max PITI is around 36% of gross monthly income.
// Let's re-calculate using a more direct PITI approach, as the previous method was a bit convoluted.
// A common rule of thumb is that your total monthly housing costs (PITI) shouldn't exceed 28% of your gross monthly income,
// and your total debt payments (including PITI) shouldn't exceed 36% of your gross monthly income.
var ptiMaxPercentage = 0.28; // Principal, Interest, Taxes, Insurance as a percentage of gross monthly income
var totalDebtMaxPercentage = 0.36; // Total debt including PITI as a percentage of gross monthly income
var maxTotalMonthlyPayments = grossMonthlyIncome * totalDebtMaxPercentage;
var maxPitiPayment = maxTotalMonthlyPayments – monthlyDebt;
if (maxPitiPayment <= 0) {
document.getElementById("maxMortgageAmount").textContent = "$0 (Existing debt too high)";
document.getElementById("maxHomePrice").textContent = "";
document.getElementById("estimatedMonthlyPayment").textContent = "";
return;
}
// Now we need to estimate Taxes and Insurance (TI) to find out how much is left for Principal & Interest (PI).
// TI is often estimated as a percentage of the home price. This creates a circular dependency.
// A common approach is to assume TI is a certain percentage of the PITI. Let's assume TI is ~1/3 of PITI for a rough estimate,
// leaving 2/3 for PI. This is a simplification.
var estimatedPiPayment = maxPitiPayment * (2 / 3); // Roughly 2/3 of max PITI for Principal & Interest
if (estimatedPiPayment <= 0) {
document.getElementById("maxMortgageAmount").textContent = "$0 (Not enough for P&I)";
document.getElementById("maxHomePrice").textContent = "";
document.getElementById("estimatedMonthlyPayment").textContent = "";
return;
}
// Calculate the maximum loan amount (Principal) based on the estimated PI payment
var principal = estimatedPiPayment * (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1) / (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments));
var maxMortgage = principal;
var maxHomePurchasePrice = maxMortgage + downPayment;
// Let's also show the estimated total monthly payment (PITI) for context
var estimatedMonthlyTaxesAndInsurance = maxPitiPayment * (1/3); // Roughly 1/3 of max PITI for Taxes & Insurance
var totalEstimatedMonthlyPayment = estimatedPiPayment + estimatedMonthlyTaxesAndInsurance;
document.getElementById("maxMortgageAmount").textContent = "Max Mortgage Amount: $" + maxMortgage.toFixed(2);
document.getElementById("maxHomePrice").textContent = "Estimated Max Home Purchase Price: $" + maxHomePurchasePrice.toFixed(2);
document.getElementById("estimatedMonthlyPayment").textContent = "Estimated Total Monthly Payment (PITI): $" + totalEstimatedMonthlyPayment.toFixed(2);
}