🔓 Z85 Decoder – Decode ZeroMQ RFC 32 Encoded Strings
The Z85 Decoder converts Z85-encoded ASCII strings back to their original binary representation. Z85, defined in ZeroMQ RFC 32, is a binary-to-text encoding scheme that maps every 4 bytes of data to exactly 5 printable ASCII characters. This makes Z85 strings safe inside C, Python, JSON, XML, shell scripts, and most text-based protocols.
What is Z85 and Why Does It Exist?
Binary data cannot always be transported as-is through text channels. Base64 solves this by expanding every 3 bytes to 4 characters (33% overhead). Z85 does better: it represents 4 bytes as 5 characters (25% overhead). The 85-character alphabet — 0–9, a–z, A–Z, and .-:+=^!/*?<>()[]@%$# — avoids quote marks and backslash, making Z85 output safe in virtually any source-code context without escaping.
Z85 is most widely used in the ZeroMQ messaging library, where it encodes Curve25519 public and private keys (32 bytes → 40 Z85 characters) for the CurveZMQ security handshake.
How Z85 Decoding Works
Each group of 5 Z85 characters is decoded to 4 binary bytes using these steps:
- Validate — confirm input length is a multiple of 5 and every character belongs to the 85-character Z85 alphabet.
- Look up indices — each character maps to an integer 0–84 in the Z85 alphabet table.
- Combine — compute
v = c₀×85⁴ + c₁×85³ + c₂×85² + c₃×85 + c₄. - Extract bytes — split the 32-bit value into 4 big-endian bytes:
byte[i] = (v >> (24 − 8i)) & 0xFF.
Output Formats
| Format | Description | Best For |
|---|---|---|
| Hex Dump | Offset + hex octets + ASCII sidebar | Binary inspection & debugging |
| UTF-8 Text | Decoded bytes rendered as readable text | Text payloads & config values |
| Base64 | Decoded bytes re-encoded as Base64 | Interoperability with Base64 systems |
| C Array | uint8_t data[] = {0xHH, …} | Embedding bytes in C / C++ code |
| Python Bytes | b'\xHH\xHH…' | Python scripts & data science |
| JavaScript Uint8Array | new Uint8Array([0xHH, …]) | Browser / Node.js buffers |
CurveZMQ Key Decoding
CurveZMQ uses 40-character Z85 strings to represent 32-byte Curve25519 keys. When the decoder receives exactly 40 Z85 characters, it automatically highlights the result as a potential cryptographic key and renders the 32 bytes in a 4×8 hex grid for easy visual inspection.
Validation Rules
✓
Length must be a multiple of 5
Z85 encodes 4 bytes per 5 chars — no partial blocks allowed
✓
Only Z85 alphabet characters
Any character outside the 85-char set triggers an error with position
✓
Non-empty input required
Empty or whitespace-only input is rejected before decoding
✓
Strip Whitespace option
Enable to auto-remove spaces and newlines from pasted data
Z85 vs Other Encoding Schemes
Z85 achieves 25% size overhead compared to the original binary — better than Base64 (33%) and Base16/Hex (100%). However, unlike Base64, Z85 mandates input that is an exact multiple of 4 bytes, so zero- padding may be needed at the encoding stage. Use the Z85 Encoder companion tool when you need to encode binary data to Z85 before decoding it here.
Common Use Cases
- CurveZMQ key inspection — decode Curve25519 public or private keys exchanged in ZeroMQ security handshakes
- Protocol debugging — inspect binary payloads embedded as Z85 in configuration files or network messages
- Round-trip verification — confirm that a Z85 encode → decode cycle recovers the original bytes without loss
- Code generation — paste a Z85 string and instantly get the byte literals needed in your C, Python, or JavaScript program