Skip to content


RedisJSON - a JSON data type for Redis

Forum Discord

RedisJSON is a Redis module that implements ECMA-404 The JSON Data Interchange Standard as a native data type. It allows storing, updating and fetching JSON values from Redis keys (documents).

Primary features:

  • Full support of the JSON standard
  • JSONPath -like syntax for selecting elements inside documents
  • Documents are stored as binary data in a tree structure, allowing fast access to sub-elements
  • Typed atomic operations for all JSON values types

RedisJSON is developed with <3 at Redis . The source code is available at:


  1. Create a free database in Redis Cloud
  2. Launch RedisJSON with Docker
  3. Use it from any Redis client , e.g.:

RedisJSON with redis-cli

Alternatively, you can also build and load the module yourself. Build and Load the RedisJSON module library

Redis Cloud

RedisJSON is available on all Redis Cloud managed services, including a completely free tier up to 30MB!

Get started here

Launch RedisJSON with Docker

Run the following on Windows, MacOS or Linux with Docker.

docker run -p 6379:6379 --name redis-redisjson redislabs/rejson:latest

Using RedisJSON

Before using RedisJSON, you should familiarize yourself with its commands and syntax as detailed in the commands reference document. However, to quickly get started just review this section and get:

  1. A Redis server running the module (see building and loading for instructions)
  2. Any Redis or RedisJSON client

With redis-cli

This example will use redis-cli as the Redis client. The first RedisJSON command to try out is JSON.SET , which sets a Redis key with a JSON value. All JSON values can be used, for example a string:> JSON.SET foo . '"bar"'
"\"bar\""> JSON.TYPE foo .

JSON.GET and JSON.TYPE do literally that regardless of the value's type, but you should really check out JSON.GET prettifying powers. Note how the commands are given the period character, i.e. . . This is the path to the value in the RedisJSON data type (in this case it just means the root). A couple more string operations:> JSON.STRLEN foo .
3> JSON.STRAPPEND foo . '"baz"'
6> JSON.GET foo

JSON.STRLEN tells you the length of the string, and you can append another string to it with JSON.STRAPPEND . Numbers can be incremented and multiplied :> JSON.SET num . 0
"1"> JSON.NUMINCRBY num . 1.5
"2.5"> JSON.NUMINCRBY num . -0.75
"1.75"> JSON.NUMMULTBY num . 24

Of course, a more interesting example would involve an array or maybe an object:> JSON.SET amoreinterestingexample . '[ true, { "answer": 42 }, null ]'
OK> JSON.GET amoreinterestingexample
"[true,{\"answer\":42},null]"> JSON.GET amoreinterestingexample [1].answer
"42"> JSON.DEL amoreinterestingexample [-1]
1> JSON.GET amoreinterestingexample

The handy JSON.DEL command deletes anything you tell it to. Arrays can be manipulated with a dedicated subset of RedisJSON commands:> JSON.SET arr . []
(integer) 1> JSON.GET arr
"[0]"> JSON.ARRINSERT arr . 0 -2 -1
(integer) 3> JSON.GET arr
"[-2,-1,0]"> JSON.ARRTRIM arr . 1 1
1> JSON.GET arr
"[-1]"> JSON.ARRPOP arr
"-1"> JSON.ARRPOP arr

And objects have their own commands too:> JSON.SET obj . '{"name":"Leonard Cohen","lastSeen":1478476800,"loggedOut": true}'
(integer) 3> JSON.OBJKEYS obj .
1) "name"
2) "lastSeen"
3) "loggedOut"

With any other client

Unless your Redis client already supports Redis modules (unlikely) or RedisJSON specifically (even more unlikely), you should be okay using its ability to send raw Redis commands. Depending on your client of choice, the exact method for doing that may vary.

Python example

This code snippet shows how to use RedisJSON with raw Redis commands from Python with redis-py :

import redis
import json

data = {
    'foo': 'bar'

r = redis.StrictRedis()
r.execute_command('JSON.SET', 'doc', '.', json.dumps(data))
reply = json.loads(r.execute_command('JSON.GET', 'doc'))

Download and running binaries

First download the pre-compiled version from Redis download center .

Next, run Redis with RedisJSON:

$ redis-server --loadmodule /path/to/module/

Building and Loading the Module

cargo build --release

Building on Ubuntu 20.04

The following packages are required to successfully build on Ubuntu 20.04:

sudo apt install build-essential llvm cmake libclang1 libclang-dev cargo

Then, run make or cargo build --release in the repository directory

Loading the module to Redis


We recommend you have Redis load the module during startup by adding the following to your redis.conf file:

loadmodule /path/to/module/target/release/

On Mac OS, if this module has been built as a dynamic library use:

loadmodule /path/to/module/target/release/librejson.dylib

In the above lines replace /path/to/module/ with the actual path to the module's library.

Alternatively, you can have Redis load the module using the following command line argument syntax:

~/$ redis-server --loadmodule ./target/release/

Lastly, you can also use the MODULE LOAD command. Note, however, that MODULE LOAD is a dangerous command and may be blocked/deprecated in the future due to security considerations.

Once the module has been loaded successfully, the Redis log should have lines similar to:


1877:M 23 Dec 02:02:59.725 # <RedisJSON> JSON data type for Redis - v1.0.0 [encver 0]
1877:M 23 Dec 02:02:59.725 * Module 'RedisJSON' loaded from <redacted>/src/

Client libraries

Some languages have client libraries that provide support for RedisJSON's commands:

Project Language License Author Stars Package
iorejson Node.js MIT Evan Huang @evanhuang8 iorejson-stars npm
node_redis-rejson Node.js MIT Kyle Davis @stockholmux node_redis-rejson-stars npm
redis-modules-sdk Node.js BSD-3-Clause Dani Tseitlin @danitseitlin redis-modules-sdk-stars npm
JRedisJSON Java BSD-2-Clause Redis JRedisJSON-stars maven
redis-modules-java Java Apache-2.0 Liming Deng @dengliming redis-modules-java-stars maven
redisjson-py Python BSD-2-Clause Redis rejson-py-stars pypi
go-rejson Go MIT Nitish Malhotra @nitishm go-rejson-stars
rejonson Go Apache-2.0 Daniel Krom @KromDaniel rejonson-stars
NReJSON .NET MIT/Apache-2.0 Tommy Hanks @tombatron NReJSON-stars nuget
phpredis-json PHP MIT Rafa Campoy @averias phpredis-json-stars composer
redislabs-rejson PHP MIT Mehmet Korkmaz @mkorkmaz redislabs-rejson-stars composer
rejson-rb Ruby MIT Pavan Vachhani @vachhanihpavan rejson-rb-stars rubygems