Numeral.js Overview
Numeral.js is a powerful, lightweight JavaScript library for formatting and manipulating numbers. It provides a simple yet flexible way to format numbers for display, including currencies, percentages, times, and data sizes. Whether you're dealing with integers, decimals, or large numbers, Numeral.js helps present them in a clean, human-readable format.
Inspired by Moment.js, Numeral.js offers a similar chainable API and robust internationalization support through locales.
Key Features
- Simple & Chainable API: Manipulate and format numbers with an intuitive, easy-to-read syntax.
- Powerful Formatting: A wide range of built-in formatters for currency, percentages, bytes, ordinals, and more.
- Internationalization: Extensive support for different languages and regional number formats through a locale system.
- Extensible: Easily create and register custom formats and locales to suit your specific needs.
- Zero Dependencies: Lightweight and self-contained, making it easy to integrate into any project.
- Value Unformatting: Parses formatted strings back into their original numeric values.
Quick Example
Here's a quick look at what Numeral.js can do:
// Formatting
var myNumber = numeral(1234.56);
var currency = myNumber.format('$0,0.00'); // '$1,234.56'
var percentage = numeral(0.75).format('0.0%'); // '75.0%'
// Manipulation
var total = numeral(1000).add(50).subtract(150).value(); // 900
// Chaining
var result = numeral('1,234.56').add(100).format('0,0'); // '1,335'
// Locales
numeral.locale('fr');
var frenchNumber = numeral(10000.23).format('0,0.00 $'); // '10 000,23 €'
Ready to get started? Head over to the Installation page to add Numeral.js to your project.