text2digits
A small library to convert text numbers to digits in a string
Decision gist · record as of 2026-08-14
Yes. The package is lightweight, actively maintained, has no dependencies, and solves a specific problem well—converting spoken/written number words to digits. It's particularly valuable if you work with speech-to-text pipelines. The MIT license imposes no restrictions. No known vulnerabilities. Install it if you need this conversion; skip it if your input is already numeric.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.7 or later.
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained as of 2026-04-28 with a recent commit history.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal attribution requirements.
last release 2026-04-28 (108 days) · last repo commit 2026-04-28 · 67 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 242,404 downloads/mo, #8,857 on PyPI
Alternatives
Verify before relying
pip install text2digits
from text2digits import text2digits
t2d = text2digits.Text2Digits()
result = t2d.convert("I am twenty nine years old")
print(result) # 'I am 29 years old'- Whether the package handles all edge cases in production speech-to-text pipelines beyond the documented examples.
- Performance characteristics when processing very long strings or batch operations.
- Whether the similarity_threshold spelling correction feature is suitable for your use case's accuracy requirements.
What it is and what it does
text2digits is a lightweight Python library that recognizes number words written as text—like "twenty ten", "one thousand six hundred sixty six", or "negative thirty seven"—and replaces them with their numeric equivalents in a string. It handles both cardinal numbers (one, two, three) and ordinals (first, second, third), supports informal year-style concatenation ("twenty ten" becomes "2010"), and works with multiple number systems including the Indian scales (lakh, crore, arab, kharab). The library is designed for post-processing speech-to-text output, particularly from voice assistants like Alexa or Lex, where spoken numbers arrive as words and need to be normalized to digits.
The package has no runtime dependencies and installs as a pure Python wheel. It recognizes a wide variety of phrasings—both formal and conversational—and can correct minor spelling variations. Known limitations include that negative numbers preserve the word "negative" rather than converting to a minus sign, and ordinal suffixes are dropped by default ("third" becomes "3" not "3rd") unless explicitly enabled. Decimal literals adjacent to scale words are supported ("2.5 thousand" becomes "2500").
Use it for
- Clean up Alexa or Lex transcription output where spoken numbers appear as words rather than digits.
- Normalize user input from voice interfaces before storing or processing numeric data.
- Parse informal written descriptions containing number words (e.g., chat logs, survey responses) into machine-readable form.
- Convert year expressions in narrative text ("born in nineteen ninety two") to standard numeric format.
- Handle ordinal references in text ("the fourth cousin") by converting them to digit form for indexing or comparison.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is lightweight, actively maintained, has no dependencies, and solves a specific problem well—converting spoken/written number words to digits. It's particularly valuable if you work with speech-to-text pipelines. The MIT license imposes no restrictions. No known vulnerabilities. Install it if you need this conversion; skip it if your input is already numeric.
Install
text2digits on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-04-28 with a recent commit history.
Requires Python 3.7 or later.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal attribution requirements.
Quickstart
pip install text2digits
from text2digits import text2digits
t2d = text2digits.Text2Digits()
result = t2d.convert("I am twenty nine years old")
print(result) # 'I am 29 years old'
Verify before relying
- Whether the package handles all edge cases in production speech-to-text pipelines beyond the documented examples.
- Performance characteristics when processing very long strings or batch operations.
- Whether the similarity_threshold spelling correction feature is suitable for your use case's accuracy requirements.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 108 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 242,404 / month, #8,857 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 |
Evidence: text2digits-0.1.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “convert text numbers to digits”
- text2digitsConverts written-out number words in text to their digit equivalents,…
- kanjizeConverts between Japanese kanji number representations and integers,…
- cn2anConverts between Chinese numerals and Arabic numerals in multiple…
Give your agent the search over MCP, or paste the wish link into any chat.
More Linguistic packages
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
tiktoken is a fast BPE tokenizer that converts text into token sequences compatible with OpenAI models, supporting multiple encoding schemes including o200k_base and model-specific encodings.
Install it if you work with OpenAI APIs or need to understand token boundaries in GPT-family models.
Detects character encoding and language in byte sequences with high accuracy, supporting 99 encodings and returning confidence scores, language tags, and MIME types.
Install it if you need to detect character encoding or language in byte data; the rewrite makes it substantially faster and more accurate than its predecessors.
Converts Unicode text to ASCII by transliterating non-ASCII characters into their closest ASCII equivalents, with no runtime dependencies.
However, if transliteration quality or ongoing maintenance matters, consider unidecode instead despite its GPL-only license.
Lark is a parsing library that builds abstract syntax trees from context-free grammars, supporting multiple parsing algorithms (Earley, LALR(1), CYK) with automatic line and column tracking.
Python bindings to the tree-sitter parsing library, enabling incremental parsing and syntax tree analysis for source code.
See also text2num · unicode-rbnf · word2number · number-parser · kanjize · num2words · indic-numtowords · inflect · sigfig · luhn