Z85 Encoder & Decoder (ZeroMQ)

Convert binary or text to Z85 — ZeroMQ's base-85 encoding that packs four bytes into five printable, source-code-safe characters — and decode it back. Feed it hex bytes or UTF-8 text, and it enforces the 4-byte grouping the format requires. Everything runs locally as you type.

How to use the Z85 Encoder & Decoder (ZeroMQ)

Pick Encode or Decode, choose whether the binary side is expressed as Hex bytes or Text, and type or paste. The result updates live and Copy output grabs it. The default shows the canonical ZeroMQ example: the eight bytes 86 4F D2 6F B5 59 F7 5B encode to the string HelloWorld. In hex mode you can separate bytes with spaces or commas and use an optional 0x prefix; in text mode the characters are converted to UTF-8 bytes first.

Z85 works on four-byte groups, turning each into exactly five characters, so the number of input bytes when encoding must be a multiple of four, and the number of characters when decoding must be a multiple of five. If your input does not line up, the tool tells you how many bytes or characters it received rather than producing a corrupt result. This strictness is part of the specification — unlike Ascii85, Z85 defines no padding, so the caller is expected to supply data already sized to a 4-byte boundary.

The output alphabet is deliberately chosen to be safe inside source code and string literals, avoiding the backslash, quotes, and comma. Everything is computed in your browser, so encoding and decoding are instant, work offline, and nothing you enter is uploaded.

Z85: base-85 built for source code

Z85 is a binary-to-text encoding defined by the ZeroMQ project in its RFC 32 specification. Like other base-85 schemes, its appeal over base-64 is density: four bytes of input carry 32 bits of information, and because 85 raised to the fifth power comfortably exceeds two raised to the thirty-second, five base-85 characters are enough to represent any four bytes. That five-for-four ratio is more compact than base-64's four-for-three, so the same data comes out about seven percent shorter. The encoding reads each four-byte group as a single unsigned 32-bit number and then writes it in base 85, most significant digit first, mapping each digit through an 85-character alphabet.

What distinguishes Z85 from the older Ascii85 is the choice of alphabet. Ascii85 uses a run of consecutive ASCII codes starting at the exclamation mark, which unfortunately includes the backslash, the double quote, and other characters that are painful to embed in source code, JSON, or shell commands without escaping. Z85 was designed specifically so that its output can be pasted directly into code and string literals: it uses the digits, both cases of the alphabet, and a carefully selected set of punctuation, while deliberately omitting the characters that cause trouble — no backslash, no single or double quote, no comma. The result is that a Z85 string is safe to drop into a C, Python, or JavaScript literal as-is, which is exactly what ZeroMQ needs for representing binary keys and identities in configuration and code.

The trade-off for that simplicity is that Z85 has no padding scheme. The specification requires that the input length be divisible by four, and decoders require the text length to be divisible by five; it is the application's job to arrange its data — typically fixed-size things like 32-byte CurveZMQ keys, which divide evenly — to meet that rule. This is a reasonable constraint for its intended use but means Z85 is not a drop-in encoder for arbitrary-length blobs the way base-64 is, unless you add your own length framing. Understanding that boundary requirement is the main thing that trips people up: an "invalid length" error almost always means the byte count was not a multiple of four. Within that rule, Z85 is a clean, compact, copy-paste-friendly way to move binary data through text-only channels, and being able to encode and decode it in the browser is handy whenever you are working with ZeroMQ keys or any system that adopted the format.

Common use cases

  • ZeroMQ keys. Encode or decode CurveZMQ public and secret keys, which are Z85 by convention.
  • Embedding binary. Turn fixed-size binary data into a string safe to paste into source code.
  • Compact transport. Get a denser-than-base64 text form of 4-byte-aligned data.
  • Debugging. Decode a Z85 string back to its raw bytes to inspect them as hex.

Frequently asked questions

Why do I get a length error?

Z85 has no padding, so encoding requires the byte count to be a multiple of four and decoding requires the character count to be a multiple of five. The tool reports the count it received so you can adjust or pad your data.

How is Z85 different from Ascii85?

Both are base-85, but Z85 uses an alphabet chosen to be safe in source code — no backslash, quotes, or comma — and defines no padding. Ascii85 uses consecutive ASCII codes and includes characters awkward to embed in code.

What is the HelloWorld example?

It is the canonical test vector from the Z85 specification: the eight bytes 86 4F D2 6F B5 59 F7 5B encode to the text HelloWorld, a quick way to confirm an implementation is correct.

Can I encode any text with it?

Only if its UTF-8 byte length is a multiple of four. Z85 is designed for fixed-size binary data like keys; arbitrary text needs to be padded to a 4-byte boundary first, which Z85 itself does not do.