Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

millify

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

millify

Converts long numbers to pretty, human-readable strings

  • 6.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111K
increased by3.81%
Maintainers
1
Weekly downloads
 
Created
Source

Millify

Converts long numbers into pretty, human-readable strings.

Before :unamused:After :tada:
2000'2K'
10000'10k'
42500'42.5 kg'
1250000'1.25 MB'
2700000000'2.7 bil'

Install

Get it on npm:

npm install millify

Usage

Command line

$ millify 12345
12.3K

See millify --help for options.

Programmatically

millify(value: number, options: MillifyOptions)
import millify from "millify";

// For CommonJS: `const { millify } = require("millify");`

millify(2500); // 2.5K

millify(1024000, {
  precision: 3,
  lowercase: true
});
// 1.024m

millify(39500, {
  precision: 2,  
  locales: "de-DE"
});
// 3,95K

millify(1440000, {
  units: ["B", "KB", "MB", "GB", "TB"],
  space: true,
});
// 1.44 MB

Options

NameTypeDefaultDescription
precisionnumber1Number of decimal places to use
localesstring | Array<string>browser languageFormats the number in different languages
lowercasebooleanfalseUse lowercase abbreviations
spacebooleanfalseAdd a space between number and abbreviation
unitsArray<string>['', 'K', 'M', 'B', 'T', 'P', 'E']Unit abbreviations

Keywords

FAQs

Package last updated on 12 Mar 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc