# @hyperjump/json-pointer

> An RFC-6901 JSON Pointer implementation

Latest version **1.1.2** (published 2026-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hyperjump/json-pointer
pnpm add @hyperjump/json-pointer
yarn add @hyperjump/json-pointer
bun add @hyperjump/json-pointer
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2026-03-05 |
| First published | 2018-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Jason Desrosiers |
| Maintainers | jason.desrosiers |
| Keywords | JSON Pointer, RFC-6901 |

## Links

- npm: https://www.npmjs.com/package/@hyperjump/json-pointer
- Repository: https://github.com/hyperjump-io/json-pointer
- Homepage: https://github.com/hyperjump-io/json-pointer#readme
- Issues: https://github.com/hyperjump-io/json-pointer/issues
- Funding: https://github.com/sponsors/jdesrosiers
- npm.io page: https://npm.io/package/@hyperjump/json-pointer

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.2 (latest) — 2026-03-05
- 1.1.1 — 2025-04-22
- 1.1.0 — 2024-04-24
- 1.0.1 — 2023-01-22
- 1.0.0 — 2023-01-22
- 0.9.8 — 2023-01-22
- 0.9.7 — 2022-12-03
- 0.9.6 — 2022-08-12
- 0.9.5 — 2022-08-11
- 0.9.4 — 2022-04-30
- 0.9.3 — 2022-04-30
- 0.9.2 — 2022-01-23
- 0.9.1 — 2021-09-02
- 0.9.0 — 2021-09-02
- 0.8.0 — 2020-04-09
- … 12 more at https://npm.io/package/@hyperjump/json-pointer/versions

## README

# JSON Pointer

This is an implementation of RFC-6901 JSON Pointer. JSON Pointer is designed for
referring to data values within a JSON document. It's designed to be URL
friendly so it can be used as a URL fragment that points to a specific part of
the JSON document.

## Installation

Includes support for node.js (ES Modules, TypeScript) and browsers.

```bash
npm install @hyperjump/json-pointer
```

## Usage

```javascript
import * as JsonPointer from "@hyperjump/json-pointer";

const value = {
  "foo": {
    "bar": 42
  }
};

// Construct pointers
const fooPointer = JsonPointer.append("foo", JsonPointer.nil); // "/foo"
const fooBarPointer = JsonPointer.append(fooPointer, "bar"); // "/foo/bar"

// Get a value from a pointer
const getFooBar = JsonPointer.get(fooBarPointer);
getFooBar(value); // 42

// Set a value from a pointer
// New value is returned without modifying the original
const setFooBar = JsonPointer.set(fooBarPointer);
setFooBar(value, 33); // { "foo": { "bar": 33 } }

// Assign a value from a pointer
// The original value is changed and no value is returned
const assignFooBar = JsonPointer.assign(fooBarPointer);
assignFooBar(value, 33); // { "foo": { "bar": 33 } }

// Unset a value from a pointer
// New value is returned without modifying the original
const unsetFooBar = JsonPointer.unset(fooBarPointer);
setFooBar(value); // { "foo": {} }

// Delete a value from a pointer
// The original value is changed and no value is returned
const deleteFooBar = JsonPointer.remove(fooBarPointer);
deleteFooBar(value); // { "foo": {} }
```

## API

* **nil**: ""

    The empty pointer.
* **pointerSegments**: (pointer: string) => Generator\<string>

    An iterator for the segments of a JSON Pointer that handles escaping.
* **append**: (segment: string, pointer: string) => string

    Append a segment to a JSON Pointer.
* **get**: (pointer: string, subject: any) => any

    Use a JSON Pointer to get a value. This function can be curried.
* **set**: (pointer: string, subject: any, value: any) => any

    Immutably set a value using a JSON Pointer. Returns a new version of
    `subject` with the value set. The original `subject` is not changed, but the
    value isn't entirely cloned. Values that aren't changed will point to
    the same value as the original. This function can be curried.
* **assign**: (pointer: string, subject: any, value: any) => void

    Mutate a value using a JSON Pointer. This function can be curried.
* **unset**: (pointer: string, subject: any) => any

    Immutably delete a value using a JSON Pointer. Returns a new version of
    `subject` without the value. The original `subject` is not changed, but the
    value isn't entirely cloned. Values that aren't changed will point to the
    same value as the original. This function can be curried.
* **remove**: (pointer: string, subject: any) => void

    Delete a value using a JSON Pointer. This function can be curried.

## Contributing

### Tests

Run the tests

```bash
npm test
```

Run the tests with a continuous test runner
```bash
npm test -- --watch
```

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