Z85 Encoder

Enter text to encode it as a Z85 (ZeroMQ base-85) string.

How it is calculated

The text is read as raw UTF-8 bytes. If the byte count is not a multiple of 4, zero bytes (0x00) are appended until it is. Each 4-byte group is read as one big-endian 32-bit number V = b1·256³ + b2·256² + b3·256 + b4, which is then written as five base-85 digits, most significant first: V = d1·85⁴ + d2·85³ + d3·85² + d4·85 + d5. Each digit 0 to 84 is replaced by the character at that position in the Z85 alphabet, which starts 0-9, a-z, A-Z and then punctuation (.-:+=^!/*?&<>()[]{}@%$#). The output shows the padding added, so you know the encoded string is longer than the original data. Empty input returns nothing. The padding is not marked in the output, so a decoder cannot tell it from real zero bytes.

Worked example

Input Hello is 5 bytes, so 3 zero bytes are added to reach 8. Group 1 is "Hell" = 0x48656C6C = 1,214,606,444, which in base 85 gives the digits 23, 22, 66, 52, 49 and the characters nm=QN. Group 2 is "o" plus three zero bytes = 1,862,270,976, digits 35, 57, 33, 65, 26 and the characters zVx+q. Joined: nm=QNzVx+q, with 5 bytes (8 after padding) and 3 zero bytes of padding.

Try this example →

Common mistakes

  • Expecting the output to be reversible to exactly the original text: the zero padding is not marked, so decoding gives the padded bytes back, with trailing NUL characters.
  • Counting characters instead of bytes: accented or non-Latin letters take 2 to 4 bytes in UTF-8, so "ğ" is 2 bytes and changes the length and padding.
  • Confusing Z85 with the Ascii85 (Adobe) or base85 of Python and git: the alphabets differ, so the strings are not interchangeable.
  • Treating the encoding as encryption. It is a reversible representation with no secrecy at all.
  • Pasting a ZeroMQ key and expecting it to be unchanged; Z85 keys are already encoded, so encoding them again produces a different, longer string.

About this calculator

Z85 is the base-85 binary-to-text encoding defined by the ZeroMQ project's ZMTP/spec:32 specification, designed to pack binary data into printable ASCII more densely than base64: base64 expands data by roughly 33%, while Z85's 85-symbol alphabet expands it by only 25%, encoding every 4 bytes of input into exactly 5 output characters.

Because that 4-byte grouping is fixed, Z85 requires the input length to be a multiple of 4 bytes, so encoders zero-pad shorter inputs before converting. Z85 is best known as the encoding ZeroMQ itself uses for its CURVE security public and secret keys, making them safe to print, log, or paste as plain text.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Z85 turns every four bytes into five characters, so the output is 25% longer than the input, and the preset Hello becomes 10 characters after padding to 8 bytes. The alphabet avoids quotes and backslashes, which suits source-code strings, but it includes the ampersand and the less-than and greater-than signs, so escape it in HTML or XML. Keep the padding count shown, since a decoder needs it. Where do you plan to embed the output?

Popular calculators

All Calculators