# lowercase-keys

> Lowercase the keys of an object

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

## Install

```sh
npm install lowercase-keys
pnpm add lowercase-keys
yarn add lowercase-keys
bun add lowercase-keys
```

## Health

**Score 60/100 (C)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2026-02-02 |
| First published | 2015-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 42 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | object, assign, extend, properties, lowercase, lower-case, case, keys, key |

## Links

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

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 4.0.1 (latest) — 2026-02-02
- 4.0.0 — 2026-02-02
- 3.0.0 — 2021-10-18
- 2.0.0 — 2019-04-30
- 1.0.1 — 2018-03-23
- 1.0.0 — 2015-01-24

## README

# lowercase-keys

> Lowercase the keys of an object

Check out [`map-obj`](https://github.com/sindresorhus/map-obj) if you need support for deep iteration.

## Install

```sh
npm install lowercase-keys
```

## Usage

```js
import lowercaseKeys from 'lowercase-keys';

lowercaseKeys({FOO: true, bAr: false});
//=> {foo: true, bar: false}
```

## API

### lowercaseKeys(object, options?)

Returns a new object with the keys lowercased.

#### options

Type: `object`

##### onConflict

Type: `Function`

A function that is called when multiple keys in the input object map to the same lowercased key.

The function receives the lowercased key, the new value, and the existing value, and should return the value to use.

By default, the last value wins.

```js
import lowercaseKeys from 'lowercase-keys';

// Throw on conflict
lowercaseKeys({Key: 'value1', key: 'value2'}, {
	onConflict({key}) {
		throw new Error(`Duplicate key: ${key}`);
	}
});

// Keep the first value
lowercaseKeys({Key: 'value1', key: 'value2'}, {
	onConflict: ({existingValue}) => existingValue,
});
//=> {key: 'value1'}
```

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