Keyspace Map for Redis and Valkey
Paste a list of keys and see what a keyspace holds: the prefixes as a tree with counts, the naming patterns behind the keys with IDs and hashes folded together, how many bytes the key names take, and naming slips worth a look. It runs in your browser.
Nothing you paste leaves this page. The tool doesn’t send anything anywhere, and the page’s security policy stops it from fetching or loading anything from another site, so your key names stay on your machine.
On a wide screen you can open it full screen.
How to Use It
- List the keys without hurting the server. Use
--scan, which walks the keyspace a slice at a time.KEYS *does it in one go and blocks every other client until it’s done.
redis-cli -h 10.0.0.4 -p 6379 --scan > keys.txt
- Paste the list or load the file. The map works out the separator, usually
:, and updates as you type. - Read the patterns. Parts that vary are folded into placeholders:
<id>for numbers,<hex>for hashes,<uuid>,<date>,<email>,<ip>,<token>for long random strings, and<*>for a level of one-off names. Braces stay, since in a key they mark a hash tag:cart:{<id>}:items. - Check what’s worth a look: keys with no separator, prefixes that differ only in case, prefixes one letter apart such as
userandusr, empty parts, very long keys, and keys with bytes that aren’t valid UTF-8.
On a cluster, run --scan against each primary, since each one lists only its own keys.
Why Map a Keyspace
A key-value store has no tables, only one flat list of keys. Whatever structure there is lives in the names. After a few years and a few teams, nobody is quite sure what’s in there, or which feature owns most of it. The map reads that structure back out of the names, so a million keys become a handful of lines like user:<id>:profile 3000 32.7%.
How It Was Tested
9,161 keys made from 13 known patterns, with planted slips, were loaded into Valkey 9.1.2 and Redis 8.10.2 and listed back with --scan, raw and quoted. On both servers the map found exactly the 13 patterns with the right counts, and every slip that was planted. The count under each top-level prefix matched the server’s own SCAN MATCH.
The Code
The map’s logic is one JavaScript file with no dependencies, open source under the Apache License 2.0. It runs as this page, as a command line in Node.js, and inside your own code:
redis-cli --scan | node keyspace/cli.js -
The full manual and the tests are in the keyspace folder on GitHub. The other tools work the same way.