APR and the interest rate are two different numbers
The note rate, sometimes called the nominal or interest rate, is what your monthly payment is calculated from. The annual percentage rate is a disclosure required by the federal Truth in Lending Act: it folds the finance charges you pay to obtain the loan - origination and underwriting fees, discount points, prepaid interest, mortgage insurance premiums - into a single yearly cost figure. Because you receive less cash than the face amount of the loan but repay the full schedule, the APR is always at least as high as the note rate.
Mechanically, the APR is an internal rate of return. Solve for the monthly rate i that makes the present value of all payments equal to the amount financed: Amount financed = M x [1 - (1 + i)^-n] / i. There is no closed-form solution, so the calculator brackets i and bisects until the two sides match, then multiplies by 12.
A worked example
Borrow $300,000 for 30 years at a 6.5% note rate and pay $6,000 in points and origination fees. The payment comes from the note rate: $1,896.20 a month. But the cash advanced is $300,000 - $6,000 = $294,000.
Now find the rate that turns 360 payments of $1,896.20 into a present value of $294,000. Bisection converges on a monthly rate of about 0.00558, so the APR is roughly 6.695% - about 0.20 percentage points above the note rate. Over the full term you pay $682,633 in payments against $294,000 received, a finance charge of $388,633.
Flip it around and the tool works from a payment you were quoted: enter $1,896.20 with the same term and it backs out both the 6.5% note rate and the 6.695% APR.
Where APR helps and where it misleads
APR is the right tool for comparing two offers you plan to hold for a long time. It is a poor guide if you will move or refinance early, because it amortizes fees over the whole term. Pay $6,000 up front and sell after five years and those fees were spread over 60 payments, not 360, so the real cost is far above 6.695%. Use the loan comparison tool's break-even line for that question.
Also note that lenders do not all include the same charges. Mortgage APR generally includes origination fees, points, mortgage insurance and prepaid interest, but excludes appraisal, credit report, title insurance and recording in many cases. Credit cards disclose APR with no fees folded in at all, which is why a card's purchase APR equals its periodic rate times 12. Adjustable-rate loans disclose an APR based on the assumption that the index stays put, which it rarely does.
One last quirk: APR is not the same as APY. APY compounds interest within the year and is used for deposits; APR is a simple annualization of a periodic rate and is used for credit.