JSPM

file-size-pretty

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q50516F
  • License ISC

Convert file sizes like 34892823 into human-readable formats like 33.2 MB.

Package Exports

  • file-size-pretty
  • file-size-pretty/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (file-size-pretty) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

# file-size-pretty

Convert file sizes in bytes into human-readable strings — like `117.7 MB` or `1.5 GB`.

## Features

- Converts raw byte sizes into KB, MB, GB, etc.
- Lightweight and dependency-free
- Supports decimal precision
- Works in Node.js and browser environments

## Installation

npm install file-size-pretty

## Usage

```js
const fileSizePretty = require('file-size-pretty');

console.log(fileSizePretty(1000)); // "1000 B"
console.log(fileSizePretty(1024)); // "1 KB" (default: binary)
console.log(fileSizePretty(1000, 1, { standard: 'si' })); // "1 kB"
console.log(fileSizePretty(1000000, 2, { standard: 'si' })); // "1 MB"

import fileSizePretty from 'file-size-pretty'
console.log(fileSizePretty(9999999))  //simple testing

API

fileSizePretty(bytes, decimals = 1)

Parameter Type Description
bytes number File size in bytes
decimals number Number of decimal places (default: 1)

Returns

A human-readable string with the appropriate size unit.

Example Output

Input Bytes Output
0 "0 B"
500 "500 B"
1048576 "1 MB"
1073741824 "1 GB"
1099511627776 "1 TB"

License

MIT


Made with ❤️ by Ruman Ahmed

# file-size-pretty