sindresorhus

sindresorhus/pretty-ms

JavaScript MIT Dev Tools

Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`

1.2k stars
66 forks
active
GitHub

1.2k

Stars

66

Forks

0

Open issues

21

Contributors

v9.3.0 15 Sep 2025

AI Analysis

pretty-ms converts milliseconds to human-readable duration strings (e.g., `1337000000` → `15d 11h 23m 20s`). It is a specialized utility library best suited for developers building tools, applications, or CLIs that need to display elapsed time, durations, or performance metrics to users. General-purpose web developers and DevOps teams building duration-aware applications benefit most; it is not intended for date manipulation or timezone handling.

Dev Tools Library Discovery value: 3/10
Documentation 9/10
Activity 10/10
Community 8/10
Code quality 5/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

time-formatting duration-humanization utility-library javascript-npm developer-tool
Actively maintained Well documented MIT licensed Niche/specialized use case Beginner friendly Production ready
Deep Analysis · Based on README and public signals
3d ago

Stable utility for formatting milliseconds into human-readable durations; widely integrated into Node.js workflows.

pretty-ms is a focused JavaScript utility that converts millisecond values into readable time strings (e.g., `1337000000` → `15d 11h 23m 20s`). Built by Sindre Sorhus in 2014, it has become a de facto standard in Node.js for displaying operation durations, test timings, and performance metrics. The library offers multiple output formats via options (compact, verbose, colon notation) and handles edge cases like sub-millisecond precision. Adoption appears embedded across CI/CD tooling, testing frameworks, and monitoring systems rather than highly visible; the modest star count (~1,200) belies practical ubiquity.

Origin

Created in 2014 as part of Sindre Sorhus's broader ecosystem of utility libraries. The project emerged from a straightforward need: displaying elapsed time in a user-friendly way. It has remained focused on that single problem across 12+ years, accumulating incremental refinements (BigInt support, additional formatting options) without feature bloat.

Growth

Growth has been gradual and plateaued. The project gained adoption early in the Node.js era when standardized utilities for this task were sparse. Recent activity (last push 2026-07-06) shows ongoing maintenance rather than expansion; zero stars gained in the last 7 days suggests the library has reached a stable equilibrium where it meets its target use case without requiring viral adoption. Growth was likely driven by inclusion in popular frameworks and CLI tools rather than direct user discovery.

In production

Adoption not verified through explicit case studies or published testimonials in README. However, the library's position in Sindre Sorhus's ecosystem, companion tools listed (pretty-ms-cli, parse-ms, parse-duration-ms, to-milliseconds), and the existence of a CLI wrapper suggest real-world integration. The 1,200 stars and 66 forks likely underrepresent actual usage—utility libraries are often included as transitive dependencies and rarely starred by end users. Likely embedded in popular test runners, build tools, and CLI frameworks where timing output is needed.

Code analysis
Architecture

Based on README, the library appears to be a single-purpose formatter with a straightforward API: accepts milliseconds (number or BigInt) and returns a string. The options object suggests a modular approach to formatting logic (separate handlers for compact, verbose, colon notation, sub-millisecond precision). Likely implemented as a series of formatting rules applied conditionally based on options. No evidence of complex state management or external dependencies mentioned.

Tests

Not documented in README. No mention of test suite, CI/CD pipeline, or coverage thresholds. This is a gap in transparency, though the long maintenance history and stable API suggest internal testing practices exist.

Maintenance

Last push 2026-07-06 (1 day before analysis date) indicates active, hands-on maintenance. The project is 12+ years old with regular incremental updates rather than abandonment or major rewrites. Maintenance appears reactive (fixing bugs, adding requested options) rather than proactive roadmap-driven development. This is consistent with a mature utility that has reached its design goals.

Honest verdict

ADOPT IF: you need a lightweight, zero-dependency formatter for millisecond durations in Node.js or browser environments, especially in CLI tools, test output, or monitoring dashboards. The stable API and active maintenance make it low-risk. AVOID IF: you require natural language output (e.g., 'roughly 2 hours'), calendar-aware formatting, or timezone handling—use date-fns or moment.js instead. Or if you need to parse duration strings back into milliseconds (use parse-duration-ms for that). MONITOR IF: you rely on this library as a critical dependency and Sindre Sorhus's maintenance practices change; the project is healthy now but tied to one maintainer's availability.

Independent dimensions

Mainstream potential

3/10

Technical importance

6/10

Adoption evidence

5/10

Risks
  • Single maintainer (Sindre Sorhus). If maintainability lapses, no clear succession path. However, the library is mature and relatively change-resistant, reducing this risk.
  • Zero-dependency design is a strength but also means no shared security infrastructure; vulnerabilities (if they ever appeared) would require direct fixes.
  • Limited test coverage transparency. README does not document testing practices, making it harder to assess regression risk across Node.js versions or edge cases.
  • Package is so narrow that any significant API change would likely break consumer code. Lock-in is minimal but backward compatibility is de facto required.
  • Rounding behavior (documented in FAQ) may surprise users expecting exact sums when combining multiple formatted values. This is a design choice, not a bug, but it's a foot-gun if misunderstood.
Prediction

pretty-ms will remain a stable, slowly-maintained utility. Expect incremental additions (new formatting options if requested, continued BigInt/JavaScript standard support) but no major pivots. Adoption will remain embedded rather than trending. The library will likely outlive most competing formatting utilities because it does one thing well and Sindre Sorhus maintains his ecosystem conservatively.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

JavaScript
96.2%
TypeScript
3.8%

Information

Language
JavaScript
License
MIT
Last updated
4d ago
Created
150mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Open issues

No open issues — clean slate.

Open pull requests

No open pull requests.

Similar repos

EvanHahn

EvanHahn/HumanizeDuration.js

Humanize Duration converts millisecond values into human-readable time strings...

1.7k JavaScript Dev Tools
vercel

vercel/ms

ms is a lightweight TypeScript utility for converting between various time...

5.5k TypeScript Dev Tools
sindresorhus

sindresorhus/query-string

query-string is a mature, well-adopted npm package for parsing and stringifying...

6.9k JavaScript Web Dev
bradymholt

bradymholt/cRonstrue

cRonstrue is a JavaScript library that translates cron expressions into...

1.6k TypeScript Dev Tools
vs. alternatives
date-fns

date-fns solves calendar and timezone problems; pretty-ms solves duration formatting. Non-overlapping domains. date-fns is larger and broader; pretty-ms is minimal and focused.

dayjs

dayjs is a date manipulation library; pretty-ms is a formatting utility for elapsed time. Different use cases. dayjs requires more setup for simple duration display.

moment.js (duration)

moment.js.duration() provides similar functionality but as part of a monolithic date library. pretty-ms is smaller, zero-dependency, and faster for this single task.

humanize-duration (npm)

Directly comparable. humanize-duration offers similar features. pretty-ms is smaller; humanize-duration is more configurable for natural language (e.g., 'about 2 hours'). Market share appears split by preference for minimalism vs. configurability.

Hand-rolled formatting

Many projects write custom duration formatters. pretty-ms eliminates this busywork and handles edge cases (BigInt, sub-ms precision, rounding quirks) consistently.