Amortization Schedule Calculator
Understanding Loan Amortization
An amortization schedule is a table that details each periodic payment on an amortizing loan (like a mortgage or auto loan). Each payment consists of two parts: interest and principal. Initially, a larger portion of your payment goes towards interest, while a smaller portion reduces the principal. As the loan progresses, this trend reverses, and more of your payment goes towards paying down the principal.
Loan Amount: This is the total sum of money borrowed. For example, if you're buying a house and taking out a mortgage, this would be the price of the house minus your down payment.
Annual Interest Rate: This is the yearly rate charged by the lender. It's important to convert this percentage into a monthly rate for calculations by dividing by 100 and then by 12.
Loan Term: This is the total duration over which the loan is to be repaid, typically expressed in years. For amortization calculations, we usually convert this into months by multiplying by 12.
Monthly Payment: This is the fixed amount you pay each month towards the loan. It's calculated using a specific formula that accounts for the loan amount, interest rate, and loan term. The formula for the monthly payment (M) is:
M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
where:
- P = Principal loan amount
- i = Monthly interest rate (Annual rate / 12 / 100)
- n = Total number of payments (Loan term in years * 12)
Amortization Schedule Details: The schedule breaks down each payment:
- Payment Number: The sequence of your payment (1st, 2nd, etc.).
- Payment Amount: The fixed total amount paid each month.
- Interest Paid: The portion of the payment that covers the interest accrued since the last payment.
- Principal Paid: The portion of the payment that reduces the outstanding loan balance.
- Remaining Balance: The amount of principal still owed after the payment is made.
Understanding your amortization schedule helps you see how your loan is being paid down over time and how much of each payment is allocated to interest versus principal.
function calculateAmortization() {
var loanAmount = parseFloat(document.getElementById("loanAmount").value);
var annualInterestRate = parseFloat(document.getElementById("interestRate").value);
var loanTerm = parseFloat(document.getElementById("loanTerm").value);
var resultDiv = document.getElementById("amortizationResult");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(loanAmount) || isNaN(annualInterestRate) || isNaN(loanTerm) || loanAmount <= 0 || annualInterestRate < 0 || loanTerm <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
var monthlyInterestRate = (annualInterestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
// Calculate monthly payment
var monthlyPayment = 0;
if (monthlyInterestRate === 0) {
monthlyPayment = loanAmount / numberOfPayments;
} else {
monthlyPayment = loanAmount * (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments)) / (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1);
}
if (isNaN(monthlyPayment) || !isFinite(monthlyPayment)) {
resultDiv.innerHTML = "Could not calculate monthly payment. Please check your input values.";
return;
}
var amortizationTableHtml = "
Amortization Schedule
";
amortizationTableHtml += "
Monthly Payment: $" + monthlyPayment.toFixed(2) + "";
amortizationTableHtml += "
";
amortizationTableHtml += "| Payment # | Payment Amount | Interest Paid | Principal Paid | Remaining Balance |
";
amortizationTableHtml += "";
var remainingBalance = loanAmount;
var totalInterestPaid = 0;
for (var i = 1; i <= numberOfPayments; i++) {
var interestPaid = remainingBalance * monthlyInterestRate;
var principalPaid = monthlyPayment – interestPaid;
// Adjust last payment to ensure balance is exactly zero
if (i === numberOfPayments) {
principalPaid = remainingBalance;
monthlyPayment = interestPaid + principalPaid; // Recalculate actual last payment
}
remainingBalance -= principalPaid;
totalInterestPaid += interestPaid;
// Ensure remaining balance doesn't go negative due to floating point inaccuracies
if (remainingBalance < 0) {
remainingBalance = 0;
}
amortizationTableHtml += "";
amortizationTableHtml += "| " + i + " | ";
amortizationTableHtml += "$" + monthlyPayment.toFixed(2) + " | ";
amortizationTableHtml += "$" + interestPaid.toFixed(2) + " | ";
amortizationTableHtml += "$" + principalPaid.toFixed(2) + " | ";
amortizationTableHtml += "$" + remainingBalance.toFixed(2) + " | ";
amortizationTableHtml += "
";
}
amortizationTableHtml += "";
amortizationTableHtml += "
";
amortizationTableHtml += "
Total Interest Paid Over Loan Life: $" + totalInterestPaid.toFixed(2) + "";
resultDiv.innerHTML = amortizationTableHtml;
}
.calculator-container {
font-family: sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.calculator-title {
text-align: center;
color: #333;
margin-bottom: 20px;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 20px;
align-items: flex-end;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-group input[type="number"] {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
}
.calculator-inputs button {
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
transition: background-color 0.3s ease;
}
.calculator-inputs button:hover {
background-color: #0056b3;
}
.calculator-result {
margin-top: 20px;
border-top: 1px solid #eee;
padding-top: 20px;
}
.calculator-result h3 {
color: #333;
margin-bottom: 15px;
}
.calculator-result table {
width: 100%;
margin-top: 10px;
border-collapse: collapse;
}
.calculator-result th, .calculator-result td {
padding: 8px;
text-align: right;
border: 1px solid #ddd;
}
.calculator-result th {
background-color: #f2f2f2;
font-weight: bold;
text-align: center;
}
.calculator-result td:first-child, .calculator-result th:first-child {
text-align: center;
}
.calculator-explanation {
margin-top: 30px;
border-top: 1px solid #eee;
padding-top: 20px;
color: #444;
line-height: 1.6;
}
.calculator-explanation h3 {
color: #333;
margin-bottom: 15px;
}
.calculator-explanation p, .calculator-explanation ul {
margin-bottom: 15px;
}
.calculator-explanation ul {
padding-left: 20px;
}
.calculator-explanation code {
background-color: #eef;
padding: 2px 5px;
border-radius: 3px;
}