Converting number to words in JavaScript

When you want to display the number both as a numeric value and in words, or just in words, JavaScript comes to aid.

Example and the free JavaScript source code

For simplicity, we placed all the code you need in one single file - click here to see it at work. To get the source code, right click on the page, select View Source and save it to a file.

How does it work

  • Enter the number (for example, "123") and click on the "Convert number to words" button
  • All the work is done in the convert(input) function, which processes the numeric value ("123") into words ("One Hundred Twenty Three" ).