Skip to content
🛠️ToolsShed

Number to Words

Convert numbers to English words (e.g. 1234 → one thousand two hundred thirty-four).

About this tool

Number to Words is a simple tool that converts numeric values into their written English equivalents. Whether you need to spell out a number for a formal document, understand how to pronounce a large figure, or verify the textual representation of a quantity, this tool provides instant, accurate conversions. It's particularly useful for financial documents, formal correspondence, and anyone learning English number nomenclature.

To use the tool, simply enter any integer or decimal number into the input field and click the convert button. The tool instantly displays the written form of your number in clear, grammatically correct English. You can convert everything from small single-digit numbers to large figures in the millions or billions, as well as decimal and fractional values, making it versatile for diverse needs.

Frequently Asked Questions

Code Implementation

# Number to words using the num2words library
# Install: pip install num2words

from num2words import num2words

# Basic conversion (English)
print(num2words(42))          # forty-two
print(num2words(1000000))     # one million
print(num2words(1234567))     # one million, two hundred and thirty-four thousand,
                              #   five hundred and sixty-seven

# Ordinal numbers
print(num2words(1, to='ordinal'))   # first
print(num2words(42, to='ordinal'))  # forty-second
print(num2words(100, to='ordinal')) # one hundredth

# Other languages
print(num2words(42, lang='de'))    # zweiundvierzig
print(num2words(42, lang='fr'))    # quarante-deux
print(num2words(42, lang='es'))    # cuarenta y dos
print(num2words(42, lang='ja'))    # 四十二

# Currency (year) mode
print(num2words(2024, to='year'))  # twenty twenty-four

# Without the library: simple custom implementation
ones = ['', 'one', 'two', 'three', 'four', 'five', 'six',
        'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve',
        'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen',
        'eighteen', 'nineteen']
tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty',
        'sixty', 'seventy', 'eighty', 'ninety']

def number_to_words(n: int) -> str:
    if n == 0: return 'zero'
    if n < 0:  return 'negative ' + number_to_words(-n)
    if n < 20: return ones[n]
    if n < 100:
        return tens[n // 10] + (('-' + ones[n % 10]) if n % 10 else '')
    if n < 1000:
        rest = number_to_words(n % 100)
        return ones[n // 100] + ' hundred' + (' and ' + rest if rest else '')
    if n < 1_000_000:
        rest = number_to_words(n % 1000)
        return number_to_words(n // 1000) + ' thousand' + (', ' + rest if rest else '')
    rest = number_to_words(n % 1_000_000)
    return number_to_words(n // 1_000_000) + ' million' + (', ' + rest if rest else '')

print(number_to_words(42))       # forty-two
print(number_to_words(100))      # one hundred
print(number_to_words(1234))     # one thousand, two hundred and thirty-four

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.