English Numeric Words to Number Converter
Convert English numeric words and mixed text-number expressions to digits instantly. Handles millions, billions, hyphenated words, and mixed input formats.
About
Parsing English numeric expressions is deceptively complex. The phrase one million forty-five hundred ninety-two encodes a non-trivial additive-multiplicative structure where 45 hundred means 4500, not a syntax error. Most naive implementations fail on mixed inputs (words interleaved with digit characters), compound scales (twenty-three thousand four hundred), or informal constructs like nineteen ninety-nine. This converter implements a recursive descent parser that correctly handles the full English numeral grammar from 0 through trillions, including mixed-mode strings like one million 45 hundred 92. It returns NaN for genuinely unparseable input rather than guessing.
The parser follows the hierarchical scale model: tokens are grouped by magnitude (trillion > billion > million > thousand > hundred), with each group accumulated additively before multiplication by its scale factor. This tool approximates standard English numeral conventions. It does not handle ordinal forms (first, second) or fractional expressions (one half). Connector words like and are discarded as semantically empty.
Formulas
The parser decomposes English numeric text using an additive-multiplicative grammar. Each input phrase is segmented by scale words and accumulated hierarchically.
Where S = {trillion, billion, million, thousand, unit} is the ordered set of scale magnitudes. Each groups is itself computed as:
Where h is the hundreds digit (0 - 9), t is the tens value (0 - 90), and u is the units value (0 - 9 or teens 10 - 19). Digit tokens (e.g. 45) are injected directly into the accumulator at the appropriate position. If any token is neither a recognized word nor a valid integer, the output is NaN.
Reference Data
| English Word | Numeric Value | Category |
|---|---|---|
| zero | 0 | Unit |
| one | 1 | Unit |
| two | 2 | Unit |
| three | 3 | Unit |
| four | 4 | Unit |
| five | 5 | Unit |
| six | 6 | Unit |
| seven | 7 | Unit |
| eight | 8 | Unit |
| nine | 9 | Unit |
| ten | 10 | Teen |
| eleven | 11 | Teen |
| twelve | 12 | Teen |
| thirteen | 13 | Teen |
| fourteen | 14 | Teen |
| fifteen | 15 | Teen |
| sixteen | 16 | Teen |
| seventeen | 17 | Teen |
| eighteen | 18 | Teen |
| nineteen | 19 | Teen |
| twenty | 20 | Tens |
| thirty | 30 | Tens |
| forty | 40 | Tens |
| fifty | 50 | Tens |
| sixty | 60 | Tens |
| seventy | 70 | Tens |
| eighty | 80 | Tens |
| ninety | 90 | Tens |
| hundred | 100 | Scale |
| thousand | 1,000 | Scale |
| million | 1,000,000 | Scale |
| billion | 1,000,000,000 | Scale |
| trillion | 1,000,000,000,000 | Scale |