Z85 Encoder/Decoder

ZeroMQ's printable Base85 variant safe in code strings

Ad placeholder (leaderboard)

Z85 is the Base85 variant defined in ZeroMQ RFC 32. It packs four bytes into five characters like Ascii85, but its 85-character alphabet is chosen so the output is safe to paste straight into source-code string literals — no backslash, quote, or other escape-prone symbols. This tool encodes UTF-8 text into Z85 and decodes it back, all in your browser.

How it works

Z85 treats the data as a stream of four-byte groups:

  1. Each group of four bytes forms a 32-bit number.
  2. That number is expressed as five base-85 digits, each mapped through the alphabet 0-9 a-z A-Z followed by the punctuation set .-:+=^!/*?&<>()[]{}@%$#, written most-significant first.
  3. Decoding reverses this: every five characters rebuild a 32-bit value, which is split back into four bytes.

Because Z85 has no padding, the byte length must be a multiple of four. When you encode free text, the tool adds the minimum number of zero bytes to reach a four-byte boundary and reports how many it appended.

Tips and example

The canonical RFC 32 test vector — the bytes 86 4F D2 6F B5 59 F7 5B — encodes to HelloWorld, a neat demonstration of the format. Z85 shines for fixed-length binary such as the 32-byte CurveZMQ keys ZeroMQ uses, which become a tidy 40-character string. If your data already aligns to four bytes, no padding is needed and the round-trip is exact; if it does not, remember the encoded output includes the padding bytes, so strip them after decoding when you only wanted the original length.

Ad placeholder (rectangle)