A mortgage is a significant financial commitment, and understanding how your repayments are calculated is crucial for effective budgeting and financial planning. This calculator helps you estimate your regular mortgage payments based on the loan amount, interest rate, loan term, and payment frequency.
The Mortgage Repayment Formula
The most common method for calculating mortgage repayments is using the annuity formula, which determines a fixed payment amount over the life of the loan. The formula accounts for both the principal repayment and the interest accrued.
The formula for calculating the periodic payment (M) is:
M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
Where:
M = Your total regular loan payment.
P = The principal loan amount (the amount you borrowed).
i = Your periodic interest rate. This is your annual interest rate divided by the number of payment periods in a year. For example, if your annual rate is 5% and you pay monthly, 'i' is 0.05 / 12.
n = The total number of payments over the loan's lifetime. This is the loan term in years multiplied by the number of payments per year. For example, a 30-year loan with monthly payments has n = 30 * 12.
How the Calculator Works
This calculator takes your inputs and applies the annuity formula:
Loan Amount (P): The total sum you are borrowing.
Annual Interest Rate: The yearly percentage charged by the lender. This is converted to a periodic rate by dividing by the number of payment periods per year (e.g., 12 for monthly).
Loan Term (Years): The total duration of the loan. This is converted to the total number of payments ('n') by multiplying by the number of payment periods per year.
Payment Frequency: This determines how many payments you make each year (e.g., monthly, bi-weekly, weekly). This impacts the total number of payments ('n') and the periodic interest rate ('i').
The calculator then computes your fixed periodic repayment (M) and displays it. For transparency, it also generates an amortization schedule, showing how each payment is split between principal and interest over time, and the remaining balance.
Key Considerations:
Accuracy: This calculator provides an estimate. Actual lender calculations may vary slightly due to differences in rounding or specific fee structures.
Additional Costs: Mortgage repayments often include more than just principal and interest (P&I). They can also include property taxes, homeowner's insurance, and potentially private mortgage insurance (PMI). This calculator typically only shows P&I.
Variable Rates: This calculator assumes a fixed interest rate. If you have a variable-rate mortgage, your payments can change over time.
Prepayment Penalties: Some mortgages have penalties for paying off your loan early.
By using this calculator, you can better understand the financial implications of your mortgage and make more informed decisions.
function calculateMortgage() {
var loanAmount = parseFloat(document.getElementById("loanAmount").value);
var annualInterestRate = parseFloat(document.getElementById("annualInterestRate").value);
var loanTermYears = parseInt(document.getElementById("loanTermYears").value);
var paymentFrequency = parseInt(document.getElementById("paymentFrequency").value);
var loanRepaymentElement = document.getElementById("loan-repayment");
var amortizationScheduleElement = document.getElementById("amortization-schedule");
// Clear previous results and schedule
loanRepaymentElement.textContent = "$0.00";
amortizationScheduleElement.innerHTML = "";
// Input validation
if (isNaN(loanAmount) || loanAmount <= 0) {
alert("Please enter a valid loan amount.");
return;
}
if (isNaN(annualInterestRate) || annualInterestRate < 0) {
alert("Please enter a valid annual interest rate.");
return;
}
if (isNaN(loanTermYears) || loanTermYears <= 0) {
alert("Please enter a valid loan term in years.");
return;
}
if (isNaN(paymentFrequency) || paymentFrequency <= 0) {
alert("Please select a valid payment frequency.");
return;
}
var periodicInterestRate = (annualInterestRate / 100) / paymentFrequency;
var numberOfPayments = loanTermYears * paymentFrequency;
var monthlyRepayment = 0;
if (periodicInterestRate === 0) {
// Handle zero interest rate scenario
monthlyRepayment = loanAmount / numberOfPayments;
} else {
// Standard mortgage formula
var numerator = periodicInterestRate * Math.pow(1 + periodicInterestRate, numberOfPayments);
var denominator = Math.pow(1 + periodicInterestRate, numberOfPayments) – 1;
monthlyRepayment = loanAmount * (numerator / denominator);
}
// Format the monthly repayment
loanRepaymentElement.textContent = "$" + monthlyRepayment.toFixed(2);
// Generate Amortization Schedule
var scheduleHtml = "
Amortization Schedule
";
scheduleHtml += "
Period
Payment
Principal
Interest
Remaining Balance
";
var remainingBalance = loanAmount;
var totalInterestPaid = 0;
var totalPrincipalPaid = 0;
for (var i = 1; i <= numberOfPayments; i++) {
var interestPayment = remainingBalance * periodicInterestRate;
var principalPayment = monthlyRepayment – interestPayment;
// Adjust last payment to ensure balance is exactly zero
if (i === numberOfPayments) {
principalPayment = remainingBalance;
monthlyRepayment = principalPayment + interestPayment;
interestPayment = monthlyRepayment – principalPayment;
}
remainingBalance -= principalPayment;
totalInterestPaid += interestPayment;
totalPrincipalPaid += principalPayment;
// Prevent negative balance due to rounding
if (remainingBalance < 0.01) {
remainingBalance = 0;
}
scheduleHtml += "