Mortgage Amortization Calculator
Understanding how your mortgage is paid down over time is crucial for financial planning. An amortization schedule breaks down each mortgage payment into its principal and interest components, showing how your loan balance decreases with each payment. This calculator helps you visualize your loan's journey and understand the impact of different loan terms and interest rates.
Your Mortgage Amortization Schedule
function calculateAmortization() {
var loanAmount = parseFloat(document.getElementById("loanAmount").value);
var interestRate = parseFloat(document.getElementById("interestRate").value);
var loanTerm = parseFloat(document.getElementById("loanTerm").value);
var resultDiv = document.getElementById("amortizationResult");
var monthlyPaymentDiv = document.getElementById("monthlyPayment");
var totalInterestPaidDiv = document.getElementById("totalInterestPaid");
var totalPrincipalPaidDiv = document.getElementById("totalPrincipalPaid");
var amortizationTableDiv = document.getElementById("amortizationTable");
resultDiv.style.display = "block";
monthlyPaymentDiv.innerHTML = "";
totalInterestPaidDiv.innerHTML = "";
totalPrincipalPaidDiv.innerHTML = "";
amortizationTableDiv.innerHTML = "";
if (isNaN(loanAmount) || isNaN(interestRate) || isNaN(loanTerm) || loanAmount <= 0 || interestRate < 0 || loanTerm <= 0) {
amortizationTableDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
var monthlyInterestRate = (interestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
// Calculate Monthly Payment using the formula: M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
var monthlyPayment = loanAmount * (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments)) / (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1);
monthlyPayment = monthlyPayment.toFixed(2);
monthlyPaymentDiv.innerHTML = "
Estimated Monthly Payment: $" + monthlyPayment + "
";
var remainingBalance = loanAmount;
var totalInterest = 0;
var totalPrincipal = 0;
var tableHTML = "
| Payment # | Payment Date | Interest Paid | Principal Paid | Remaining Balance |
";
var currentDate = new Date();
var paymentDates = [];
for (var i = 0; i < numberOfPayments; i++) {
var year = currentDate.getFullYear();
var month = currentDate.getMonth();
paymentDates.push(new Date(year, month + i + 1, 1).toLocaleDateString());
}
for (var i = 0; i < numberOfPayments; i++) {
var interestPayment = remainingBalance * monthlyInterestRate;
var principalPayment = monthlyPayment – interestPayment;
if (remainingBalance – principalPayment < 0) {
principalPayment = remainingBalance;
monthlyPayment = principalPayment + interestPayment; // Adjust final payment
}
remainingBalance -= principalPayment;
totalInterest += interestPayment;
totalPrincipal += principalPayment;
tableHTML += "";
tableHTML += "| " + (i + 1) + " | ";
tableHTML += "" + paymentDates[i] + " | ";
tableHTML += "$" + interestPayment.toFixed(2) + " | ";
tableHTML += "$" + principalPayment.toFixed(2) + " | ";
tableHTML += "$" + remainingBalance.toFixed(2) + " | ";
tableHTML += "
";
}
tableHTML += "
";
totalInterestPaidDiv.innerHTML = "
Total Interest Paid Over Loan Term: $" + totalInterest.toFixed(2) + "
";
totalPrincipalPaidDiv.innerHTML = "
Total Principal Paid Over Loan Term: $" + totalPrincipal.toFixed(2) + "
";
amortizationTableDiv.innerHTML = tableHTML;
}
#amortizationCalculator {
font-family: sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
background-color: #f9f9f9;
}
#amortizationCalculator h2, #amortizationCalculator h3, #amortizationCalculator h4 {
color: #333;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-group input {
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
}
button {
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1.1em;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
#amortizationResult {
margin-top: 20px;
border-top: 1px solid #eee;
padding-top: 15px;
}
#amortizationResult h3 {
margin-bottom: 15px;
}
#amortizationResult div {
margin-bottom: 10px;
padding: 10px;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
}
#amortizationTable table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
#amortizationTable th, #amortizationTable td {
padding: 10px;
text-align: left;
border: 1px solid #ddd;
}
#amortizationTable th {
background-color: #e9ecef;
font-weight: bold;
}
#amortizationTable tr:nth-child(even) {
background-color: #f8f9fa;
}