BigInt & Large Numbers β
to-words accepts bigint and precision-preserving string input, so you can safely convert values far beyond Number.MAX_SAFE_INTEGER without rounding or truncation.
BigInt Example β
js
import { ToWords } from 'to-words';
const tw = new ToWords({ localeCode: 'en-US' });
tw.convert(1000000000000000000n);
// "One Quintillion"
tw.convert('9007199254740993');
// "Nine Quadrillion Seven Trillion One Hundred Ninety Nine Billion..."
// Indian system
const hi = new ToWords({ localeCode: 'hi-IN' });
hi.convert(100000000000000000n);
// "ΰ€ΰ€ ΰ€Άΰ€ΰ€"String Input For Precision β
js
const tw = new ToWords({ localeCode: 'en-US' });
tw.convert('9007199254740993');
tw.convert('1000000000000000000000');Use string input when the value came from a database, finance system, or API and must remain exact.
Large-Number Systems β
en-USand most western locales use short scalede-DEandfr-FRuse long scale wording such asMilliardeandMilliardhi-IN,ta-IN, andur-PKuse lakh / crore style groupingja-JP,zh-CN, andko-KRuse East Asian units such asδΈ,ε, andε
When To Use BigInt vs String β
- Use
bigintwhen your app already holds whole numbers as integers - Use
stringwhen decimal precision or trailing zeros matter - Use plain
numberonly when the value is safely within JavaScript integer limits and fractional precision is not critical