pocketsearch

EMI calculator

EMI calculator — enter loan amount, interest rate and tenure to see the monthly EMI and full breakdown

EMI Calculator

Calculate your monthly loan EMI, total interest and total repayment — pure math, no API needed

Loan details

Result

Enter your loan amount, interest rate and tenure to see the EMI breakdown.
`; lastResult = null; } function calculate() { const amount = parseFloat(document.getElementById('amount').value) || 0; const rate = parseFloat(document.getElementById('rate').value) || 0; const tenureRaw = parseFloat(document.getElementById('tenure').value) || 0; if (amount <= 0 || rate <= 0 || tenureRaw <= 0) { showEmpty('Enter your loan amount, interest rate and tenure to see the EMI breakdown.'); return; } const months = Math.round(tenureUnit === 'years' ? tenureRaw * 12 : tenureRaw); if (months <= 0) { showEmpty('Tenure must be greater than zero.'); return; } const monthlyRate = rate / 12 / 100; let emi; if (monthlyRate === 0) { emi = amount / months; } else { const pow = Math.pow(1 + monthlyRate, months); emi = (amount * monthlyRate * pow) / (pow - 1); } const totalPayment = emi * months; const totalInterest = totalPayment - amount; const principalPct = (amount / totalPayment) * 100; const interestPct = (totalInterest / totalPayment) * 100; const tenureLabel = tenureUnit === 'years' ? (tenureRaw % 1 === 0 ? tenureRaw + ' year' + (tenureRaw === 1 ? '' : 's') : tenureRaw + ' years (' + months + ' months)') : months + ' month' + (months === 1 ? '' : 's'); const sentence = `Borrowing ${fmtCurrency(amount)} at ${rate}% p.a. for ${tenureLabel} costs ${fmtCurrency(totalInterest)} in interest — ${fmtCurrency(totalPayment)} total.`; const barsHtml = `
Principal — ${principalPct.toFixed(1)}%${fmtCurrency(amount)}
Interest — ${interestPct.toFixed(1)}%${fmtCurrency(totalInterest)}
`; const rows = [ ["Loan amount", fmtCurrency(amount)], ["Interest rate", rate + "% p.a."], ["Tenure", tenureLabel], ["Monthly EMI", fmtCurrency(emi)], ["Total interest payable", fmtCurrency(totalInterest)], ["Total amount payable", fmtCurrency(totalPayment)] ]; let rowsHtml = ''; rows.forEach(([l, v]) => { rowsHtml += `
${l}${v}
`; }); const r5 = monthlyRate.toFixed(5); const formula = `EMI = P × r × (1+r)n ÷ ((1+r)n − 1) = ${fmtNum(amount)} × ${r5} × (1+${r5})${months} ÷ ((1+${r5})${months} − 1) = ${fmtCurrency(emi)}`; const hist = `${fmtCurrency(amount)} @ ${rate}% for ${tenureLabel} → EMI ${fmtCurrency(emi)}`; lastResult = { sentence, hist }; document.getElementById('resultArea').innerHTML = `

Monthly EMI

${fmtCurrency(emi)}

${sentence}

${barsHtml}
${rowsHtml}
${formula}
`; } function copyResult() { if (!lastResult) return; navigator.clipboard.writeText(lastResult.sentence).catch(() => {}); } function saveToHistory() { if (!lastResult) return; history.unshift({ text: lastResult.hist, time: new Date().toLocaleTimeString('en-IN', { hour: '2-digit', minute: '2-digit' }) }); if (history.length > 8) history.pop(); renderHistory(); } function renderHistory() { if (!history.length) { document.getElementById('historyCard').style.display = 'none'; return; } document.getElementById('historyCard').style.display = 'block'; document.getElementById('historyList').innerHTML = history.map(h => `
${h.text}${h.time}
` ).join(''); } function clearHistory() { history = []; renderHistory(); } function resetFields() { document.getElementById('amount').value = ''; document.getElementById('rate').value = ''; document.getElementById('tenure').value = ''; showEmpty('Enter your loan amount, interest rate and tenure to see the EMI breakdown.'); }