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

data-formatters

v0.1.3

Published

Reusable TypeScript formatters for numbers, currency, percent and text.

Readme

data-formatters

CI npm version npm downloads License

Utility library for formatting numbers, currency, percentages, dates, time, bytes, and text using modern Intl APIs. This project provides small, reusable helpers to standardize value formatting in frontend applications.


Features

  • Currency formatting
  • Compact currency formatting
  • Number formatting
  • Compact numbers
  • Percent formatting
  • Compact percent formatting
  • Date formatting
  • Date/time formatting
  • Relative time formatting
  • Duration formatting
  • Bytes formatting
  • Name normalization (Title Case)
  • Locale support (Intl)
  • Lightweight and dependency-free

Installation

npm install data-formatters

or

yarn add data-formatters

Usage

import {
  formatBytes,
  formatCurrency,
  formatDate,
  formatDateTime,
  formatDuration,
  formatCompactCurrency,
  formatNumber,
  formatCompactNumber,
  formatPercent,
  formatCompactPercent,
  formatName,
  formatRelativeTime
} from "data-formatters"

Currency

formatCurrency(1200, {
  currency: "USD",
  locale: "en-US"
})

Result:

$1,200.00

Compact Currency

formatCompactCurrency(1200000, {
  currency: "USD",
  locale: "en-US"
})

Result:

$1.2M

Numbers

formatNumber(1200, { locale: "en-US" })

Result:

1,200

Compact Numbers

formatCompactNumber(1500, { locale: "en-US" })

Result:

1.5K

Percent

formatPercent(0.25, { locale: "en-US" })

Result:

25%

Compact Percent

formatCompactPercent(0.1234, { locale: "en-US" })

Result:

12.3%

Name Formatting

formatName("victor hugo lima")

Result:

Victor Hugo Lima

Bytes

formatBytes(1536)

Result:

1.5 KB

Date

formatDate("2026-03-09T00:00:00Z", {
  locale: "en-US",
  timeZone: "UTC"
})

Result:

03/09/2026

DateTime

formatDateTime("2026-03-09T14:30:00Z", {
  locale: "en-US",
  timeZone: "UTC",
  dateStyle: "medium",
  timeStyle: "short"
})

Result:

Mar 9, 2026, 2:30 PM

Duration

formatDuration(3665)

Result:

1h 1m 5s

Relative Time

formatRelativeTime(-1, "day", "en-US")

Result:

yesterday

Locale Support

The library uses the native Intl API, so formatting behavior depends on the provided locale. Examples: | Locale | Number Example | | ------- | -------------- | | en-US | 1,000 | | pt-BR | 1.000 | | de-DE | 1.000 |


Testing

Tests are written using Vitest. Run locally:

npm test

Run in watch mode:

npm run test:watch

Development

Clone the repository:

git clone https://github.com/vhlima1008/data-formatters.git

Install dependencies:

npm install

Build:

npm run build

Contributing

Contributions are welcome! Steps:

  1. Fork the repository
  2. Create a branch
git checkout -b feature/my-feature
  1. Commit your changes
  2. Push the branch
  3. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.


Author

Victor Hugo Lima Monteiro GitHub: https://github.com/vhlima1008