
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

File-size module for node.js for converting, manipulating, and handling file-sizes.
1024, default), SI (power 1000), and JEDEC (Alternative SI Unit Notation).bytes to K, M, G, and so forth...$ npm install file-size
Now require it in your files like so:
var filesize = require('file-size');
filesize(Number bytes, Object options)
Using filesize is very easy, a lot easier if you know the Specification Table. However, it's not required to know it, and in most cases you won't need it.
Initialization
Filesize works in a jQuery chainable manner so you can use multiple instances without trouble.
var size = filesize(186457865);
Options
var size = filesize(186457865, {
fixed: 2,
spacer: ' '
});
fixed - Number of positions after the decimal to show, default is 2spacer - Space between the number and the unit, default is a space Generates human readable filesize.
spec can be one of the following:
siiecjedecDefault
Power of 1024
// outputs: 177.82 MiB
filesize(186457865).human();
Power of 1000
// outputs: 186.46 MB
filesize(186457865).human('si');
Changes IEC default unit notation iB to B for the following: KB, MB, GB
The rest are in iB notation, as per JEDEC Specification.
// outputs: 186.46 MB
filesize(186457865).human('jedec');
Converts bytes to another filesize unit
unit of size can be one of the following:
B, KB, MB, GB, TB, PB, EB, ZB, YBspec can be one of the following:
siiecjedecDefault
// outputs: 177.82
filesize(186457865).to('MB');
// outputs: 186.46
filesize(186457865).to('MB', true);
Calculates suffix, magnitude, fixed, non-fixed, bits (fixed, non-fixed) from specified bytes against the specified spec.
spec can be one of the following:
siiecjedec/*
* outputs:
*
* {
* suffix: 'Bytes',
* magnitude: 0,
* result: 8,
* fixed: '8.00',
* bits: { result: 1, fixed: '1.00' }
* }
*/
var result = filesize(8).calculate()
FAQs
Lightweight filesize to human-readable / proportions w/o dependencies.
The npm package file-size receives a total of 84,566 weekly downloads. As such, file-size popularity was classified as popular.
We found that file-size demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.