Mortgage Affordability Calculator
.mac-calculator-container {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
max-width: 800px;
margin: 0 auto;
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
border: 1px solid #e0e0e0;
}
.mac-header {
text-align: center;
margin-bottom: 30px;
color: #2c3e50;
}
.mac-grid {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.mac-input-section {
flex: 1 1 300px;
}
.mac-result-section {
flex: 1 1 300px;
background-color: #f8f9fa;
padding: 20px;
border-radius: 8px;
border-left: 5px solid #27ae60;
}
.mac-input-group {
margin-bottom: 15px;
}
.mac-input-group label {
display: block;
margin-bottom: 5px;
font-weight: 600;
color: #34495e;
font-size: 14px;
}
.mac-input-group input, .mac-input-group select {
width: 100%;
padding: 10px;
border: 1px solid #bdc3c7;
border-radius: 4px;
font-size: 16px;
box-sizing: border-box;
}
.mac-input-group input:focus {
border-color: #3498db;
outline: none;
box-shadow: 0 0 5px rgba(52,152,219,0.3);
}
.mac-btn {
width: 100%;
padding: 12px;
background-color: #2980b9;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: background 0.3s;
margin-top: 10px;
}
.mac-btn:hover {
background-color: #1c5980;
}
.mac-result-title {
font-size: 18px;
color: #7f8c8d;
margin-bottom: 10px;
border-bottom: 1px solid #dfe6e9;
padding-bottom: 10px;
}
.mac-big-number {
font-size: 36px;
font-weight: 800;
color: #27ae60;
margin: 10px 0;
}
.mac-detail-row {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
font-size: 14px;
color: #555;
}
.mac-detail-row span.val {
font-weight: bold;
color: #333;
}
.mac-content {
margin-top: 40px;
line-height: 1.6;
color: #333;
}
.mac-content h2 {
color: #2c3e50;
border-bottom: 2px solid #ecf0f1;
padding-bottom: 10px;
margin-top: 30px;
}
.mac-content h3 {
color: #34495e;
margin-top: 25px;
}
.mac-content p {
margin-bottom: 15px;
}
.mac-content ul {
margin-bottom: 20px;
padding-left: 20px;
}
.mac-content li {
margin-bottom: 8px;
}
@media (max-width: 600px) {
.mac-grid {
flex-direction: column;
}
}
Maximum Home Price
$0
Monthly Payment Breakdown
Principal & Interest:
$0
Taxes & Insurance:
$0
Total Monthly Payment:
$0
*Based on a standard 36% debt-to-income ratio back-end limit and 28% front-end limit.
How Much House Can You Afford?
Buying a home is one of the most significant financial decisions you will make. This Mortgage Affordability Calculator helps you estimate a realistic home purchase price based on your gross annual income, existing monthly debts, and current interest rates.
Understanding Debt-to-Income (DTI) Ratios
Lenders use the Debt-to-Income ratio to measure your ability to manage monthly payments and repay debts. There are two main types of ratios used in this calculation:
- Front-End Ratio (28%): Ideally, your monthly housing expenses (principal, interest, taxes, and insurance) should not exceed 28% of your gross monthly income.
- Back-End Ratio (36%): Your total debt load, including housing expenses plus student loans, car payments, and credit cards, should not exceed 36% of your gross monthly income.
Our calculator checks both limits and uses the lower of the two to ensure you do not overextend your finances.
Key Factors Affecting Your Affordability
Several variables influence your purchasing power:
- Interest Rates: Higher interest rates increase your monthly mortgage payment, significantly reducing the total loan amount you can afford.
- Down Payment: A larger down payment reduces the principal loan amount and may eliminate the need for Private Mortgage Insurance (PMI), increasing your buying power.
- Property Taxes: Taxes vary by location. High property tax rates eat into your monthly budget, lowering the maximum home price you can target.
Tips for Increasing Your Budget
If the results are lower than expected, consider paying down high-interest consumer debt before applying for a mortgage. Reducing your monthly obligations directly improves your back-end DTI ratio, potentially allowing you to qualify for a more expensive home.
function calculateAffordability() {
// 1. Get Input Values
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 loanTermYears = parseFloat(document.getElementById('loanTerm').value);
var taxInsRate = parseFloat(document.getElementById('taxInsRate').value);
// 2. Validate Inputs
if (isNaN(annualIncome) || annualIncome <= 0) {
alert("Please enter a valid annual income.");
return;
}
if (isNaN(monthlyDebt) || monthlyDebt < 0) monthlyDebt = 0;
if (isNaN(downPayment) || downPayment < 0) downPayment = 0;
if (isNaN(interestRate) || interestRate <= 0) interestRate = 5.0; // Default safety
if (isNaN(taxInsRate) || taxInsRate < 0) taxInsRate = 0;
// 3. Define DTI Limits (Standard Conventional)
var FRONT_END_RATIO = 0.28;
var BACK_END_RATIO = 0.36;
// 4. Calculate Gross Monthly Income
var monthlyIncome = annualIncome / 12;
// 5. Calculate Max Allowable Housing Payment
// Limit 1: Based purely on income (Front-End)
var maxHousingFront = monthlyIncome * FRONT_END_RATIO;
// Limit 2: Based on income minus other debts (Back-End)
var maxTotalDebt = monthlyIncome * BACK_END_RATIO;
var maxHousingBack = maxTotalDebt – monthlyDebt;
// The actual limit is the lesser of the two, but cannot be negative
var maxAllowablePayment = Math.min(maxHousingFront, maxHousingBack);
if (maxAllowablePayment < 0) maxAllowablePayment = 0;
// 6. Solve for Home Price
// Formula derivation:
// P = Monthly Payment available for P&I + Taxes + Insurance
// P = (LoanAmount * r * (1+r)^n) / ((1+r)^n – 1) + (Price * TaxInsRate/12)
// LoanAmount = Price – DownPayment
// var M_factor = (r * (1+r)^n) / ((1+r)^n – 1)
// var T_factor = TaxInsRate / 100 / 12
// P = (Price – DownPayment) * M_factor + Price * T_factor
// P = Price * M_factor – DownPayment * M_factor + Price * T_factor
// P + DownPayment * M_factor = Price * (M_factor + T_factor)
// Price = (P + DownPayment * M_factor) / (M_factor + T_factor)
var monthlyRate = (interestRate / 100) / 12;
var numPayments = loanTermYears * 12;
// Mortgage Factor (M_factor)
var mathPow = Math.pow(1 + monthlyRate, numPayments);
var mortgageFactor = 0;
if (monthlyRate === 0) {
mortgageFactor = 1 / numPayments;
} else {
mortgageFactor = (monthlyRate * mathPow) / (mathPow – 1);
}
// Tax & Insurance Factor (T_factor)
var taxInsFactor = (taxInsRate / 100) / 12;
// Calculate Max Home Price
var numerator = maxAllowablePayment + (downPayment * mortgageFactor);
var denominator = mortgageFactor + taxInsFactor;
var maxHomePrice = numerator / denominator;
// Edge case: If down payment is huge, logic holds, but price shouldn't be infinite if factors are 0 (unlikely)
if (maxHomePrice < downPayment) {
// Even if payment capacity is 0, you can afford what you put down
maxHomePrice = downPayment;
}
// 7. Calculate Breakdown based on Max Home Price
var loanAmount = maxHomePrice – downPayment;
if (loanAmount < 0) loanAmount = 0;
var monthlyPI = loanAmount * mortgageFactor;
var monthlyTaxIns = maxHomePrice * taxInsFactor;
var totalMonthly = monthlyPI + monthlyTaxIns;
// 8. Update DOM with formatting
document.getElementById('resultHomePrice').innerText = formatCurrency(maxHomePrice);
document.getElementById('resultPI').innerText = formatCurrency(monthlyPI);
document.getElementById('resultTaxIns').innerText = formatCurrency(monthlyTaxIns);
document.getElementById('resultTotalMonthly').innerText = formatCurrency(totalMonthly);
}
function formatCurrency(num) {
return '$' + num.toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 0 });
}
// Initial calculation on load
calculateAffordability();