New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

number-commas

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-commas

A simple library to format numbers with commas

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

number-commas

A simple and lightweight JavaScript library to format numbers with comma separators.

Installation

npm install number-commas

Usage

ES Module (import)

import numberCommas from 'number-commas';

console.log(numberCommas(1000));       // "1,000"
console.log(numberCommas(1000000));    // "1,000,000"
console.log(numberCommas(123456789));  // "123,456,789"
console.log(numberCommas(1234.567));   // "1,234.567"

CommonJS (require)

const numberCommas = require('number-commas');

console.log(numberCommas(1000));       // "1,000"
console.log(numberCommas(1000000));    // "1,000,000"

API

numberCommas(num)

Formats a number by adding comma separators for thousands.

Parameters

  • num (Number): The number to format

Returns

  • (String): The formatted number with commas

Example

import numberCommas from 'number-commas';

const price = 1234567;
console.log(`Price: $${numberCommas(price)}`); // "Price: $1,234,567"

const decimal = 12345.6789;
console.log(`Value: ${numberCommas(decimal)}`); // "Value: 12,345.6789"

License

ISC

Keywords

number

FAQs

Package last updated on 25 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts