# os-locale

> Get the system locale

Latest version **8.0.0** (published 2026-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install os-locale
pnpm add os-locale
yarn add os-locale
bun add os-locale
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 8.0.0 |
| Published | 2026-02-04 |
| First published | 2015-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 230 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | locale, language, system, os, string, user, country, id, identifier, region |

## Links

- npm: https://www.npmjs.com/package/os-locale
- Repository: https://github.com/sindresorhus/os-locale
- Homepage: https://github.com/sindresorhus/os-locale#readme
- Issues: https://github.com/sindresorhus/os-locale/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/os-locale

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 8.0.0 (latest) — 2026-02-04
- 6.0.2 — 2021-12-23
- 6.0.1 — 2021-10-07
- 6.0.0 — 2021-07-29
- 5.0.0 — 2020-03-22
- 4.0.0 — 2019-06-11
- 3.1.0 — 2018-12-26
- 3.0.1 — 2018-08-31
- 3.0.0 — 2018-08-06
- 2.1.0 — 2017-07-21
- 2.0.0 — 2016-11-16
- 1.4.0 — 2015-09-08
- 1.3.1 — 2015-09-03
- 1.3.0 — 2015-09-03
- 1.2.1 — 2015-08-28
- … 4 more at https://npm.io/package/os-locale/versions

## README

# os-locale

> Get the system [locale](https://en.wikipedia.org/wiki/Locale_(computer_software))

> [!NOTE]
> You may want [`new Intl.DateTimeFormat().resolvedOptions().locale`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions) instead. This package is useful for CLI tools as it also reads locale from environment variables (`LC_ALL`, `LC_MESSAGES`, `LANG`, `LANGUAGE`), which the Intl API does not fully support (it only respects `LC_ALL`).

Useful for localizing your module or app.

POSIX systems: The returned locale refers to the [`LC_MESSAGES`](http://www.gnu.org/software/libc/manual/html_node/Locale-Categories.html#Locale-Categories) category, suitable for selecting the language used in the user interface for message translation.

## Install

```sh
npm install os-locale
```

## Usage

```js
import osLocale from 'os-locale';

console.log(osLocale());
//=> 'en-US'
```

## API

### osLocale()

Returns the locale.

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