Loan Calculator Formula: Amortization and APR
Monthly payment is not just rate times principal. Unpack the amortization formula, see why early payments are interest-heavy, and compare APR.
Implements PMT exactly as shown, returns monthly payment, total repaid, total interest, and interest as a share of the total.
loan calculator with amortization schedule →The core amortization formula
A fixed-rate amortizing loan pays a constant amount every period. That amount is PMT = P · r · (1+r)^n / ((1+r)^n − 1), with P the principal, r the periodic rate, and n the number of payments. Work it through once. Take 20,000 at 6% annual over 60 months. The monthly rate is 0.005 and n = 60. Compute (1.005)^60, which is 1.34885. The numerator is 20,000 × 0.005 × 1.34885 = 134.885. The denominator is 1.34885 − 1 = 0.34885. The payment is 386.66. Over 60 payments that is 23,199.36 repaid, of which 3,199.36 is interest. The zero-rate case is degenerate and the formula divides by zero, so handle it separately: if r is zero the payment is P / n. The loan calculator here implements exactly this expression and returns four figures: the monthly payment, the total repaid, the total interest, and interest as a share of the total. It does not produce a month-by-month schedule, so for the per-month split you iterate the balance yourself.
The amortization schedule
The schedule is a loop, and once you write it the loan becomes predictable. Start with balance = 20,000 and payment 386.66. Each month, interest is balance × 0.005, principal is payment minus that interest, and the balance drops by the principal. Month 1: interest 100.00, principal 286.66, balance 19,713.34. Month 2: interest 98.57, principal 288.09. Month 30: interest 55.39, principal 331.27, balance 10,746.61. Month 60: interest 1.92, principal 384.74. The interest share starts at 25.9% and ends under 1%, and the balance never falls linearly, which is the intuition most people get wrong. The same effect is far more dramatic on a long mortgage. At 300,000 over 30 years at 5%, the payment is 1,610.46. In the first twelve months, 77% of what you pay is interest, and after a year the balance is 295,574, or 98.5% of the original principal.
Interest rate, APR, and effective annual rate
Three different numbers get called the cost of a loan, and confusing them is how people compare the wrong offers. The nominal rate is the stated annual rate, and it is not what you pay when compounding is monthly, because interest is charged on the balance twelve times rather than once. The effective annual rate accounts for that: at a 6% nominal rate compounded monthly, EAR = (1 + 0.06/12)^12 − 1 = 6.168%. The APR folds the cost of obtaining the credit, such as origination fees or points, into a single annualised figure so offers can be compared. Take 20,000 at 6% over 60 months with a 500 origination fee. You receive 19,500 but repay a schedule calculated on 20,000, so the rate equating the present value of those payments to the 19,500 you actually got is about 7.06% APR, not 6%. When comparing offers, use APR and total cost, and check whether the rate is fixed or variable, because a variable rate re-runs this calculation at every reset.
Extra payments and shortening the term
An extra payment works by attacking the only variable in the loop, which is the balance next month's interest is charged on. The new term is usually not quoted by lenders, but you can solve for it: n = −ln(1 − P·r/PMT) / ln(1+r), using your new payment as PMT. Take the 20,000 at 6% example and round the payment up from 386.66 to 450. That gives n ≈ 50.4, so the loan clears in 51 payments instead of 60. Total interest falls from 3,199.36 to 2,675.06, a saving of 524.30, and you are free nine months earlier. On the 300,000 mortgage at 5% over 30 years, adding 200 to the 1,610.46 payment brings the payoff forward to 283 months, 23.6 years instead of 30, cutting total interest from 279,767 to 210,557. The relationship is convex rather than linear: the same extra amount is worth less as the term shortens. Compare offers on total interest paid, not on monthly payment.
A complete worked example
Inputs: principal 150,000, annual rate 4.5%, term 15 years, and a 1,200 fee. The monthly rate is 0.00375 and n = 180. Compute (1.00375)^180, which is 1.96161. The payment is 150,000 × 0.00375 × 1.96161 / 0.96161 = 1,147.49. Over 180 payments the total is 206,548.19 and the interest is 56,548.19, so interest is 27.4% of everything you pay. The fee does not change the payment, which is still calculated on 150,000, but it changes what you effectively borrowed. You received 148,800, so the APR is the rate making the present value of the 1,147.49 stream equal 148,800, which solves to about 4.62% rather than the 4.5% headline. The implementation is one line: function pmt(P, r, n) { return r === 0 ? P / n : P * r * Math.pow(1 + r, n) / (Math.pow(1 + r, n) - 1); }. The guard on r matters, because dividing by a zero denominator produces NaN rather than an error. The assertion that catches most schedule bugs is that the principal column sums to the original principal and the final balance is zero.
What the lender's paperwork adds
The formula above gives a clean amortizing loan and nothing else, so anything unusual in a real quote is a deviation worth finding. A deferred-payment or interest-only product shows a payment that does not amortise at all, which makes the headline number look small and the total enormous. A loan with a balloon has a large sum due at the end that the monthly figure never mentions. An accelerated repayment such as a weekly or fortnightly schedule runs the same arithmetic with more payments per year, so the effective rate is higher for the same nominal rate. A variable rate is recomputed against an index, and the schedule you verified is only the first. Taxes and insurance bundled into a payment are not part of the loan. Before committing, reconcile the lender's schedule against your own: recompute the first payment, the balance after one year, and the final payment.
Disclaimer: this is education, not advice
These figures illustrate a standard amortization formula. They ignore tax, insurance, fees, variable-rate resets and any prepayment penalty, none of which are captured by the PMT expression. A rate used in a calculator is not an offer, and a calculator cannot tell you what you qualify for: lenders also assess income, credit history, debt-to-income ratio and collateral value. The interest calculator here covers a different question, comparing simple against compound interest at a chosen frequency, which suits a savings account or an investment and is not the same calculation as a loan. Use these formulas to understand a schedule and to compare scenarios such as a shorter term or an extra monthly payment, and confirm the final figures against your lender's disclosure before committing. Nothing here is financial advice.