# keyd

> A small library for using and manipulating key path in JavaScript.

Latest version **2.1.84** (published 2026-10-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.1.84 |
| Published | 2026-10-05 |
| First published | 2017-03-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kristian Trenskow |
| Maintainers | trenskow |
| Keywords | key, path, keypath, object, get, set, manipulate, edit |

## Links

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

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 2.1.84 (latest) — 2026-10-05
- 2.1.83 — 2026-10-05
- 2.1.82 — 2026-09-21
- 2.1.81 — 2026-09-21
- 2.1.80 — 2026-09-18
- 2.1.79 — 2026-09-18
- 2.1.78 — 2026-09-16
- 2.1.77 — 2026-09-16
- 2.1.76 — 2026-09-16
- 2.1.75 — 2026-09-16
- 2.1.74 — 2026-08-03
- 2.1.73 — 2026-08-03
- 2.1.72 — 2026-07-27
- 2.1.71 — 2026-07-27
- 2.1.70 — 2026-07-13
- … 127 more at https://npm.io/package/keyd/versions

## README

keyd
----

A small library for using and manipulating key paths in JavaScript.

# Installation

````bash
npm install --save keyd
````

````javascript
const keyd = require('keyd');
````
    
# Getting / Setting Values

## Getting Values

````javascript
keyd(obj).get('my.keypath');
````

### Getting values in array and sub-arrays.

````javascript
keyd(obj).get.all('my.keypath');
````

## Setting Values

````javascript
keyd(obj).set('my.keypath', value);
````

# Manipulating Key Paths

## Components

````javascript
const components = keyd.components('my.key.path');
/* -> ['my','key','path'] */
````

> Throws an error if input is not a string.

## Joining

````javascript
const keyPath = keyd.join(['my','key','path']);
/* -> 'my.key.path' */
````

> Throws an error if input is not an array.

## Appending Keys

````javascript
const keyPath = keyd.append('my.key', 'path');
/* -> 'my.key.path' */
````

or

````javascript
const keyPath = keyd.append('my', ['key', 'path']);
/* -> 'my.key.path' */
````

> Both inputs can be either strings or arrays.

## Last

### Getting

````javascript
const lastComponent = keyd.last('my.key.path');
/* -> 'path' */
````

> Input can be a string or an array.

### Removing

````javascript
const keyPath = keyd.eatLast('my.key.path');
/* -> 'my.key' */
````

> Input can be a string or an array.

## First

### Getting

````javascript
const firstComponent = keyd.first('my.key.path');
/* -> 'my' */
````

> Input can be a string or an array.

### Removing

````javascript
const keyPath = keyd.eatFirst('my.key.path');
/* -> 'key.path' */
````

or

````javascript
const keyPath = keyd.eatFirst('my.key.path', 'my.key');
/* -> 'path' */
````

> Input can be a string or an array.

> Latter example with throw an error if second key path is not within the first.

## Match

````javascript
const within = keyd.within('my.key.path', 'my.key');
/* -> true */
````

````javascript
const is = keyd.is('my.key.path', 'my.key');
/* -> false */
````

> Both inputs can be either strings or arrays.

# Options

All methods supports options, which is provided as an object as the last parameter.

The table below shows the supported key(s).

| Name | Default value | Description | 
|:-----|:--------------|:------------|
| `separator` | `.` | A string that represents the separation characters of keys in a key path string.

# License

MIT (see LICENSE).

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