npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@helpu/headless-loan-calculator

v1.0.0

Published

A headless, framework-agnostic loan calculator with support for VAT, multiple currencies, and amortization schedules

Readme

Headless Loan Calculator

A headless, framework-agnostic loan calculator with support for VAT, multiple currencies, and full amortization schedules. Zero dependencies, works in Node.js, Bun, and browsers.

What is HelpU Finance?

HelpU Finance is a free, privacy-first platform with financial tools and educational resources. No tracking, no data collection.

We believe that financial literacy should be accessible to everyone.

Features

  • Full amortization schedule - Get detailed month-by-month payment breakdown
  • VAT support - Calculate with net or gross prices, with configurable VAT rates
  • Multi-currency - Support for 35+ currencies with proper formatting
  • Open & Closed loans - Support for both traditional loans and balloon payment structures
  • Zero dependencies - Lightweight and fast
  • TypeScript first - Full type safety and IntelliSense support
  • Universal - Works with Node.js, Bun, and in browsers

Installation

# npm
npm install @helpu/headless-loan-calculator

# yarn
yarn add @helpu/headless-loan-calculator

# pnpm
pnpm add @helpu/headless-loan-calculator

# bun
bun add @helpu/headless-loan-calculator

Usage

import { calculateLoan, formatCurrency } from '@helpu/headless-loan-calculator'

const result = calculateLoan({
  price: 25000,           // Total price
  loanTermMonths: 60,     // 5 years
  apr: 6.5,               // 6.5% APR
  initialPayment: 5000,   // $5,000 down payment
  residualValue: 0,       // No balloon payment
  loanType: 'closed',     // Standard loan
  priceMode: 'gross',     // Price includes VAT
  vatRate: 0.21,          // 21% VAT
})

if (result.success) {
  console.log('Monthly payment:', formatCurrency('USD', result.data.monthlyPayment))
  console.log('Total interest:', formatCurrency('USD', result.data.totalInterestAmount))
  console.log('Total repayment:', formatCurrency('USD', result.data.totalRepayment))
}

API Reference

calculateLoan(input)

Calculate a complete loan with amortization schedule.

interface LoanCalculationInput {
  price: number
  loanTermMonths: number
  apr: number
  initialPayment?: number
  residualValue?: number
  loanType: 'closed' | 'open'
  priceMode: 'gross' | 'net'
  vatRate: number
}

Returns a result object:

interface LoanCalculationResult {
  totalFinancedAmount: number
  totalInterestAmount: number
  totalVatAmount: number
  totalRepayment: number
  monthlyPayment: number
  paymentSchedule: MonthlyPayment[]
  input: LoanCalculationInput
}

calculateMonthlyPayment(principal, monthlyRate, termMonths)

Calculate the monthly payment for a loan using the amortization formula.

import { calculateMonthlyPayment } from '@helpu/headless-loan-calculator'

const monthlyPayment = calculateMonthlyPayment(
  20000,      // Principal
  0.005,      // Monthly rate (6% APR / 12)
  60          // Term in months
)

calculateAffordableLoan(monthlyPayment, monthlyRate, termMonths)

Calculate how much you can borrow based on a desired monthly payment.

import { calculateAffordableLoan } from '@helpu/headless-loan-calculator'

const maxLoan = calculateAffordableLoan(
  500,        // Desired monthly payment
  0.005,      // Monthly rate
  60          // Term in months
)

formatCurrency(currency, amount)

Format a number as currency with proper locale-specific formatting.

import { formatCurrency } from '@helpu/headless-loan-calculator'

formatCurrency('EUR', 1234.56)  // "1 234,56 €"
formatCurrency('USD', 1234.56)  // "$1,234.56"
formatCurrency('HUF', 123456)   // "123 456 Ft"

getVatRate(vatRateKey, customRate?)

Get the VAT rate for a specific region.

import { getVatRate } from '@helpu/headless-loan-calculator'

getVatRate('EU')              // 0.21 (21%)
getVatRate('DE')              // 0.19 (19%)
getVatRate('Custom', 15)      // 0.15 (15%)

Loan Types

Closed Loan (Standard)

Traditional loan where the full amount is financed and paid off over the term.

const result = calculateLoan({
  price: 30000,
  loanTermMonths: 48,
  apr: 5.9,
  loanType: 'closed',
  priceMode: 'gross',
  vatRate: 0.21,
})

Open Loan (Balloon Payment)

Loan with a residual value that is paid as a lump sum at the end.

const result = calculateLoan({
  price: 30000,
  loanTermMonths: 48,
  apr: 5.9,
  residualValue: 10000,  // Balloon payment at end
  loanType: 'open',
  priceMode: 'gross',
  vatRate: 0.21,
})

Price Modes

Gross Mode (Default)

Use when the price includes VAT. Common for consumer/retail scenarios.

const result = calculateLoan({
  price: 12100,
  priceMode: 'gross',
  vatRate: 0.21,
  ...
})

Net Mode

Use when the price excludes VAT. Common for B2B scenarios where VAT can be deducted.

const result = calculateLoan({
  price: 10000,
  priceMode: 'net',
  vatRate: 0.21,
  ...
})

Supported Currencies

The library supports 35+ currencies across all regions:

  • Europe: EUR, GBP, CHF, SEK, NOK, DKK, PLN, CZK, RON, HUF
  • Americas: USD, CAD, MXN, BRL, ARS, CLP, COP, PEN
  • Asia: JPY, CNY, HKD, KRW, SGD, INR, THB, MYR, IDR, PHP
  • Middle East & Africa: AED, SAR, ILS, ZAR
  • Oceania: AUD, NZD
  • Other: RUB, TRY

Error Handling

The library uses a Result type pattern for safe error handling:

const result = calculateLoan(input)

if (result.success) {
  console.log(result.data.monthlyPayment)
} else {
  console.error(result.error.code, result.error.message)
}

Possible error codes:

  • INVALID_PRICE - Price must be a positive number
  • INVALID_TERM - Loan term must be a positive integer
  • INVALID_APR - APR must be a non-negative number
  • INITIAL_PAYMENT_TOO_HIGH - Initial payment exceeds price
  • RESIDUAL_VALUE_TOO_HIGH - Residual value exceeds financed amount

TypeScript Support

Full TypeScript support with exported types:

import type {
  LoanCalculationInput,
  LoanCalculationResult,
  MonthlyPayment,
  Currency,
  LoanType,
  PriceMode,
} from '@helpu/headless-loan-calculator'

Testing

Install the repository dependencies and run the test suite with:

npm test

Contributing

Contributions are welcome. Please read the contribution guidelines before opening a pull request.

Sponsor

Support HelpU Finance through GitHub Sponsors.

License

This project is available for permitted non-commercial use under the PolyForm Noncommercial License 1.0.0.

Personal learning, education, research, experimentation, and other uses permitted by the PolyForm Noncommercial License are welcome.

Commercial use requires a separate license from Omisai Technologies.

Commercial licensing helps fund the HelpU Finance mission of creating freely accessible financial tools, educational resources, and technology.

For commercial licensing, see COMMERCIAL-LICENSING.md.

Copyright (c) 2026 Omisai Technologies.

HelpU Finance is a project and brand of Omisai Technologies.