An amortization schedule is a table that details each periodic payment on a loan or other debt. For each payment, it shows how much is applied to the principal, how much is applied to interest, and the remaining balance of the loan. Amortization is most commonly associated with mortgages, but it applies to many types of loans, including auto loans, personal loans, and business loans.
How Amortization Works
When you make a loan payment, it typically consists of two parts: the principal payment and the interest payment. The principal is the actual amount you borrowed, and the interest is the fee charged by the lender for borrowing the money.
Interest Paid: In the early stages of a loan, a larger portion of your payment goes towards interest because the outstanding principal balance is high. The interest is calculated on the remaining balance. The formula for monthly interest paid is:
Interest Paid = (Remaining Balance * Annual Interest Rate) / 12
Principal Paid: As you make payments, the principal balance decreases. Consequently, the amount of interest paid in subsequent payments also decreases, and a larger portion of your fixed payment goes towards reducing the principal. The formula for principal paid is:
Principal Paid = Total Payment - Interest Paid
Ending Balance: After each payment, the loan's ending balance is updated by subtracting the principal paid from the beginning balance of that period.
Ending Balance = Beginning Balance - Principal Paid
The Calculation Process
To generate an amortization schedule, we first need to calculate the fixed monthly payment. This is done using the loan payment formula:
M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
Where:
M = Your total monthly payment
P = Your principal loan amount
i = Your monthly interest rate (annual rate divided by 12)
n = The total number of payments (loan term in years multiplied by 12)
Once the monthly payment (M) is determined, the schedule is generated by iterating through each payment period:
Calculate the interest due for the current period based on the beginning balance.
Subtract the interest due from the total monthly payment to find the principal paid.
Subtract the principal paid from the beginning balance to find the ending balance.
The ending balance of the current period becomes the beginning balance for the next period.
This process is repeated until the ending balance is zero (or very close to zero due to rounding).
Use Cases for Amortization Schedules
An amortization schedule is a powerful tool for borrowers and lenders alike:
Budgeting: Helps borrowers understand their fixed monthly obligations and plan their finances accordingly.
Debt Management: Allows borrowers to see how quickly they are paying down debt and to plan for extra payments to accelerate payoff.
Loan Comparison: Useful for comparing different loan offers by visualizing the total interest paid over the life of the loan.
Financial Planning: Crucial for understanding the long-term costs of borrowing for major purchases like a home or vehicle.
function calculateAmortization() {
var loanAmount = parseFloat(document.getElementById("loanAmount").value);
var annualInterestRate = parseFloat(document.getElementById("annualInterestRate").value);
var loanTermYears = parseInt(document.getElementById("loanTermYears").value);
var resultDiv = document.getElementById("result");
var scheduleTable = document.getElementById("scheduleTable");
var scheduleBody = document.getElementById("scheduleBody");
resultDiv.innerHTML = ""; // Clear previous results
scheduleBody.innerHTML = ""; // Clear previous table rows
scheduleTable.style.display = "none"; // Hide table initially
// Input validation
if (isNaN(loanAmount) || loanAmount <= 0) {
resultDiv.innerHTML = "Please enter a valid loan amount greater than zero.";
return;
}
if (isNaN(annualInterestRate) || annualInterestRate < 0) {
resultDiv.innerHTML = "Please enter a valid annual interest rate (0% or greater).";
return;
}
if (isNaN(loanTermYears) || loanTermYears 0) {
monthlyPayment = loanAmount * (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments)) / (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1);
} else {
monthlyPayment = loanAmount / numberOfPayments; // Simple division if interest rate is 0
}
// Round monthly payment to 2 decimal places
monthlyPayment = parseFloat(monthlyPayment.toFixed(2));
var totalInterestPaidOverall = 0;
var beginningBalance = loanAmount;
var paymentDate = new Date(); // Start with today's date for the first payment
for (var i = 0; i < numberOfPayments; i++) {
var paymentNumber = i + 1;
// Calculate interest for this period
var interestPaid = beginningBalance * monthlyInterestRate;
// Calculate principal for this period
var principalPaid = monthlyPayment – interestPaid;
// Adjust last payment if necessary to account for rounding and ensure balance is zero
if (i === numberOfPayments – 1) {
principalPaid = beginningBalance; // Pay off the remaining balance
monthlyPayment = principalPaid + interestPaid; // Recalculate final payment
interestPaid = beginningBalance * monthlyInterestRate; // Recalculate interest for final payment
if (isNaN(interestPaid) || interestPaid < 0) interestPaid = 0;
if (isNaN(principalPaid) || principalPaid < 0) principalPaid = 0;
if (isNaN(monthlyPayment) || monthlyPayment < 0) monthlyPayment = 0;
}
var endingBalance = beginningBalance – principalPaid;
// Add row to the schedule table
var row = scheduleBody.insertRow();
var cell1 = row.insertCell(0); // Payment #
var cell2 = row.insertCell(1); // Payment Date
var cell3 = row.insertCell(2); // Beginning Balance
var cell4 = row.insertCell(3); // Total Payment
var cell5 = row.insertCell(4); // Principal Paid
var cell6 = row.insertCell(5); // Interest Paid
var cell7 = row.insertCell(6); // Ending Balance
cell1.innerHTML = paymentNumber;
// Format date
var day = paymentDate.getDate();
var month = paymentDate.getMonth() + 1; // Months are zero-indexed
var year = paymentDate.getFullYear();
cell2.innerHTML = `${month}/${day}/${year}`;
cell3.innerHTML = "$" + beginningBalance.toFixed(2);
cell4.innerHTML = "$" + monthlyPayment.toFixed(2);
cell5.innerHTML = "$" + principalPaid.toFixed(2);
cell6.innerHTML = "$" + interestPaid.toFixed(2);
cell7.innerHTML = "$" + endingBalance.toFixed(2);
totalInterestPaidOverall += interestPaid;
beginningBalance = endingBalance;
// Move to the next month for the next payment date
paymentDate.setMonth(paymentDate.getMonth() + 1);
// Stop if balance is effectively zero (handles potential floating point inaccuracies)
if (beginningBalance 0) {
// If the last payment was an adjustment and brought balance to zero, we are done.
// We might have one extra iteration if the adjustment made the balance zero.
if (paymentNumber < numberOfPayments) {
// If we are not at the last scheduled payment and the balance is zero,
// it means the adjustment for the last payment was sufficient.
// We should remove the last added row if it's a duplicate of the final state.
// For simplicity and to avoid complex logic here, we will just break.
// The final ending balance will show $0.00.
}
break; // Exit loop if balance is paid off
}
}
// Display summary results
var totalInterestFormatted = totalInterestPaidOverall.toFixed(2);
var totalAmountPaid = loanAmount + totalInterestPaidOverall;
resultDiv.innerHTML = "Estimated Monthly Payment: $" + monthlyPayment.toFixed(2) + "" +
"Total Interest Paid: $" + totalInterestFormatted + "" +
"Total Amount Paid: $" + totalAmountPaid.toFixed(2) + "";
scheduleTable.style.display = "table"; // Show the table
}