How this comparison works
First it figures out where your current loan is headed: given your balance, rate, and the payment you actually make, it simulates month by month until the balance hits zero, counting every dollar of interest along the way. Then it prices the refinance — a fresh loan at the new rate and term — and puts the two side by side: monthly payment, payoff date, total interest, and the lifetime difference. Watch that last row closely: a lower monthly payment with a longer term can quietly cost you more in total interest, and the calculator will say so.
The formula
M is the new monthly payment, B your balance, r the monthly rate (annual ÷ 12), and n the number of months in the new term. Your current path doesn't need a formula — it's simulated directly from the payment you're making, which also catches the nasty case where your payment doesn't even cover monthly interest and the balance grows instead of shrinking.
Worked example
$40,000 at 7%, currently paying $500/month, refinanced to 5% over 10 years:
Staying put pays the loan off in 9 years, 1 month with $14,037.84 of interest. The refinance drops the payment to $424.26 — saving $75.74/month — and total interest falls to $10,911.45, for lifetime savings of about $3,126. Want savings instead of breathing room? The same balance at 4% over just 5 years costs $736.66/month but saves about $9,838 in total. Rate cuts save you money; term cuts save you more.
The federal loan warning — read this before refinancing
Refinancing is done by private lenders. The moment you refinance a federal student loan, it becomes a private loan, and that conversion is permanent — you cannot change your mind later. You give up income-driven repayment plans (payments tied to what you earn), Public Service Loan Forgiveness (PSLF) and other federal forgiveness programs, and federal deferment and forbearance protections that let you pause payments through unemployment or hardship. If you work in public service, expect to use an income-driven plan, or have shaky income, a lower rate is usually a bad trade for that safety net. Refinancing shines for private loans (nothing to lose), and for federal borrowers with high rates, stable income, and no forgiveness path — decide with your eyes open.