# @redis/json

> This package provides support for the [RedisJSON](https://redis.io/docs/latest/develop/data-types/json/) module, which adds JSON as a native data type to Redis.

Latest version **6.3.0** (published 2026-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @redis/json
pnpm add @redis/json
yarn add @redis/json
bun add @redis/json
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score; popular repo.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 6.3.0 |
| Published | 2026-09-30 |
| First published | 2022-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 20.0.0 |
| Dependencies | 0 |
| Unpacked size | 157.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 17587 |
| Maintainers | dmaier-redislabs, nkaradzhov |
| Keywords | redis, RedisJSON |

## Links

- npm: https://www.npmjs.com/package/@redis/json
- Repository: https://github.com/redis/node-redis
- Homepage: https://github.com/redis/node-redis/tree/master/packages/json
- Issues: https://github.com/redis/node-redis/issues
- npm.io page: https://npm.io/package/@redis/json

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 6.3.0 (latest) — 2026-09-30
- 6.2.0-beta.0 (beta) — 2026-07-29
- 5.0.0-next.7 (next) — 2025-03-25
- 6.2.1 — 2026-08-11
- 6.2.0 — 2026-07-31
- 6.1.0 — 2026-07-01
- 6.0.1 — 2026-06-24
- 6.0.0 — 2026-05-28
- 5.12.1 — 2026-04-14
- 5.12.0 — 2026-04-14
- 5.11.0 — 2026-02-16
- 5.10.0 — 2025-11-19
- 5.9.0 — 2025-10-23
- 5.9.0-beta.3 — 2025-10-21
- 5.8.3 — 2025-10-02
- … 24 more at https://npm.io/package/@redis/json/versions

## README

# @redis/json

This package provides support for the [RedisJSON](https://redis.io/docs/latest/develop/data-types/json/) module, which adds JSON as a native data type to Redis.

Should be used with [`redis`/`@redis/client`](https://github.com/redis/node-redis).

:warning: To use these extra commands, your Redis server must have the RedisJSON module installed.

## Usage

For a complete example, see [`managing-json.js`](https://github.com/redis/node-redis/blob/master/examples/managing-json.js) in the [examples folder](https://github.com/redis/node-redis/tree/master/examples).

### Storing JSON Documents in Redis

The [`JSON.SET`](https://redis.io/commands/json.set/) command stores a JSON value at a given JSON Path in a Redis key.

Here, we'll store a JSON document in the root of the Redis key "`mydoc`":

```javascript
await client.json.set('noderedis:jsondata', '$', {
  name: 'Roberta McDonald',
  pets: [{
    name: 'Rex',
    species: 'dog',
    age: 3,
    isMammal: true
  }, {
    name: 'Goldie',
    species: 'fish',
    age: 2,
    isMammal: false
  }]
});
```

For more information about RedisJSON's path syntax, [check out the documentation](https://redis.io/docs/latest/develop/data-types/json/path).

### Retrieving JSON Documents from Redis

With RedisJSON, we can retrieve all or part(s) of a JSON document using the [`JSON.GET`](https://redis.io/commands/json.get/) command and one or more JSON Paths. Let's get the name and age of one of the pets:

```javascript
const results = await client.json.get('noderedis:jsondata', {
  path: [
    '.pets[1].name',
    '.pets[1].age'
  ]
});
```

`results` will contain the following:

```javascript
 { '.pets[1].name': 'Goldie', '.pets[1].age': 2 }
```

### Performing Atomic Updates on JSON Documents Stored in Redis

RedisJSON includes commands that can atomically update values in a JSON document, in place in Redis without having to first retrieve the entire document.

Using the [`JSON.NUMINCRBY`](https://redis.io/commands/json.numincrby/) command, we can update the age of one of the pets like this:

```javascript
await client.json.numIncrBy('noderedis:jsondata', '.pets[1].age', 1);
```

And we can add a new object to the pets array with the [`JSON.ARRAPPEND`](https://redis.io/commands/json.arrappend/) command:

```javascript
await client.json.arrAppend('noderedis:jsondata', '.pets', {
  name: 'Robin',
  species: 'bird',
  age: 1,
  isMammal: false
});
```

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