A loan amortization schedule is a table detailing each periodic payment on an amortizing loan (like a mortgage or auto loan). Each payment is broken down into two components: interest and principal. Initially, a larger portion of your payment goes towards interest, and as the loan matures, more goes towards the principal.
How the Calculator Works:
This calculator helps you visualize your loan repayment. It takes the loan amount, annual interest rate, and loan term (in years) as inputs. It then calculates:
Monthly Payment: The fixed amount you'll pay each month.
Amortization Schedule: A month-by-month breakdown showing how much of each payment goes to interest and principal, and the remaining balance after each payment.
Total Paid: The sum of all payments made over the life of the loan.
Total Interest Paid: The total amount of interest you will pay.
Key Terms:
Loan Amount: The total sum of money borrowed.
Annual Interest Rate: The yearly rate charged on the loan, expressed as a percentage.
Loan Term: The duration of the loan, usually expressed in years.
Principal: The original amount of the loan.
Interest: The cost of borrowing money.
Remaining Balance: The outstanding amount of the loan at a specific point in time.
Example:
Let's say you take out a loan for $200,000 with an annual interest rate of 5% over 30 years. The calculator will determine your monthly payment, the total interest you'll pay over 30 years, and provide a detailed schedule of how your loan is paid down.
function calculateAmortization() {
var loanAmount = parseFloat(document.getElementById("loanAmount").value);
var annualInterestRate = parseFloat(document.getElementById("interestRate").value);
var loanTerm = parseInt(document.getElementById("loanTerm").value);
var resultsContainer = document.getElementById("results-container");
var scheduleBody = document.getElementById("scheduleBody");
var totalPaidSpan = document.getElementById("totalPaid");
var totalInterestPaidSpan = document.getElementById("totalInterestPaid");
var monthlyPaymentSpan = document.getElementById("monthlyPayment");
// Clear previous results
scheduleBody.innerHTML = "";
resultsContainer.style.display = 'none'; // Hide results until calculation is valid
totalPaidSpan.textContent = "";
totalInterestPaidSpan.textContent = "";
monthlyPaymentSpan.textContent = "";
if (isNaN(loanAmount) || isNaN(annualInterestRate) || isNaN(loanTerm) || loanAmount <= 0 || annualInterestRate < 0 || loanTerm <= 0) {
alert("Please enter valid positive numbers for all fields.");
return;
}
var monthlyInterestRate = (annualInterestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
var monthlyPayment = 0;
if (monthlyInterestRate === 0) {
monthlyPayment = loanAmount / numberOfPayments;
} else {
monthlyPayment = loanAmount * (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments)) / (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1);
}
var totalPaid = 0;
var totalInterestPaid = 0;
var remainingBalance = loanAmount;
var amortizationRows = [];
for (var i = 0; i < numberOfPayments; i++) {
var interestPayment = remainingBalance * monthlyInterestRate;
var principalPayment = monthlyPayment – interestPayment;
// Adjust last payment to ensure balance is exactly zero
if (i === numberOfPayments – 1) {
principalPayment = remainingBalance;
monthlyPayment = principalPayment + interestPayment; // Adjust monthly payment for the last installment
}
remainingBalance -= principalPayment;
if (remainingBalance < 0) remainingBalance = 0; // Ensure balance doesn't go negative
totalInterestPaid += interestPayment;
totalPaid += monthlyPayment;
amortizationRows.push({
month: i + 1,
payment: monthlyPayment,
interest: interestPayment,
principal: principalPayment,
balance: remainingBalance
});
}
// Display results
monthlyPaymentSpan.textContent = "$" + monthlyPayment.toFixed(2);
totalPaidSpan.textContent = "$" + totalPaid.toFixed(2);
totalInterestPaidSpan.textContent = "$" + totalInterestPaid.toFixed(2);
resultsContainer.style.display = 'block'; // Show results container
// Populate schedule table
for (var j = 0; j < amortizationRows.length; j++) {
var row = scheduleBody.insertRow();
row.insertCell(0).textContent = amortizationRows[j].month;
row.insertCell(1).textContent = "$" + amortizationRows[j].payment.toFixed(2);
row.insertCell(2).textContent = "$" + amortizationRows[j].interest.toFixed(2);
row.insertCell(3).textContent = "$" + amortizationRows[j].principal.toFixed(2);
row.insertCell(4).textContent = "$" + amortizationRows[j].balance.toFixed(2);
}
}