num2words
Convert numbers to written words in dozens of languages
Repository Health
Technical Analysis
num2words is a Python library that turns numbers like 42 into their written form, forty-two. It supports cardinal and ordinal output (forty-second), a range of formatting modes such as currency and years, and localization across dozens of languages.
Widely used for invoices, cheques, accessibility, and natural-language generation, num2words exposes a single num2words() function plus a command-line entry point. Its multi-language support makes it a common building block anywhere numbers need to be spelled out for humans.
What You Get
- A
num2words()function converting integers and floats to words - Cardinal and ordinal output (forty-two, forty-second)
- Currency, year, and other formatting modes via the
toargument - Localization across dozens of languages through per-language modules
- A command-line entry point for quick conversions
Common Use Cases
- Spelling out amounts on invoices, cheques, and receipts
- Generating human-readable or spoken numbers for accessibility
- Localizing numeric output in multilingual applications
Under The Hood
Architecture - The library centers on a dispatcher (num2words) that selects a language-specific converter class based on the lang code, then calls the appropriate method for the requested to mode (cardinal, ordinal, currency, year). Each language lives in its own module (lang_EN, lang_FR, etc.) subclassing shared base logic that handles digit grouping and scale words.
Tech Stack - Pure Python with no heavy runtime dependencies, packaged with a setup.py console-scripts entry point for the CLI. It ships a tox configuration to test across multiple Python versions and a linting pass in CI.
Code Quality - The project has a large contributor base and broad language coverage, with a test suite the README candidly describes as thin in places and ordinal support flagged as imperfect for some languages. Its enormous download volume reflects heavy production use despite low recent activity.
API Design - The public surface is essentially one function with keyword arguments, which keeps everyday use trivial while the to and lang parameters expose the breadth of formatting and localization options. The matching CLI mirrors the same behavior for shell use.