ms is a tiny millisecond conversion utility that converts between various time formats and milliseconds.
The tool solves the problem of handling time unit conversions in JavaScript applications. It accepts multiple input formats—numbers with optional units like minutes, hours, days, or written-out time strings—and converts them to milliseconds or vice versa. The conversion logic handles flexible input including case-insensitive units, optional spacing, and fractional values. When given a number, it returns a formatted string with a unit; when given a string with a unit, it returns the numeric millisecond equivalent.
The tool suits any JavaScript project needing straightforward time conversions without external dependencies. It works in browsers and server runtimes including Node.js, Deno, and Bun, and is compatible with Edge Runtime environments like Vercel Edge Functions. TypeScript users benefit from Template Literal Types that enforce correct input formats at compile time, with an optional strict parsing mode for additional safety. The package includes separate `parse` and `format` functions for modular usage.
Development activity shows consistent maintenance with automated testing through CI workflows. The project maintains compatibility across multiple JavaScript runtimes and package managers, and includes TypeScript definitions as a core feature rather than an afterthought.