A mortgage is a long-term loan used to finance the purchase of real estate. The process of paying off a mortgage over time is called amortization. An amortization schedule details how each of your payments is applied to both the principal balance and the interest owed over the life of the loan.
How the Mortgage Amortization Calculator Works
Our calculator uses a standard formula to determine your fixed monthly mortgage payment and then calculates the total interest and total amount paid over the loan's term. The core of the calculation relies on the following formula for the monthly payment (M):
M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
Where:
P = Principal Loan Amount (the total amount borrowed)
i = Monthly Interest Rate (annual interest rate divided by 12)
n = Total Number of Payments (loan term in years multiplied by 12)
The calculator first computes the monthly payment (M). Then, it iterates through each month of the loan term. In each iteration:
The interest for the current month is calculated on the remaining principal balance.
The principal portion of the payment is the monthly payment minus the interest paid.
The remaining principal balance is reduced by the principal portion.
By summing up the interest paid each month, we can determine the total interest paid over the life of the loan. The total amount paid is simply the monthly payment multiplied by the total number of payments.
Key Terms Explained:
Loan Amount (Principal): The initial sum of money you borrow from the lender. This is the base amount on which interest is calculated.
Annual Interest Rate: The yearly rate charged by the lender on the outstanding loan balance. This is typically expressed as a percentage.
Loan Term (Years): The total duration over which the loan is to be repaid, usually specified in years (e.g., 15, 30 years).
Monthly Payment: The fixed amount you pay each month to the lender, which covers both principal and interest.
Total Interest Paid: The cumulative amount of interest paid over the entire loan term.
Total Amount Paid: The sum of all monthly payments made over the loan term, which equals the principal loan amount plus the total interest paid.
Why Use an Amortization Calculator?
Understanding your mortgage payments is crucial for financial planning. This calculator helps you:
Estimate your monthly housing costs.
Compare different loan offers and terms.
Visualize how much of your payment goes towards principal versus interest.
Plan for making extra payments to reduce interest and pay off your loan faster.
By inputting your specific loan details, you gain clarity on your financial obligations and can make more informed decisions about your homeownership journey.
function calculateMortgage() {
var loanAmountInput = document.getElementById("loanAmount");
var annualInterestRateInput = document.getElementById("annualInterestRate");
var loanTermYearsInput = document.getElementById("loanTermYears");
var monthlyPaymentSpan = document.getElementById("monthlyPayment");
var totalInterestSpan = document.getElementById("totalInterest");
var totalPaidSpan = document.getElementById("totalPaid");
var errorMessageDiv = document.getElementById("errorMessage");
var resultSectionDiv = document.getElementById("resultSection");
// Clear previous error messages
errorMessageDiv.textContent = "";
resultSectionDiv.style.display = "none";
// Get input values
var principal = parseFloat(loanAmountInput.value);
var annualRate = parseFloat(annualInterestRateInput.value);
var termYears = parseInt(loanTermYearsInput.value);
// Validate inputs
if (isNaN(principal) || principal <= 0) {
errorMessageDiv.textContent = "Please enter a valid loan amount greater than zero.";
return;
}
if (isNaN(annualRate) || annualRate < 0) {
errorMessageDiv.textContent = "Please enter a valid annual interest rate.";
return;
}
if (isNaN(termYears) || termYears <= 0) {
errorMessageDiv.textContent = "Please enter a valid loan term in years.";
return;
}
// Calculate monthly interest rate and number of payments
var monthlyRate = annualRate / 100 / 12;
var numberOfPayments = termYears * 12;
var monthlyPayment = 0;
var totalInterest = 0;
var totalPaid = 0;
// Calculate monthly payment using the loan payment formula
if (monthlyRate === 0) { // Handle zero interest rate case
monthlyPayment = principal / numberOfPayments;
} else {
monthlyPayment = principal * (monthlyRate * Math.pow(1 + monthlyRate, numberOfPayments)) / (Math.pow(1 + monthlyRate, numberOfPayments) – 1);
}
// Calculate total interest and total paid
totalPaid = monthlyPayment * numberOfPayments;
totalInterest = totalPaid – principal;
// Format and display results
monthlyPaymentSpan.textContent = "$" + monthlyPayment.toFixed(2);
totalInterestSpan.textContent = "$" + totalInterest.toFixed(2);
totalPaidSpan.textContent = "$" + totalPaid.toFixed(2);
resultSectionDiv.style.display = "block";
}