A lightweight, Python-based Redis RDB parser that converts Redis dump.rdb files to JSON format. Perfect for migrating Redis data, backup analysis, or debugging Redis databases. Supports RDB version 12 (Redis 7.x) with full parsing of strings, lists, sets, sorted sets (ZSET), hashes, streams, and more. SEO-optimized for developers searching for "Redis RDB to JSON converter" or "parse Redis RDB file".
Transform your Redis RDB dump into searchable JSON in seconds:
# Without Redis
pip install -r requirements.txt # Optional: for LZF decompression
python rdb_parser.py dump.rdb output.json --pretty --simple
# With Redis Server - make sure you have backup.rdb file
docker-compose up -d
python3 export_from_redis.py output.jsonOutput example (simplified JSON):
{
"keys": {
"user:123": "John Doe",
"cart:456": ["item1", "item2"],
"scores": [{"member": "alice", "score": 95.5}]
}
}- Full RDB Parsing: Handles Redis RDB version 12 (Redis 7.x) including legacy formats like ziplists, quicklists, and listpacks.
- Data Types Supported:
- Strings (with LZF compression support)
- Lists (ziplist, quicklist)
- Sets (intset, listpack)
- Sorted Sets (ZSET, ziplist/listpack encoded)
- Hashes (ziplist, listpack)
- Streams (simplified parsing)
- Metadata Extraction: Captures expiry times, idle/frequency counters, DB selection, and AUX fields.
- Flexible Output:
- Simple mode: Raw values only.
- Full mode: Includes type, expiry, and timestamps.
- Error-Resilient: Skips invalid entries, handles binary data gracefully, and logs warnings.
- SEO-Friendly: Optimized for searches like "convert Redis RDB to JSON", "Redis backup parser Python", "RDB dump analyzer".
- Lightweight: No heavy dependencies (optional
python-lzffor compression).
-
Clone the Repo:
git clone https://github.com/aero25x/redis-rdb-convert.git cd redis-rdb-convert -
Install Dependencies (Python 3.7+ required):
pip install python-lzf # Optional: For LZF decompression of strings
3.1. Run the Parser Offline:
python rdb_parser.py /path/to/dump.rdb [output.json] [--pretty] [--simple]3.2. Run the Parser with Redis Server:
docker-compose up -d
python3 export_from_redis.py output.jsonConvert a full RDB dump to pretty-printed JSON:
python rdb_parser.py backup.rdb --prettyOutput: Prints JSON to stdout with full metadata (e.g., expiry dates in ISO format).
Extract just key-value pairs (no metadata):
python rdb_parser.py dump.rdb output.json --simpleThe parser auto-detects DB changes via SELECTDB opcodes. For multi-DB dumps, all data is consolidated under the last DB (customize in code if needed).
from rdb_parser import RDBParser
parser = RDBParser('dump.rdb', simple_format=True)
result = parser.parse()
print(json.dumps(result['keys'], indent=2))| RDB Type | Encoding | Description | Example Output |
|---|---|---|---|
| String | Raw/LZF/Int | Basic key-value | "value" |
| List | Ziplist/Quicklist | Ordered array | ["item1", "item2"] |
| Set | Intset/Listpack | Unique members | ["a", "b"] |
| ZSET | Ziplist/Listpack | Member-score pairs | [{"member": "alice", "score": 95.5}] |
| Hash | Ziplist/Listpack | Field-value map | {"field1": "val1"} |
| Stream | Listpacks | Entries (simplified) | "<stream with N elements>" |
Note: Binary data is hex-encoded; large strings (>100MB) are skipped for safety.
- Compression: LZF requires
python-lzf; otherwise, compressed strings show as placeholders. - Streams: Basic support—full consumer groups not parsed.
- Very Large Files: Memory-intensive for GB-scale RDBs; process in chunks if needed.
- Older Versions: Optimized for RDB v12; test with v5-v11 for compatibility.
- No Modules: Skips Redis Modules (TYPE_MODULE).
For issues like "RDB parse error" or "ziplist decoding failed", check stderr logs or open an issue.
Love this Redis RDB converter? Help make it better!
- Fork the repo.
- Create a feature branch (
git checkout -b feature/amazing-feature). - Commit changes (
git commit -m 'Add amazing feature'). - Push to branch (
git push origin feature/amazing-feature). - Open a Pull Request.
Guidelines: Add tests for new encodings, update parse_ziplist for edge cases. See CONTRIBUTING.md for details.
This Redis RDB to JSON parser is MIT-licensed. See LICENSE for details.
- rdbtools: C-based alternative.
- redis-dump-go: Go implementation.
- Searching for "Redis RDB recovery" or "migrate Redis to JSON"? This tool fits perfectly!
Keywords: Redis RDB parser, RDB to JSON, Redis dump converter, parse Redis backup, Redis 7 RDB, ziplist decoder, listpack parser.
Built with ❤️ for Redis devs. Star ⭐ if it saves your day!