Use this mortgage calculator to calculate your monthly payments, total cost over the loan term, and see how extra payments can reduce your loan term.
Enter Your Mortgage Details
Mortgage Payment Breakdown
Disclaimer: This calculator is for informational purposes only. The results provided are estimates based on the information you enter. For an accurate assessment of your mortgage options, you should consult a qualified mortgage lender.
function calculateMortgage() {
// Get input values
var homeValue = parseFloat(document.getElementById('homeValue').value);
var downPayment = parseFloat(document.getElementById('downPayment').value);
var interestRate = parseFloat(document.getElementById('interestRate').value) / 100;
var loanTerm = parseInt(document.getElementById('loanTerm').value);
var propertyTaxes = parseFloat(document.getElementById('propertyTaxes').value);
var homeInsurance = parseFloat(document.getElementById('homeInsurance').value);
var pmiRate = parseFloat(document.getElementById('pmi').value) / 100;
// Calculate the loan amount
var loanAmount = homeValue - downPayment;
// Calculate the monthly interest rate
var monthlyInterestRate = interestRate / 12;
// Calculate the number of payments (months)
var numberOfPayments = loanTerm * 12;
// Calculate the monthly principal and interest payment (PMI not included yet)
var monthlyPayment = (loanAmount * monthlyInterestRate) / (1 - Math.pow(1 + monthlyInterestRate, -numberOfPayments));
// Calculate PMI if applicable (PMI is applied if loan-to-value ratio is > 80%)
var pmiPayment = 0;
if (loanAmount / homeValue > 0.8) {
pmiPayment = loanAmount * pmiRate / 12;
}
// Calculate the total monthly payment including PMI, property taxes, and home insurance
var totalMonthlyPayment = monthlyPayment + pmiPayment + (propertyTaxes / 12) + (homeInsurance / 12);
// Calculate the total payments over the life of the loan
var totalPayments = totalMonthlyPayment * numberOfPayments;
// Calculate the total interest paid over the life of the loan
var totalInterest = totalPayments - loanAmount - downPayment;
// Display the results
document.getElementById('monthlyPayment').innerText = "Monthly Payment (Principal & Interest): $" + monthlyPayment.toFixed(2);
document.getElementById('totalPayments').innerText = "Total Payments Over Loan Term: $" + totalPayments.toFixed(2);
document.getElementById('totalInterest').innerText = "Total Interest Paid: $" + totalInterest.toFixed(2);
// Show results section
document.getElementById('results').style.display = 'block';
// Generate amortization data for graph
var months = [];
var principalData = [];
var interestData = [];
var totalPaymentData = [];
var balance = loanAmount;
for (var i = 1; i <= numberOfPayments; i++) {
var interest = balance * monthlyInterestRate;
var principal = monthlyPayment - interest;
balance -= principal;
months.push(i);
interestData.push(interest);
principalData.push(principal);
totalPaymentData.push(monthlyPayment);
}
// Create the chart
var ctx = document.getElementById('paymentChart').getContext('2d');
var paymentChart = new Chart(ctx, {
type: 'line',
data: {
labels: months,
datasets: [{
label: 'Principal Payment',
data: principalData,
borderColor: 'green',
fill: false
}, {
label: 'Interest Payment',
data: interestData,
borderColor: 'red',
fill: false
}, {
label: 'Total Monthly Payment',
data: totalPaymentData,
borderColor: 'blue',
fill: false
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
},
responsive: true
}
});
}