Gathering detailed insights and metrics for bytes
Gathering detailed insights and metrics for bytes
Gathering detailed insights and metrics for bytes
Gathering detailed insights and metrics for bytes
pretty-bytes
Convert bytes to a human readable string: 1337 → 1.34 kB
random-bytes
URL and cookie safe UIDs
@transloadit/prettier-bytes
> Even though this module is publicly accessible, we do not recommend using it in projects outside of [Transloadit](https://transloadit.com). We won't make any guarantees about its workings and can change things at any time, we won't adhere strictly to Se
ripemd160
Compute ripemd160 of bytes or strings.
npm install bytes
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.8
Supply Chain
99.4
Quality
78.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
12,943,710,726
Last Day
3,225,859
Last Week
53,859,326
Last Month
236,309,483
Last Year
2,697,260,933
MIT License
470 Stars
169 Commits
54 Forks
8 Watchers
2 Branches
23 Contributors
Updated on Jun 13, 2025
Minified
Minified + Gzipped
Latest Version
3.1.2
Package Id
bytes@3.1.2
Unpacked Size
11.98 kB
Size
4.39 kB
File Count
5
NPM Version
8.1.2
Node Version
16.13.1
Cumulative downloads
Total Downloads
Last Day
-7.8%
3,225,859
Compared to previous day
Last Week
-8.2%
53,859,326
Compared to previous week
Last Month
5.6%
236,309,483
Compared to previous month
Last Year
-0.7%
2,697,260,933
Compared to previous year
4
Utility to parse a string bytes (ex: 1TB
) to bytes (1099511627776
) and vice-versa.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
1$ npm install bytes
1var bytes = require('bytes');
Default export function. Delegates to either bytes.format
or bytes.parse
based on the type of value
.
Arguments
Name | Type | Description |
---|---|---|
value | number |string | Number value to format or string value to parse |
options | Object | Conversion options for format |
Returns
Name | Type | Description |
---|---|---|
results | string |number |null | Return null upon error. Numeric value in bytes, or string value otherwise. |
Example
1bytes(1024); 2// output: '1KB' 3 4bytes('1KB'); 5// output: 1024
Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is rounded.
Arguments
Name | Type | Description |
---|---|---|
value | number | Value in bytes |
options | Object | Conversion options |
Options
Property | Type | Description |
---|---|---|
decimalPlaces | number |null | Maximum number of decimal places to include in output. Default value to 2 . |
fixedDecimals | boolean |null | Whether to always display the maximum number of decimal places. Default value to false |
thousandsSeparator | string |null | Example of values: ' ' , ',' and '.' ... Default value to '' . |
unit | string |null | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to '' (which means auto detect). |
unitSeparator | string |null | Separator to use between number and unit. Default value to '' . |
Returns
Name | Type | Description |
---|---|---|
results | string |null | Return null upon error. String value otherwise. |
Example
1bytes.format(1024); 2// output: '1KB' 3 4bytes.format(1000); 5// output: '1000B' 6 7bytes.format(1000, {thousandsSeparator: ' '}); 8// output: '1 000B' 9 10bytes.format(1024 * 1.7, {decimalPlaces: 0}); 11// output: '2KB' 12 13bytes.format(1024, {unitSeparator: ' '}); 14// output: '1 KB'
Parse the string value into an integer in bytes. If no unit is given, or value
is a number, it is assumed the value is in bytes.
Supported units and abbreviations are as follows and are case-insensitive:
b
for byteskb
for kilobytesmb
for megabytesgb
for gigabytestb
for terabytespb
for petabytesThe units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
Arguments
Name | Type | Description |
---|---|---|
value | string |number | String to parse, or number in bytes. |
Returns
Name | Type | Description |
---|---|---|
results | number |null | Return null upon error. Value in bytes otherwise. |
Example
1bytes.parse('1KB'); 2// output: 1024 3 4bytes.parse('1024'); 5// output: 1024 6 7bytes.parse(1024); 8// output: 1024
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More