Convert bytes to a human readable string: 1337 → 1.34 kB
JavaScript
Latest commit ed4f51e Apr 24, 2017 @caub caub committed with Minor code simplification (#32)
Permalink
Failed to load latest commit information.
.editorconfig ES2015ify Aug 26, 2016
.gitattributes init Feb 9, 2014
.gitignore init Feb 9, 2014
.travis.yml ES2015ify Aug 26, 2016
index.js Minor code simplification (#32) Apr 24, 2017
license various tweaks Aug 9, 2014
package.json 4.0.2 Aug 28, 2016
readme.md use archived link in readme Sep 29, 2016
test.js simplify argument checking Aug 27, 2016

readme.md

pretty-bytes Build Status

Convert bytes to a human readable string: 13371.34 kB

Useful for displaying file sizes for humans.

Note that it uses base-10 (e.g. kilobyte).
Read about the difference between kilobyte and kibibyte.

Install

$ npm install --save pretty-bytes

Usage

const prettyBytes = require('pretty-bytes');

prettyBytes(1337);
//=> '1.34 kB'

prettyBytes(100);
//=> '100 B'

Related

License

MIT © Sindre Sorhus