# ms

> Tiny millisecond conversion utility

Latest version **2.1.3** (published 2020-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install ms
pnpm add ms
yarn add ms
bun add ms
```

## Health

**Score 33/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.1.3 |
| Published | 2020-12-08 |
| First published | 2011-12-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/ms) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5553 |
| Maintainers | elsigh, leerobinson, hankvercel, okbel, samsisle, cleishm, nazarenooviedo, chibicode, gielcobben, jaredpalmer, jkrems, prateekbh, kikobeats, gmonaco, housseindjirdeh, developit, spanicker, keanulee, atcastle, janicklas-ralph, skllcrn, paco, guybedford, ragojose, williamli, msweeneydev, coetry, rabaut, lfades, mfix22, ijjk, arzafran, umegaya, timer, anatrajkovska, paulogdm, andybitz, mglagola, lucleray, zeit-bot, styfle, juancampa, dav-is, quietshu, joecohens, codetheory, matheuss, igorklopov, leo, nkzawa, tootallnate, rauchg, timneutkens, javivelasco, iamevilrabbit |

## Links

- npm: https://www.npmjs.com/package/ms
- Repository: https://github.com/vercel/ms
- Homepage: https://github.com/vercel/ms#readme
- Issues: https://github.com/vercel/ms/issues
- npm.io page: https://npm.io/package/ms

## Recent versions

- 2.1.3 (latest) — 2020-12-08
- 4.0.0-nightly.202508271359 (nightly) — 2025-08-27
- 3.0.0-canary.202508261828 (canary) — 2025-08-26
- 3.0.0-beta.2 (beta) — 2021-08-25
- 4.0.0-nightly.202508271358 — 2025-08-27
- 4.0.0-nightly.202508270145 — 2025-08-27
- 3.0.0-canary.202508261745 — 2025-08-26
- 3.0.0-canary.202508261539 — 2025-08-26
- 3.0.0-canary.202508252038 — 2025-08-25
- 3.0.0-canary.202508252028 — 2025-08-25
- 3.0.0-canary.1 — 2021-09-15
- 3.0.0-canary.0 — 2021-09-15
- 3.0.0-beta.1 — 2021-08-20
- 3.0.0-beta.0 — 2021-08-20
- 2.1.2 — 2019-06-06
- … 17 more at https://npm.io/package/ms/versions

## README

# ms

![CI](https://github.com/vercel/ms/workflows/CI/badge.svg)

Use this package to easily convert various time formats to milliseconds.

## Examples

```js
ms('2 days')  // 172800000
ms('1d')      // 86400000
ms('10h')     // 36000000
ms('2.5 hrs') // 9000000
ms('2h')      // 7200000
ms('1m')      // 60000
ms('5s')      // 5000
ms('1y')      // 31557600000
ms('100')     // 100
ms('-3 days') // -259200000
ms('-1h')     // -3600000
ms('-200')    // -200
```

### Convert from Milliseconds

```js
ms(60000)             // "1m"
ms(2 * 60000)         // "2m"
ms(-3 * 60000)        // "-3m"
ms(ms('10 hours'))    // "10h"
```

### Time Format Written-Out

```js
ms(60000, { long: true })             // "1 minute"
ms(2 * 60000, { long: true })         // "2 minutes"
ms(-3 * 60000, { long: true })        // "-3 minutes"
ms(ms('10 hours'), { long: true })    // "10 hours"
```

## Features

- Works both in [Node.js](https://nodejs.org) and in the browser
- If a number is supplied to `ms`, a string with a unit is returned
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned

## Related Packages

- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.

## Caught a Bug?

1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
2. Link the package to the global module directory: `npm link`
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!

As always, you can run the tests using: `npm test`

---
_Source: https://npm.io/package/ms · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
