npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@toolsbee/humanize

v0.1.0

Published

Tiny modern data formatter (Bytes, Numbers, Lists, Duration).

Downloads

102

Readme

@toolsbee/humanize

Humanize

Humanize is a tiny, modern data formatter library. It provides essential utilities for humanizing data without the bloat.

It focuses on:

  • Zero Dependencies: Lightweight and tree-shakeable.
  • Modern APIs: Leverages native Intl for robust internationalization (where applicable).
  • Speed: Optimized implementations (e.g., log-based byte calculation).

Early development. API stable for v0.1.0.

Maintained by toolsbee.com · https://www.toolsbee.com


Install

npm install @toolsbee/humanize

Quick Start

import { bytes, number, list, duration, ordinal } from "@toolsbee/humanize";

bytes(1500000);
// "1.43 MB"

number(2500000);
// "2.5M"

list(["Apple", "Banana", "Cherry"]);
// "Apple, Banana, and Cherry"

duration(3661000);
// "1h 1m"

duration(60000, { ago: true });
// "1m 0s ago"

ordinal(21);
// "21st"

Core API

1. bytes(n: number, options?)

Convert bytes to a readable string with unit (B, KB, MB, GB, TB, etc.).

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | decimals | number | 2 | Number of decimal places. |

bytes(1024);                  // "1 KB"
bytes(1234, { decimals: 3 }); // "1.205 KB"
bytes(0);                     // "0 B"

2. number(n: number)

Compact number formatting using Intl.NumberFormat.

number(1500);    // "1.5K"
number(1000000); // "1M"

3. list(items: string[])

Natural list formatting using Intl.ListFormat.

list(["A", "B"]);      // "A and B"
list(["A", "B", "C"]); // "A, B, and C"

4. duration(ms: number, options?)

Convert milliseconds to a human-readable duration string.

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | ago | boolean | false | Append " ago" suffix (ignored if "just now"). |

duration(500);                  // "just now"
duration(1000 * 60);            // "1m 0s"
duration(1000 * 60 * 60 * 24);  // "1d 0h"
duration(3600000, { ago: true }); // "1h 0m ago"

5. ordinal(n: number)

Convert a number to its ordinal string representation (1st, 2nd, 3rd, etc.).

ordinal(1);  // "1st"
ordinal(2);  // "2nd"
ordinal(11); // "11th"
ordinal(21); // "21st"

Browser Usage

<!doctype html>
<html>
  <body>
    <pre id="out">Loading…</pre>

    <script type="module">
      import { bytes, number, list, duration, ordinal } from "https://cdn.jsdelivr.net/npm/@toolsbee/humanize/dist/index.js";

      document.getElementById("out").textContent = JSON.stringify(
        {
          file_size:   bytes(15728640),            // "15 MB"
          views:       number(1234567),            // "1.2M"
          authors:     list(["John", "Jane"]),     // "John and Jane"
          time_passed: duration(3600000 * 2.5),    // "2h 30m"
          ranking:     ordinal(3)                  // "3rd"
        },
        null,
        2
      );
    </script>
  </body>
</html>

Design Goals

  • Tiny: Minimal footprint, tree-shakeable.
  • Modern: Uses native Intl APIs where possible.
  • Zero-Deps: No external dependencies.
  • Strict: Built with strict TypeScript settings.

License

MIT