How to use
- Choose Encode to turn text or bytes into Z85, or Decode to turn Z85 back into data.
- For keys and other binary values, set the input to Hex when encoding, or the output to Hex when decoding.
- Type, paste or open a file. The result updates as you type.
- Copy the result or download it as a file.
What is Z85?
Z85 is specified in ZeroMQ RFC 32 (a ZeroMQ community specification, not an IETF RFC). Like other Base85 encodings it turns every 4 bytes into 5 characters, reading each group as a big-endian 32-bit number and writing it as 5 base-85 digits, most significant first. The output is 25% larger than the input.
What sets Z85 apart is its alphabet: 0-9, a-z, A-Z and the 23 symbols .-:+=^!/*?&<>()[]{}@%$#. It leaves out both quote characters, the backslash, the backtick, the comma, the semicolon, the vertical bar, the tilde and the underscore. The alphabet was designed to be safe in source code strings, so a Z85 value can be pasted between quotes in C, Python or JSON without any escaping.
Where Z85 is used
ZeroMQ uses Z85 to print CurveZMQ keys. A 32-byte public or secret key becomes a 40-character Z85 string, which is the form returned by zmq_curve_keypair() and accepted by the socket options for CURVE security. The library also exposes zmq_z85_encode() and zmq_z85_decode(), and bindings such as pyzmq provide the same functions.
// C (libzmq)
char text[41]; // 32 bytes -> 40 chars + NUL
zmq_z85_encode(text, key, 32);
# Python (pyzmq)
from zmq.utils import z85
z85.encode(bytes.fromhex('864fd26fb559f75b')) # b'HelloWorld'
The last line is the test vector from the specification.
Input length: a note on this tool
RFC 32 requires the binary input to be a multiple of 4 bytes and the encoded string a multiple of 5 characters. It defines no padding, and strict implementations such as zmq_z85_encode() refuse other lengths.
This tool also accepts other lengths, using the same rule as Ascii85 and Base85: a final group of n bytes becomes n + 1 characters. This is a non-standard extension. Output produced this way may be rejected by other Z85 decoders, so pad your data to a multiple of 4 bytes when you need compatibility. CurveZMQ keys are 32 bytes and always fit.
Specification
| Alphabet | 0-9 a-z A-Z .-:+=^!/*?&<>()[]{}@%$# |
|---|---|
| Output size | 5 characters per 4 bytes (125%) |
| Padding | None |
| Standard | ZeroMQ RFC 32 |
| Case sensitive | Yes |
Examples
| Input (UTF-8) | Output |
|---|---|
Hello, World! | nm=QNz.92jz/PV8aP |
Base64.is | lsB}Dhz^42A@ |
你好 | <H}kFRm= |
Frequently asked questions
What is the difference between Z85 and Ascii85?
! to u, which includes quotes and the backslash, and has a z shortcut for zero bytes. Z85 avoids characters that need escaping in strings and has no shortcut.Does Z85 use padding?
No. The specification only allows input lengths that are a multiple of 4 bytes. This tool encodes other lengths with a shorter final group, which is not part of the standard.
Can I use Z85 in JSON, XML or URLs?
How long is a Z85-encoded CurveZMQ key?
A CurveZMQ key is 32 bytes, so it encodes to exactly 40 characters. To see the raw key, decode it here with Hex output.