JSON to Redis Commands Converter

Convert JSON data to Redis CLI commands — SET, HSET, RPUSH, ZADD — with smart type detection and key prefix support.

Key prefix:
Format:

What is JSON to Redis Commands Converter?

Redis is an in-memory data structure store that supports strings, hashes, lists, sets, sorted sets, and more. Unlike document databases, Redis does not store JSON natively — each piece of data must be mapped to a specific Redis data type and accessed through dedicated commands. This converter bridges that gap by analyzing your JSON structure and generating the appropriate Redis CLI commands automatically. Primitive values like strings and numbers become SET key-value pairs, flat objects with primitive fields are stored as HSET hashes, arrays of primitives map to RPUSH lists, and objects whose values are all numeric are recognized as leaderboards or rankings and converted to ZADD sorted sets. Nested JSON is flattened into colon-delimited key hierarchies that follow Redis key naming conventions, making the output ready to paste directly into redis-cli or use in application code.

How to Use

  1. Paste a JSON object, array, or nested structure into the input panel on the left
  2. Optionally type a key prefix (such as "myapp" or "prod") to namespace every generated Redis key
  3. Pick your output format — Redis CLI for individual commands, or Pipeline to wrap everything in PIPELINE/EXEC for batch execution
  4. Click "Generate Redis Commands" and review the output on the right
  5. Copy the commands and run them in redis-cli, embed them in a migration script, or pipe them through redis-cli --pipe for bulk loading

Why Use This Tool?

Intelligent type detection chooses the most efficient Redis command for each data shape — HSET for flat objects, ZADD for numeric maps, RPUSH for lists
Nested JSON is automatically flattened into colon-separated key patterns that match Redis best practices for key hierarchy
Key prefix support lets you isolate data by environment or application without manually editing every command
Pipeline format batches all commands into a single round trip, reducing network latency when loading large datasets
Special characters in values — spaces, quotes, and backslashes — are properly escaped so commands execute without syntax errors
Boolean values are converted to 1/0 integers, which is the standard Redis convention for representing truth values

Tips & Best Practices

  • Design your JSON keys with colons (e.g., "user:1001") to produce natural Redis key patterns without extra flattening
  • Objects where every value is a number are treated as sorted sets — perfect for leaderboards, rankings, or priority queues
  • Use the Pipeline format when inserting hundreds or thousands of keys at once; it can be 10x faster than individual commands
  • After running generated commands, verify with SCAN or KEYS to confirm the key structure matches your expectations
  • For very large JSON files, consider splitting the data into chunks and running each chunk as a separate pipeline

Frequently Asked Questions

How does the converter decide which Redis command to use for each value?

The algorithm inspects each JSON value at runtime. Strings and numbers produce SET commands. Objects whose values are all primitives become HSET commands. Arrays of primitives become RPUSH commands. Objects where every value is numeric are treated as sorted sets and produce ZADD commands. Nested objects and arrays of objects are recursively flattened into colon-delimited key paths.

When should I NOT use this converter?

Avoid this tool if you need to preserve the original JSON document as a single Redis key — in that case, simply store the JSON string with SET. Also, if your data requires Redis Streams, HyperLogLog, or Bitmaps, those data types are not inferred from JSON and must be created manually.

What is the difference between CLI and Pipeline output?

CLI format prints one command per line, which you can paste into redis-cli interactively. Pipeline format wraps all commands inside PIPELINE and EXEC, allowing Redis to process them as a single batch. Pipeline mode dramatically reduces round-trip latency when you have many commands to execute.

How are boolean and null values represented in Redis?

Redis has no native boolean or null type. Booleans are stored as the strings "1" (true) and "0" (false), following a widely adopted convention. Null values are stored as the literal string "null". If you need different semantics, edit the output commands before running them.

How are deeply nested objects handled?

Deeply nested JSON is recursively flattened into colon-separated key paths. For example, {"user": {"profile": {"name": "Alice"}}} becomes SET prefix:user:profile:name Alice. Arrays of objects generate indexed keys like prefix:items:0:name and prefix:items:1:name.

Is my JSON data sent to any external server?

No. All conversion logic runs entirely inside your browser. Your data never leaves your device, and no network requests are made during the conversion process.

Real-world Examples

Seeding a user profile cache from a JSON export

You have a JSON export of user records and need to load them into Redis as hashes for fast lookup by user ID.

Input
{
  "user:5001": {
    "name": "Carol White",
    "email": "carol@example.com",
    "plan": "pro"
  },
  "user:5002": {
    "name": "Dave Lee",
    "email": "dave@example.com",
    "plan": "free"
  }
}
Output
HSET user:5001 name "Carol White" email "carol@example.com" plan "pro"
HSET user:5002 name "Dave Lee" email "dave@example.com" plan "free"

Loading a leaderboard into a sorted set

A JSON object with player scores is automatically detected as a sorted set, producing ZADD commands that let you query rankings instantly.

Input
{
  "leaderboard": {
    "alice": 950,
    "bob": 870,
    "carol": 920
  }
}
Output
ZADD leaderboard 950 alice 870 bob 920 carol

Related Tools