{"id":21995991,"url":"https://github.com/andria-dev/pretty-bytes","last_synced_at":"2026-04-18T02:07:23.737Z","repository":{"id":124003138,"uuid":"182823905","full_name":"andria-dev/pretty-bytes","owner":"andria-dev","description":"Format sizes from bytes to human readable strings.","archived":false,"fork":false,"pushed_at":"2023-11-22T14:43:27.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-28T10:46:41.036Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npm.im/@chbphone55/pretty-bytes","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andria-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-22T16:15:28.000Z","updated_at":"2023-11-22T14:43:31.000Z","dependencies_parsed_at":"2023-11-22T16:22:43.360Z","dependency_job_id":null,"html_url":"https://github.com/andria-dev/pretty-bytes","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andria-dev%2Fpretty-bytes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andria-dev%2Fpretty-bytes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andria-dev%2Fpretty-bytes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andria-dev%2Fpretty-bytes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andria-dev","download_url":"https://codeload.github.com/andria-dev/pretty-bytes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245053799,"owners_count":20553396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T21:19:40.329Z","updated_at":"2026-04-18T02:07:18.695Z","avatar_url":"https://github.com/andria-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @chbphone55/pretty-bytes\n\nFormat sizes from bytes to human readable strings\n\n\u003e ```js\n\u003e Convert bytes to human readable strings\n\u003e 1032192 → ['1,008', 'KiB', 'kibibytes']\n\u003e ```\n\n_Note that this package uses base-2 (e.g. kibibyte) so every 1024 bytes is 1 KiB and every 1024 KiB is 1 MiB. [Read about the difference between kilobyte and kibibyte.](https://web.archive.org/web/20150324153922/https://pacoup.com/2009/05/26/kb-kb-kib-whats-up-with-that/)_\n\n## Usage\n\n### Install\n\nTo install the package, use a package manager to access the NPM registry.\n\n```bash\npnpm install @chbphone55/pretty-bytes\n\n# or\n\nyarn add @chbphone55/pretty-bytes\n```\n\n### Import\n\nThe function is exported as `format`.\n\n```js\nimport { format } from '@chbphone55/pretty-bytes';\n\n// or\n\nconst { format } = require('@chbphone55/pretty-bytes');\n```\n\n### Example\n\nTo use `format`, pass it the size of your file in bytes. Optionally, you can pass in a locale as the second argument. _The locale defaults to `en`._\n\n```js\nformat(0);\n// =\u003e ['0', 'B', 'bytes']\n\nformat(-1);\n// =\u003e ['-1', 'B', 'bytes']\n\nformat(1024);\n// =\u003e ['1', 'KiB', 'kibibytes']\n\nformat(2621440);\n// =\u003e ['2.5', 'MiB', 'mebibytes']\n\nformat(1041332);\n// =\u003e ['1,016.926', 'KiB', 'kibibytes'];\n\nformat(1041332, 'es');\n// =\u003e ['1.016,926', 'KiB', 'kibibytes']\n\n// You can also use `navigator.language`\nformat(1041332, navigator.language);\n```\n\n### API\n\n```ts\nformat(\n  // The number to format\n  size: number,\n  // The locale to use with `.toLocaleString()`\n  locale?: string = 'en'\n): [string, Units.short, Units.long]\n\nnamespace Units {\n  type short = 'B' | 'KiB' | 'MiB' | 'GiB' | 'TiB' | 'PiB' | 'EiB' | 'ZiB' | 'YiB';\n  type long = 'bytes' | 'kibibytes' | 'mebibytes' | 'gibibytes' | 'tebibytes' | 'pebibytes' | 'exbibytes' | 'zebibytes' | 'yobibytes';\n}\n```\n\n## License\n\nMIT © 2019-2023 Andria Brown\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandria-dev%2Fpretty-bytes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandria-dev%2Fpretty-bytes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandria-dev%2Fpretty-bytes/lists"}