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

i18n-number-parser

v1.2.0

Published

Converts numbers written out in words into their numeric value, in English, Dutch, German and Portuguese.

Readme

i18n-number-parser

Converts numbers written out in words into their numeric value, in English, Dutch, German and Portuguese.

First relied on words-to-numbers and multilingual-number-parser. Added German language support and fixed a number of issues of the original packages.

Installation

npm install i18n-number-parser
# or
pnpm add i18n-number-parser

Usage

import wordsToNumbers, { Languages } from 'i18n-number-parser';

wordsToNumbers('two hundred thirty four');
// 234

wordsToNumbers('I bought twenty-two apples, and thirty pears!');
// 'I bought 22 apples, and 30 pears!'

wordsToNumbers('fünf Millionen vierhundertdreiundzwanzig', { language: Languages['de-de'] });
// 5000423

wordsToNumbers('tweehonderddrieëndertig', { language: Languages['nl-nl'] });
// 233

wordsToNumbers('duzentos e cinquenta e seis', { language: Languages['pt-br'] });
// 256

API

wordsToNumbers(text, options?)

| argument | type | description | | --------- | --------- | -------------------------------------------------- | | text | string | the text to convert | | options | Options | optional, see below. Defaults to {} (en-us). |

Return value:

  • a number when the whole text is a single number ('five hundred' → 500)
  • a number[] when numbersOnly is set
  • otherwise the original text with every number replaced ('I have five apples' → 'I have 5 apples')

Options

| option | type | default | description | | ------------- | ----------- | --------- | ---------------------------------------------------------------------------------------- | | language | Languages | 'en-us' | language of the text | | numbersOnly | boolean | false | return every parsed number as a number[] instead of replacing them in the text | | oneNumber | boolean | false | glue all parsed numbers into one number, useful for years: 'nineteen ninety-eight' → 1998 | | debug | boolean | false | log the parsed regions |

Languages

| language | code | decimal separator words | joiner | | ---------- | --------- | ----------------------- | ------ | | English | en-us | point, dot | and | | Dutch | nl-nl | komma, punt | en | | German | de-de | komma | und | | Portuguese | pt-br | vírgula | e |

Behaviour

  • Compound words are supported: twenty-five, fünfundzwanzig, vijfentwintig, duzentos. A written word is only treated as a number when it consists entirely of number words, in-word glue (-, und, en, ën, e) and — for German — a trailing declension (zweiundzwanzigste, fünfter). This keeps ordinary words such as alone, keine, rein or geen out of the parser.
  • Ordinals are supported: the twenty-second of may → the 22 of may.
  • Decimals work both as spelled out numbers and as digit sequences: five point five hundred twenty one → 5.521 and five point five two one → 5.521.
  • Magnitudes are language specific: billion is 10^9 in English but 10^12 in German (Billion).
  • Sentence punctuation ends a number, so 'Give me twenty. Two are broken.' becomes 'Give me 20. 2 are broken.'.
  • Digits are not parsed; only words are converted.
  • The English a and the Dutch een are worth 1 inside a sentence (a hundred → 100), but are left alone when they are the only word of the input.

Development

This repo uses pnpm, vitest for tests and tsup for the build.

pnpm install
pnpm test          # run the suite once
pnpm test:watch    # watch mode
pnpm run typecheck # tsc over src *and* test (vitest itself does not type check)
pnpm run build     # dist/index.js (cjs), dist/index.mjs (esm), dist/index.d.ts
pnpm run size      # size-limit

There is currently no linter. The previous tsdx lint was removed together with tsdx, whose 2020 toolchain no longer works with TypeScript 5 or with a modern dependency tree.