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

number-words-converter

v1.2.0

Published

Convert numbers to words in multiple languages (English, Romanian, Spanish, and more)

Downloads

8

Readme

Number Words Converter

npm version License: MIT Build Status codecov

A lightweight, zero-dependency TypeScript library for converting numbers to words in multiple languages. Currently supports English, Romanian, and Spanish.

Features

  • ✅ Convert numbers to words in multiple languages
  • ✅ Support for both integer and decimal numbers
  • ✅ Handles negative numbers and zero
  • ✅ TypeScript support out of the box
  • ✅ Zero runtime dependencies
  • ✅ Accurate handling of very large numbers (up to decillions and beyond) using BigInt.
  • ✅ Comprehensive test coverage (~98%)
  • ✅ Works in both Node.js and browser environments

Requirements

  • Node.js 14 or higher
  • npm or yarn

Installation

# Using npm
npm install number-words-converter

# Or using yarn
yarn add number-words-converter

Usage

Basic Usage

import { numberToWords, LANGUAGES } from 'number-words-converter';

// English (default)
const words1 = numberToWords(42); // "forty-two"
const words2 = numberToWords(123.45, LANGUAGES.ENGLISH); // "one hundred twenty-three point forty-five"

// Romanian
const words3 = numberToWords(42, LANGUAGES.ROMANIAN); // "patruzeci și doi"
const words4 = numberToWords('123.45', LANGUAGES.ROMANIAN); // "o sută douăzeci și trei virgulă patruzeci și cinci"

// Spanish
const words5 = numberToWords(42, LANGUAGES.SPANISH); // "cuarenta y dos"
const words6 = numberToWords('123.45', LANGUAGES.SPANISH); // "ciento veintitrés coma cuatro cinco"

Available Languages

  • LANGUAGES.ENGLISH - English (default)
  • LANGUAGES.ROMANIAN - Romanian (Română)
  • LANGUAGES.SPANISH - Spanish (Español)

API Reference

numberToWords(num: string | number, language: Language = 'en'): string

Converts a number to words in the specified language.

Parameters:

  • num: The number to convert (can be a string or number)
  • language: The target language (defaults to English)

Returns: The number converted to words as a string

Throws:

  • Error if the input cannot be converted to a valid number
  • Error if the language is not supported

Examples:

// Basic usage
numberToWords(42); // "forty-two"
numberToWords("123.45", LANGUAGES.ENGLISH); // "one hundred twenty-three point forty-five"

// With variables
const amount = 99.99;
const amountInWords = numberToWords(amount); // "ninety-nine point ninety-nine"

// In a template literal
const message = `You owe me ${numberToWords(100)} dollars.`;
// "You owe me one hundred dollars."

Advanced Usage

Handling Different Number Formats

The library handles various number formats:

// Different decimal separators
numberToWords('1,234.56'); // US format
numberToWords('1.234,56', LANGUAGES.ROMANIAN); // EU format

// Negative numbers
numberToWords(-42); // "minus forty-two"

// Large numbers (BigInt support)
numberToWords(1000000); // "one million"
numberToWords(1_000_000_000_000_000_000n, LANGUAGES.ENGLISH); // "one quintillion"
// For Romanian, it also supports very large numbers:
numberToWords('1000000000000000000000000000000000', LANGUAGES.ROMANIAN); // "un decilion"

Development

Prerequisites

  • Node.js 14+
  • npm or yarn

Setup

  1. Clone the repository:

    git clone https://github.com/mike-innerhaus/number-words-converter.git
    cd number-words-converter
  2. Install dependencies:

    npm install
    # or
    yarn

Building

npm run build

Testing

# Run tests once
npm test

# Run tests in watch mode
npm run test:watch

# Check test coverage
npm test -- --coverage

Linting

# Check for linting errors
npm run lint

# Automatically fix linting issues
npm run lint -- --fix

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgments

  • Thanks to all contributors who help improve this project
  • Inspired by various number-to-words implementations