This is a React-based npm package that translates/converts numbers into words. It allows developers to easily integrate this functionality into their React applications. This package will help to convert number or amounts into words form.
npm install react-number-to-words
- Import the convertToWords function from the package:
import {convertToWords} from 'react-number-to-words';
- Call the convertToWords function with a number as an argument:
const number = 123;
const words = convertToWords(number);
console.log(words); // Output: "One Hundred and Tweenty Three"
- (Optional) Use the provided React components for user input and display:
import {NumberInput, NumberDisplay} from 'react-number-to-words';
- Call the toOrdinal function with a number as an argument:
const number = 123;
const ordinal = toOrdinal(number);
console.log(ordinal); // Output: "123th"
- Converts numbers up to trillions into words.
- Supports custom number formatting (currently not implemented, but can be added in the future).
Feel free to submit pull requests for bug fixes, improvements, or new features. We welcome community contributions.
This package is licensed under the MIT License.