
Research
/Security News
Malicious Chrome and Firefox Extensions Steal Crypto Traders’ Session and Wallet Data
Malicious Chrome and Firefox extensions target Axiom Trade and Padre users, stealing session tokens and wallet data.
Lightweight, zero-dependency JavaScript utility to convert bytes to human-readable strings with localization support
A lightweight, high-performance file size utility that converts bytes to human-readable strings. Zero dependencies. 100% test coverage.
npm install filesize
Fully typed with TypeScript definitions included:
import { filesize, partial } from 'filesize';
const result: string = filesize(1024);
const formatted: { value: number; symbol: string; exponent: number; unit: string } = filesize(1024, { output: 'object' });
const formatter: (arg: number | bigint) => string = partial({ standard: 'iec' });
import {filesize, partial} from "filesize";
filesize(1024); // "1.02 kB"
filesize(265318); // "265.32 kB"
filesize(1024, {standard: "iec"}); // "1 KiB"
filesize(1024, {bits: true}); // "8.19 kbit"
import {partial} from "filesize";
const formatBinary = partial({standard: "iec"});
formatBinary(1024); // "1 KiB"
formatBinary(1048576); // "1 MiB"
| Option | Type | Default | Description |
|---|---|---|---|
bits | boolean | false | Calculate bits instead of bytes |
base | number | -1 | Number base (2 for binary, 10 for decimal, -1 for auto) |
round | number | 2 | Decimal places to round |
locale | string|boolean | "" | Locale for formatting, true for system locale |
localeOptions | Object | {} | Additional locale options |
separator | string | "" | Custom decimal separator |
spacer | string | " " | Value-unit separator |
symbols | Object | {} | Custom unit symbols |
standard | string | "" | Unit standard (si, iec, jedec) |
output | string | "string" | Output format (string, array, object, exponent) |
fullform | boolean | false | Use full unit names |
fullforms | Array | [] | Custom full unit names |
exponent | number | -1 | Force specific exponent (-1 for auto) |
roundingMethod | string | "round" | Math method (round, floor, ceil) |
precision | number | 0 | Significant digits (0 for auto) |
pad | boolean | false | Pad decimal places |
// String (default)
filesize(1536); // "1.54 kB"
// Array
filesize(1536, {output: "array"}); // [1.54, "kB"]
// Object
filesize(1536, {output: "object"});
// {value: 1.54, symbol: "kB", exponent: 1, unit: "kB"}
// Exponent
filesize(1536, {output: "exponent"}); // 1
// SI (default, base 10)
filesize(1000); // "1 kB"
// IEC (binary, requires base: 2)
filesize(1024, {base: 2, standard: "iec"}); // "1 KiB"
// JEDEC (binary calculation, traditional symbols)
filesize(1024, {standard: "jedec"}); // "1 KB"
// Bits
filesize(1024, {bits: true}); // "8.19 kbit"
filesize(1024, {bits: true, base: 2}); // "8 Kibit"
// Full form
filesize(1024, {fullform: true}); // "1.02 kilobytes"
filesize(1024, {base: 2, fullform: true}); // "1 kibibyte"
// Custom separator
filesize(265318, {separator: ","}); // "265,32 kB"
// Padding
filesize(1536, {round: 3, pad: true}); // "1.536 kB"
// Precision
filesize(1536, {precision: 3}); // "1.54 kB"
// Locale
filesize(265318, {locale: "de"}); // "265,32 kB"
// Custom symbols
filesize(1, {symbols: {B: "Б"}}); // "1 Б"
// BigInt support
filesize(BigInt(1024)); // "1.02 kB"
// Negative numbers
filesize(-1024); // "-1.02 kB"
try {
filesize("invalid");
} catch (error) {
// TypeError: "Invalid number"
}
try {
filesize(1024, {roundingMethod: "invalid"});
} catch (error) {
// TypeError: "Invalid rounding method"
}
npm test # Run all tests (lint + node:test)
npm run test:watch # Live test watching
100% test coverage with 149 tests:
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
constants.js | 100 | 100 | 100 | 100 |
filesize.js | 100 | 100 | 100 | 100 |
helpers.js | 100 | 100 | 100 | 100 |
--------------|---------|----------|---------|---------|-------------------
npm install # Install dependencies
npm run dev # Development mode with live reload
npm run build # Build distributions
npm run lint # Check code style
npm run lint:fix # Auto-fix linting issues
filesize.js/
├── src/
│ ├── filesize.js # Main implementation (285 lines)
│ ├── helpers.js # Helper functions (215 lines)
│ └── constants.js # Constants (81 lines)
├── tests/
│ └── unit/
├── dist/ # Built distributions
└── types/ # TypeScript definitions
Optimization tips:
partial() formatters for reuseobject output for fastest structured data accessWe welcome contributions! Please see our Contributing Guidelines for details.
See CHANGELOG.md for a history of changes.
Copyright (c) 2026 Jason Mulligan
Licensed under the BSD-3 license.
Similar to filesize, pretty-bytes converts byte values into a human-readable format. It focuses on simplicity and does not offer as many customization options as filesize, making it a good choice for straightforward use cases.
The bytes package also provides functionality for formatting byte sizes into human-readable strings. It offers a balance between simplicity and customization, with options to specify the number of decimal places and the units to use.
FAQs
Lightweight, zero-dependency JavaScript utility to convert bytes to human-readable strings with localization support
The npm package filesize receives a total of 4,761,997 weekly downloads. As such, filesize popularity was classified as popular.
We found that filesize demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Research
/Security News
Malicious Chrome and Firefox extensions target Axiom Trade and Padre users, stealing session tokens and wallet data.

Security News
GPT-6 Astra hits 100% on ExploitBench and finds zero-days autonomously, while independent tests reveal scope violations and monitoring gaps.

Product
Socket can now send alerts and supply chain attack notifications to Microsoft Teams, with filters that route the right updates to each channel.