A tiny utility to convert human-readable time strings to milliseconds and vice versa.
ms is a JavaScript utility library that converts human-readable time expressions to milliseconds and milliseconds back to readable time strings. It solves the problem of consistently parsing and formatting time durations across different JavaScript environments with a simple, robust API.
JavaScript/TypeScript developers who need to handle time durations in applications, particularly those working with timers, scheduling, logging, or any feature requiring time interval calculations.
Developers choose ms for its tiny size, zero dependencies, comprehensive TypeScript support, and wide runtime compatibility—it works everywhere from browsers to Edge Runtime with consistent behavior.
Tiny millisecond conversion utility
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works seamlessly across Node.js, Deno, Bun, browsers, and Edge Runtime, as evidenced by the compatibility badges and examples in the README.
Includes template literal types for compile-time validation of time strings, reducing runtime errors in TypeScript projects, with detailed examples in the TypeScript support section.
Supports a wide variety of unit formats, abbreviations, and casings, allowing lenient parsing of user inputs, as shown in the input formats list.
With zero dependencies and a focused API, it adds negligible overhead while providing essential duration conversion functionality, aligning with its philosophy of being lightweight.
Limited to duration parsing and formatting; cannot handle full dates, time zones, or calendar operations, which restricts its use in date-heavy applications.
Does not support locale-specific formatting or multiple languages, making it unsuitable for global apps without additional i18n libraries.
The TypeScript implementation requires careful use of type assertions, which can lead to bugs if misused, as highlighted in the advanced usage section with warnings about dangerous coercion.