Amortization Schedule Calculator
An amortization schedule is a table that shows each periodic payment on a loan. Each payment consists of both principal and interest, with the principal portion gradually increasing and the interest portion gradually decreasing over the life of the loan.
Understanding Amortization
When you take out a loan, like a mortgage or an auto loan, you typically repay it over time with regular payments. Each of these payments is split into two parts: principal and interest. Amortization is the process of paying off debt over time in equal installments.
The principal is the actual amount you borrowed. The interest is the cost of borrowing that money, usually expressed as a percentage of the principal. In the early stages of a loan, a larger portion of your payment goes towards interest, and a smaller portion goes towards the principal. As you continue to make payments, this ratio gradually shifts, with more of your payment going towards the principal and less towards interest.
The amortization schedule provides a detailed breakdown of how each payment contributes to paying down the loan balance. It helps you understand the total interest you'll pay over the life of the loan and how quickly you're building equity.
Key Components:
- Loan Amount: The total amount of money borrowed.
- Annual Interest Rate: The yearly rate charged on the loan. This is usually converted to a monthly rate for calculations.
- Loan Term: The total duration of the loan, typically in years. This is converted to months for calculations.
- Monthly Payment: The fixed amount paid each month to cover both principal and interest.
- Interest Paid: The portion of the monthly payment that goes towards interest.
- Principal Paid: The portion of the monthly payment that goes towards reducing the loan balance.
- Remaining Balance: The outstanding amount of the loan after each payment.
Understanding your amortization schedule can help you make informed financial decisions and plan your loan repayments effectively.
function calculateAmortization() {
var loanAmount = parseFloat(document.getElementById("loanAmount").value);
var annualInterestRate = parseFloat(document.getElementById("annualInterestRate").value);
var loanTermYears = parseFloat(document.getElementById("loanTermYears").value);
var scheduleOutput = document.getElementById("scheduleOutput");
var totalInterestPaidDisplay = document.getElementById("totalInterestPaid");
var totalPrincipalPaidDisplay = document.getElementById("totalPrincipalPaid");
// Clear previous results
scheduleOutput.innerHTML = ";
totalInterestPaidDisplay.innerHTML = ";
totalPrincipalPaidDisplay.innerHTML = ";
if (isNaN(loanAmount) || isNaN(annualInterestRate) || isNaN(loanTermYears) || loanAmount <= 0 || annualInterestRate < 0 || loanTermYears <= 0) {
scheduleOutput.innerHTML = 'Please enter valid positive numbers for all fields.';
return;
}
var monthlyInterestRate = (annualInterestRate / 100) / 12;
var loanTermMonths = loanTermYears * 12;
// Calculate monthly payment using the loan payment formula: M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
var monthlyPayment = loanAmount * (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, loanTermMonths)) / (Math.pow(1 + monthlyInterestRate, loanTermMonths) – 1);
if (isNaN(monthlyPayment) || !isFinite(monthlyPayment)) {
scheduleOutput.innerHTML = 'Could not calculate monthly payment. Please check your inputs.';
return;
}
var tableHTML = '
';
tableHTML += '| Month | Starting Balance | Payment | Interest Paid | Principal Paid | Ending Balance |
';
tableHTML += '';
var currentBalance = loanAmount;
var totalInterest = 0;
var totalPrincipal = 0;
for (var i = 0; i < loanTermMonths; i++) {
var interestPayment = currentBalance * monthlyInterestRate;
var principalPayment = monthlyPayment – interestPayment;
// Adjust last payment to ensure balance reaches exactly zero
if (i === loanTermMonths – 1) {
principalPayment = currentBalance;
monthlyPayment = interestPayment + principalPayment;
}
currentBalance -= principalPayment;
totalInterest += interestPayment;
totalPrincipal += principalPayment;
tableHTML += '';
tableHTML += '| ' + (i + 1) + ' | ';
tableHTML += '$' + loanAmount.toFixed(2) + ' | '; // Starting balance of the loan for display.
tableHTML += '$' + monthlyPayment.toFixed(2) + ' | ';
tableHTML += '$' + interestPayment.toFixed(2) + ' | ';
tableHTML += '$' + principalPayment.toFixed(2) + ' | ';
tableHTML += '$' + currentBalance.toFixed(2) + ' | ';
tableHTML += '
';
// Update loanAmount for the next iteration's starting balance representation in the table.
// This is a bit of a simplification for display clarity within this loop iteration context.
// The `currentBalance` is the true dynamically changing balance.
loanAmount = currentBalance;
}
tableHTML += '
';
scheduleOutput.innerHTML = tableHTML;
totalInterestPaidDisplay.innerHTML = '
Total Interest Paid: $' + totalInterest.toFixed(2) + ";
totalPrincipalPaidDisplay.innerHTML = '
Total Principal Paid: $' + totalPrincipal.toFixed(2) + ";
}
.calculator-wrapper {
font-family: sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
}
.calculator-wrapper h2, .calculator-wrapper h3 {
text-align: center;
margin-bottom: 20px;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 20px;
padding: 15px;
border: 1px solid #eee;
border-radius: 5px;
background-color: #f9f9f9;
}
.form-group {
display: flex;
flex-direction: column;
}
.form-group label {
margin-bottom: 5px;
font-weight: bold;
}
.form-group input[type="number"] {
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
}
.calculator-inputs button {
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
align-self: center; /* Center the button if it's the only item in its grid cell */
grid-column: 1 / -1; /* Span across all columns */
}
.calculator-inputs button:hover {
background-color: #0056b3;
}
.calculator-results {
margin-top: 30px;
padding: 15px;
border: 1px solid #eee;
border-radius: 5px;
background-color: #fefefe;
}
.calculator-results table {
width: 100%;
margin-top: 15px;
border-collapse: collapse;
}
.calculator-results th, .calculator-results td {
padding: 10px;
text-align: right;
}
.calculator-results th {
background-color: #f2f2f2;
font-weight: bold;
}
.calculator-results tbody tr:nth-child(even) {
background-color: #f9f9f9;
}
.calculator-explanation {
margin-top: 30px;
padding: 15px;
border: 1px solid #eee;
border-radius: 5px;
background-color: #f9f9f9;
}
.calculator-explanation h4 {
margin-top: 15px;
margin-bottom: 10px;
}
.calculator-explanation ul {
padding-left: 20px;
}