Gathering detailed insights and metrics for pretty-bytes
Gathering detailed insights and metrics for pretty-bytes
Gathering detailed insights and metrics for pretty-bytes
Gathering detailed insights and metrics for pretty-bytes
Convert bytes to a human readable string: 1337 → 1.34 kB
npm install pretty-bytes
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.8
Supply Chain
99.5
Quality
79.5
Maintenance
100
Vulnerability
100
License
JavaScript (96.8%)
TypeScript (3.2%)
Total Downloads
3,160,305,670
Last Day
772,344
Last Week
15,050,067
Last Month
65,601,718
Last Year
706,705,640
MIT License
1,213 Stars
81 Commits
85 Forks
11 Watchers
1 Branches
17 Contributors
Updated on Jun 30, 2025
Minified
Minified + Gzipped
Latest Version
7.0.0
Package Id
pretty-bytes@7.0.0
Unpacked Size
11.94 kB
Size
3.79 kB
File Count
5
NPM Version
10.9.2
Node Version
23.6.1
Published on
Apr 29, 2025
Cumulative downloads
Total Downloads
Last Day
-10.5%
772,344
Compared to previous day
Last Week
-8.7%
15,050,067
Compared to previous week
Last Month
2.6%
65,601,718
Compared to previous month
Last Year
5%
706,705,640
Compared to previous year
Convert bytes to a human readable string:
1337
→1.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.
1npm install pretty-bytes
1import prettyBytes from 'pretty-bytes'; 2 3prettyBytes(1337); 4//=> '1.34 kB' 5 6prettyBytes(100); 7//=> '100 B' 8 9// Display with units of bits 10prettyBytes(1337, {bits: true}); 11//=> '1.34 kbit' 12 13// Display file size differences 14prettyBytes(42, {signed: true}); 15//=> '+42 B' 16 17// Localized output using German locale 18prettyBytes(1337, {locale: 'de'}); 19//=> '1,34 kB'
Type: number | bigint
The number to format.
Type: object
Type: boolean
Default: false
Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
Type: boolean
Default: false
Format the number as bits instead of bytes. This can be useful when, for example, referring to bit rate.
Type: boolean
Default: false
Format the number using the Binary Prefix instead of the SI Prefix. This can be useful for presenting memory amounts. However, this should not be used for presenting file sizes.
Type: boolean | string
Default: false
(No localization)
Important: Only the number and decimal separator are localized. The unit title is not and will not be localized.
true
: Localize the output using the system/browser locale.string
: Expects a BCP 47 language tag (For example: en
, de
, …)string[]
: Expects a list of BCP 47 language tags (For example: en
, de
, …)Type: number
Default: undefined
The minimum number of fraction digits to display.
If neither minimumFractionDigits
or maximumFractionDigits
are set, the default behavior is to round to 3 significant digits.
1import prettyBytes from 'pretty-bytes'; 2 3// Show the number with at least 3 fractional digits 4prettyBytes(1900, {minimumFractionDigits: 3}); 5//=> '1.900 kB' 6 7prettyBytes(1900); 8//=> '1.9 kB'
Type: number
Default: undefined
The maximum number of fraction digits to display.
If neither minimumFractionDigits
or maximumFractionDigits
are set, the default behavior is to round to 3 significant digits.
1import prettyBytes from 'pretty-bytes'; 2 3// Show the number with at most 1 fractional digit 4prettyBytes(1920, {maximumFractionDigits: 1}); 5//=> '1.9 kB' 6 7prettyBytes(1920); 8//=> '1.92 kB'
Type: boolean
Default: true
Put a space between the number and unit.
1import prettyBytes from 'pretty-bytes'; 2 3prettyBytes(1920, {space: false}); 4//=> '1.9kB' 5 6prettyBytes(1920); 7//=> '1.92 kB'
k
is the standardized SI prefix for kilo.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
4 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 4
Reason
Found 11/30 approved changesets -- score normalized to 3
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
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 Moreprettier-bytes
augment pretty-bytes to make the output a little more readable (and a little less precise)
bytes-formatter
Bytes formatter module provides a function to format byte values into human-readable strings with appropriate units (bytes, KB, MB, GB, TB, PB).
@types/pretty-bytes
Stub TypeScript definitions entry for pretty-bytes, which provides its own types definitions
pretty-bytes-cli
Convert bytes to a human readable string: 1337 → 1.34 kB