mortgage-utils
v1.0.1
Published
Lightweight JavaScript utility library for mortgage calculations — DTI, amortization, affordability, LTV and more.
Maintainers
Readme
mortgage-utils
Lightweight JavaScript utility library for mortgage calculations. Built for developers building mortgage tools, fintech apps, and borrower readiness platforms.
Built by OurNetHelps — borrower readiness and mortgage tools for independent mortgage brokers.
Features
- ✅ DTI Calculator — Front-end and back-end debt-to-income ratio
- ✅ Amortization — Monthly payment and full amortization schedule
- ✅ Affordability — Maximum loan amount based on income and debts
- ✅ LTV — Loan-to-value ratio with PMI threshold detection
- ✅ Zero dependencies
- ✅ Works in Node.js and modern browsers
Installation
npm install mortgage-utilsUsage
DTI (Debt-to-Income)
const { frontEndDTI, backEndDTI, dtiReport } = require('mortgage-utils');
// Front-End DTI (housing costs only)
const front = frontEndDTI(1400, 7000);
console.log(front);
// { ratio: 0.2, percentage: 20, status: 'good', label: 'Front-End DTI', guideline: 'Recommended: <= 28%' }
// Back-End DTI (all monthly debts)
const back = backEndDTI(1400, 500, 7000);
console.log(back);
// { ratio: 0.2714, percentage: 27.14, status: 'good', ... }
// Full DTI Report
const report = dtiReport({
monthlyHousingCost: 1400,
monthlyDebts: 500,
grossMonthlyIncome: 7000,
});
console.log(report.qualified); // true
console.log(report.summary); // "Front-End: 20% | Back-End: 27.14%"Amortization
const { monthlyPayment, amortizationSchedule } = require('mortgage-utils');
// Monthly Payment
const payment = monthlyPayment(300000, 6.5, 30);
console.log(payment.monthlyPayment); // 1896.20
console.log(payment.totalInterest); // 382632.00
// Full Amortization Schedule
const schedule = amortizationSchedule(300000, 6.5, 30);
console.log(schedule[0]);
// { month: 1, payment: 1896.20, principal: 271.20, interest: 1625.00, balance: 299728.80 }Affordability
const { maxAffordableLoan, loanToValue } = require('mortgage-utils');
// Max Affordable Loan
const afford = maxAffordableLoan(7000, 500, 6.5, 30);
console.log(afford.estimatedLoanAmount); // ~$411,000
console.log(afford.maxMonthlyPayment); // 2510
// LTV Ratio
const ltv = loanToValue(160000, 200000);
console.log(ltv.percentage); // 80
console.log(ltv.requiresPMI); // falseAPI Reference
frontEndDTI(monthlyHousingCost, grossMonthlyIncome)
Returns front-end DTI ratio with status (good / caution / high).
backEndDTI(monthlyHousingCost, monthlyDebts, grossMonthlyIncome)
Returns back-end DTI including all monthly debts.
dtiReport({ monthlyHousingCost, monthlyDebts, grossMonthlyIncome })
Returns full DTI report with qualified boolean and summary string.
monthlyPayment(loanAmount, annualInterestRate, loanTermYears)
Returns monthly P&I payment, total payment, and total interest.
amortizationSchedule(loanAmount, annualInterestRate, loanTermYears)
Returns array of 360 (or n) monthly payment breakdowns.
maxAffordableLoan(grossMonthlyIncome, monthlyDebts, annualInterestRate, loanTermYears, maxDTI?)
Returns max affordable loan amount based on income and DTI threshold (default 43%).
loanToValue(loanAmount, propertyValue)
Returns LTV ratio, percentage, and PMI requirement flag.
DTI Status Thresholds
| Status | Front-End DTI | Back-End DTI |
|--------|--------------|--------------|
| good | <= 28% | <= 36% |
| caution | 29–36% | 37–43% |
| high | > 36% | > 43% |
Related
- OurNetHelps — White-label borrower readiness tools for mortgage brokers
- MDE Pro — Mortgage Decision Engine for independent brokers
License
MIT © Sanjeev Kumar
