Human readable file size in JavaScript

File Size JS a library to generate a human readable file size in JavaScript (KB, MB, GB, TB, etc).

Format readable file size in JavaScript

The filesize.js is a tiny JavaScript library that creates a global function named filesize(). It provides an easy way to get a human readable file size String.

The library can be loaded from npm, as an AMD module, or as a regular script tag.

A library to format human readable file size in JavaScript
A library to format human readable file size in JavaScript

Samples:

filesize(500);                        // "500 B"
filesize(500, {bits: true});          // "4 Kb"
filesize(265318, {base: 10});         // "265.32 kB"
filesize(265318);                     // "259.1 KB"
filesize(265318, {round: 0});         // "259 KB"
filesize(265318, {output: "array"});  // [259.1, "KB"]
filesize(1, {symbols: {B: "Б"}});    // "1 Б"
filesize(1024);                       // "1 KB"
filesize(1024, {exponent: 0});        // "1024 B"
filesize(1024, {output: "exponent"}); // 1

License: the BSD-3 license.

Project homepage and docs:

http://filesizejs.com

Get the library from GitHub:

https://github.com/avoidwork/filesize.js

Enjoy!

Share:Share on Facebook2Share on Google+1Tweet about this on TwitterShare on LinkedIn1Pin on Pinterest1