Value formats

functional

View a value as UTF-8, JSON, hex, MessagePack, Base64, Protobuf, or decompressed gzip, zstd and LZ4, with your pick remembered per key.

The value viewer can show a value in the format you choose instead of only the one it detects. Open a value, Open Value on a Redis key and then Open in Value Viewer… or View as Hex… on its result cell, or Preview Payload in the Pub/Sub viewer, and use the Format menu in the viewer's toolbar. The menu is grouped: the plain views, then encodings, then compression, then language serializers. The formats are presentation only: whichever you pick, the bytes stored in the key never change.

  • Auto - the detected view (JSON, XML, image, geometry, or text). When none of those match, Auto also looks at the leading bytes and the structure of the value and recognises gzip, zstd, LZ4, zlib, Java serialization, Python pickle, PHP serialize, Base64, and Protobuf; what it found is named beside the menu ("Auto: gzip → JSON (1,234 → 5,678 bytes)"). The structural sniffs are conservative on purpose: the whole value must parse, and a Base64 guess is only made for values of at least 16 characters whose decoded bytes are something readable, so a plain word, a hex id, or a key name like user:42 stays text.
  • UTF-8 - the bytes as text; invalid UTF-8 is shown with replacement characters and a note saying so.
  • JSON - pretty-printed with the tree view; a value that is not valid JSON keeps its raw text with a note.
  • YAML - highlighted, with the same searchable tree JSON gets; a value that is not a YAML mapping or list keeps its raw text with a note.
  • Markdown - highlighted in Raw mode, and rendered (headings, lists, tables, code blocks, links) in Preview mode.
  • Hex - the canonical hex dump.
  • MessagePack - decoded to JSON for the tree and highlighter. Binary fields show as {"$binary": "<hex>"}, standard timestamps as {"$timestamp": "2023-11-14T22:13:20Z"}, other extension values as {"$ext": {"type": n, "data": "<hex>"}}, and a map whose keys would collide as JSON object keys (an integer 1 next to the string "1", or a repeated key) as {"$map": [[key, value], …]} so no entry is lost. A payload that is not valid MessagePack falls back to the hex dump with the decoder's reason.
  • Base64 - standard or URL-safe, padded or not, with line wrapping ignored. The decoded bytes are then shown as whatever they are: a JSON or XML tree, text, a recognised serialization, or a hex dump.
  • Protobuf - a protocol-buffers message walked without its schema, so any message can be inspected: field numbers become keys, varints show as numbers, fixed-width fields show both their integer and floating-point readings ({"$fixed64": …, "$double": …}), length-delimited fields show as text when they read as text, as a nested message when they walk as one, and as {"$bytes": "<hex>"} otherwise. A repeated field becomes an array. Field names need the message's schema: register your .proto files under Settings › Results › Protobuf Schemas (see below).
  • gzip - zstd, LZ4, deflate, the value is decompressed and the result is shown as whatever it contains (JSON and XML get their trees, PHP, Java, pickle and Protobuf payloads their decode, text its text, anything else the hex dump), with a note giving the sizes before and after. Only one layer is unwrapped per pick: a compressed stream inside a compressed stream is named in the note, not decompressed again. LZ4 accepts both the frame format and a raw block with its original size prepended; deflate accepts zlib-wrapped and raw streams. zstd is not available in the browser edition of SQLly, and the menu says so.
  • PHP serialize - serialize() output decoded to JSON: lists become arrays, other arrays objects, objects {"$class": "Name", "$properties": {…}} with protected and private property names spelled protected:name and private:Class:name, references {"$ref": n}, and a string that is not UTF-8 {"$bytes": "<hex>"}.
  • Java serialization - an ObjectOutputStream payload is recognised by its header and summarised: the stream version, the classes it carries with their serialVersionUID, and the strings in it. Field values are not decoded; that needs the classes themselves.
  • Python pickle - a protocol 2 or later pickle is recognised by its header and summarised: protocol, opcode counts, the globals (module.name) it references, a sample of its strings, and whether it ends cleanly. The object is never rebuilt, that would mean running the pickle's instructions.

Every decoder treats the value as untrusted. Decompressed output is capped at 16 MB, and a gzip trailer, zstd frame header, or LZ4 block prefix that already claims more than that is refused before any decompression starts; a truncated or corrupt stream is reported as not decodable with the decoder's reason, never shown as partial output. Protobuf and PHP nesting stops at 128 levels, every length inside a value is checked against the bytes actually present, and a walker that cannot account for every byte refuses the whole value.

Protobuf with your own schemas

Under Settings › Results › Protobuf Schemas, Add .proto File… registers one or more .proto files (a file's folder is where its imports are looked up, and the standard google/protobuf/* types are built in), and Add Descriptor Set… registers a compiled set from protoc --descriptor_set_out. Each schema is listed with its message types, or with the compiler's reason when it cannot be read; Reload re-reads the files after you change them, and Remove unregisters one without touching the file.

With a schema registered, a value shown as Protobuf gets a Message menu beside the Format menu. Pick a message type and the value is decoded with real field names - nested messages, enums by name, repeated fields as arrays, 64-bit numbers as numbers - in the JSON tree. Fields the value carries that the message does not define are listed by number in the note. If the value does not fit the message at all (a field has the wrong wire type, or none of its fields belong to the message), or the schema has since been removed, the viewer falls back to the schema-free field-number view and says why. The message type is remembered like the format: for a Redis key across restarts (in protobuf-schemas.json in SQLly's data folder), for any other cell for the session. The browser edition cannot read schema files, so there Protobuf values are always shown by field number.

Editing a compressed value

A value stored compressed - gzip, zlib, raw deflate, zstd, LZ4 (frame or size-prefixed block), or MySQL COMPRESS() output, can be edited as the text inside it and written back compressed exactly the same way, so whatever reads it keeps working:

  • Result grid. Open a compressed binary cell in the viewer (View as Hex… or Open Structured Data Viewer). When the view is a decompressed value, Edit opens the text; Stage as gzip (or whichever packaging it was read in) re-compresses it and stages it as a pending change on that cell, which you review and save like any other grid edit.
  • Redis key view. Editing a compressed string, hash field, or list element starts from its decompressed text with Save re-compressed as … ticked; the reviewed command writes the re-compressed bytes. Untick it to store the text as typed.

The packaging is matched exactly (a zlib header stays a zlib header, MySQL's 4-byte length prefix is rewritten for the new length), and the re-compressed bytes are checked to decompress back to your text before anything is staged. A value whose packaging cannot be pinned down, or whose contents are binary rather than text, is not offered for editing.

Binary cells also get the picker in the Cell Details panel's hex view and in the viewer it opens, so a MessagePack value in any binary column can be decoded the same way.

The MessagePack decoder treats the payload as untrusted. Lengths in the data are checked against the bytes actually present, so a truncated or hostile payload is reported as not decodable instead of exhausting memory, and nesting deeper than 128 levels is refused.

For a Redis key read (GET, HGETALL, LRANGE, JSON.GET…) opened from a result cell, the choice is remembered for that connection, database, key and column, and it survives restarting SQLly: the key's value comes back in the format you picked whichever tab or row shows it. The choices are kept in value-formats.json in SQLly's data folder, which holds the 2,000 most recently chosen keys; older ones are forgotten first. The file carries a version number, and a format name written by a newer SQLly that this one does not know is read as Auto rather than refusing the file. If that file cannot be read, SQLly leaves it untouched, says so under the viewer's toolbar, and keeps your new choices for this session only. Other result cells remember the choice for that query, row and column until SQLly quits. Choosing Auto forgets it. Values over 1 MB keep the detected view only.

SQLly
Value viewer format picker: a MessagePack-encoded Redis value decoded into the JSON tree.
Value viewer format picker: a MessagePack-encoded Redis value decoded into the JSON tree.