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?

This tool converts JSON data into Redis CLI commands. It intelligently maps JSON structures to the most appropriate Redis data types: strings and numbers become SET keys, objects with primitive values become HSET hashes, arrays become RPUSH lists, and objects with all-numeric values become ZADD sorted sets.

How to Use

  1. Optionally set a key prefix to namespace your Redis keys
  2. Choose output format: Redis CLI (one command per line) or Pipeline (wrapped in PIPELINE/EXEC)
  3. Paste your JSON data into the input area and click "Generate Redis Commands"
  4. Copy the output and run the commands in your Redis CLI or application

Why Use This Tool?

Smart type detection: objects → HSET, arrays → RPUSH, numeric objects → ZADD
Handles nested JSON by flattening into colon-separated Redis key patterns
Configurable key prefix for namespace isolation
Supports both CLI and pipeline output formats
Proper escaping for values containing spaces, quotes, and special characters

Tips & Best Practices

  • Use colon-separated keys (e.g. "user:1001") in your JSON for natural Redis key patterns
  • Objects with all-numeric values are automatically converted to sorted sets (ZADD)
  • The pipeline format batches all commands for efficient execution in a single round trip
  • Boolean values are stored as 1 (true) and 0 (false) for Redis compatibility

Frequently Asked Questions

How does the tool decide which Redis command to use?

The tool uses smart type detection: top-level string/number values use SET, objects with primitive values use HSET, arrays use RPUSH, and objects where all values are numbers use ZADD (sorted sets). Nested objects are flattened into colon-separated keys.

What is the difference between CLI and Pipeline format?

CLI format outputs one command per line, suitable for direct execution in redis-cli. Pipeline format wraps all commands in PIPELINE/EXEC blocks, which allows Redis to execute them in a batch for better performance.

How are boolean values handled?

Redis does not have a native boolean type. Boolean values are converted to strings: true becomes "1" and false becomes "0", which is a common convention in Redis.

What about nested objects and arrays?

Nested objects are flattened using colon-separated key patterns. For example, {"user": {"profile": {"name": "Alice"}}} becomes SET prefix:user:profile:name Alice. Arrays of objects generate separate keys with index-based suffixes.

Is my JSON data sent to a server?

No, all processing happens entirely in your browser. Your JSON data never leaves your device.

Related Tools