> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# mapKeys es-toolkit

Returns a new object with keys transformed through a function.

```typescript
const newObj = mapKeys(object, getNewKey);
```

## Usage

### `mapKeys(object, getNewKey)`

Use `mapKeys` when you want to create a new object by transforming each key. Values remain the same, and only the keys are changed to the results of the `getNewKey` function.

```typescript
import { mapKeys } from 'es-toolkit/object';

// Add prefix to keys
const obj = { a: 1, b: 2 };
const prefixed = mapKeys(obj, (value, key) => `prefix_${key}`);
// prefixed becomes { prefix_a: 1, prefix_b: 2 }

// Combine key and value to create new keys
const combined = mapKeys(obj, (value, key) => `${key}${value}`);
// combined becomes { a1: 1, b2: 2 }

// Convert keys to uppercase
const uppercased = mapKeys(obj, (value, key) => key.toString().toUpperCase());
// uppercased becomes { A: 1, B: 2 }
```

#### Parameters


objectT extends Record<PropertyKey, any>required

The object to transform keys from.


getNewKey(value: T[keyof T], key: keyof T, object: T) => Krequired

A function that generates new keys. Receives value, key, and the entire object as parameters.

#### Returns

Returns a new object with transformed keys.

```typescript
Record<K, T[keyof T]>
```


Source: es-toolkit

Re-exported verbatim from [`es-toolkit`](https://es-toolkit.dev/reference/object/mapKeys.html). Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.
