Buying a home is one of the largest financial decisions you will make. Using this Mortgage Repayment Calculator allows you to estimate your monthly housing costs accurately by factoring in not just the principal and interest, but also property taxes and homeowners insurance, often referred to as PITI.
How is the Monthly Payment Calculated?
Your monthly mortgage payment is primarily composed of four parts:
Principal: The money you borrowed to buy the house. A portion of every payment goes toward reducing this balance.
Interest: The fee the lender charges you for borrowing the money. In the early years of a mortgage, a large percentage of your payment goes toward interest.
Taxes: Property taxes assessed by your local government. These are often collected by the lender in an escrow account and paid annually on your behalf.
Insurance: Homeowners insurance protects your property against damage. Like taxes, this is usually broken down into monthly amounts and added to your mortgage payment.
The Impact of Interest Rates and Loan Terms
Even a small difference in your interest rate can significantly impact your monthly payment and the total cost of the loan over time. For example, on a $300,000 loan, a difference of just 0.5% in the interest rate can save or cost you tens of thousands of dollars over a 30-year term.
Similarly, the loan term matters. A 15-year mortgage will have higher monthly payments compared to a 30-year mortgage, but you will pay significantly less in total interest because the loan is paid off twice as fast.
What is Debt-to-Income (DTI)?
Lenders look at your Debt-to-Income ratio to determine how much home you can afford. This is calculated by dividing your total monthly debt payments (including your new estimated mortgage) by your gross monthly income. Most lenders prefer a DTI below 43%, though some loan programs allow for higher ratios.
function calculateMortgage() {
// Get Input Values
var homePrice = parseFloat(document.getElementById('homePrice').value);
var downPayment = parseFloat(document.getElementById('downPayment').value);
var interestRate = parseFloat(document.getElementById('interestRate').value);
var loanTerm = parseFloat(document.getElementById('loanTerm').value);
var propertyTax = parseFloat(document.getElementById('propertyTax').value);
var homeInsurance = parseFloat(document.getElementById('homeInsurance').value);
var errorMsg = document.getElementById('errorMsg');
var resultsArea = document.getElementById('results-area');
// Validation
if (isNaN(homePrice) || isNaN(downPayment) || isNaN(interestRate) || isNaN(loanTerm) || isNaN(propertyTax) || isNaN(homeInsurance)) {
errorMsg.style.display = 'block';
resultsArea.style.display = 'none';
return;
}
// Reset Error
errorMsg.style.display = 'none';
// Calculation Logic
var principal = homePrice – downPayment;
// Handle case where down payment > home price
if (principal < 0) {
principal = 0;
}
var monthlyInterestRate = (interestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
// Mortgage Amortization Formula: M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1 ]
var monthlyPrincipalInterest = 0;
if (interestRate === 0) {
monthlyPrincipalInterest = principal / numberOfPayments;
} else {
var x = Math.pow(1 + monthlyInterestRate, numberOfPayments);
monthlyPrincipalInterest = (principal * x * monthlyInterestRate) / (x – 1);
}
// Monthly Tax and Insurance
var monthlyTax = propertyTax / 12;
var monthlyInsurance = homeInsurance / 12;
// Totals
var totalMonthlyPayment = monthlyPrincipalInterest + monthlyTax + monthlyInsurance;
var totalPaidOverTerm = (monthlyPrincipalInterest * numberOfPayments);
var totalInterestPaid = totalPaidOverTerm – principal;
var totalCostOfLoan = totalPaidOverTerm + (monthlyTax * numberOfPayments) + (monthlyInsurance * numberOfPayments);
// Formatting currency
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2
});
// Display Results
document.getElementById('totalMonthly').innerText = formatter.format(totalMonthlyPayment);
document.getElementById('piMonthly').innerText = formatter.format(monthlyPrincipalInterest);
document.getElementById('taxMonthly').innerText = formatter.format(monthlyTax);
document.getElementById('insMonthly').innerText = formatter.format(monthlyInsurance);
document.getElementById('loanTotal').innerText = formatter.format(principal);
document.getElementById('totalInterest').innerText = formatter.format(totalInterestPaid);
document.getElementById('totalCost').innerText = formatter.format(totalCostOfLoan);
// Show Results Area
resultsArea.style.display = 'block';
}