Base85 Encoder

Encode and decode Base85 (Z85) — compact 4-byte to 5-char binary text.

Free Base85 (Z85) encoder and decoder. Converts text and binary into the compact ZeroMQ Z85 alphabet — five printable characters per four bytes — and back. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is Base85 / Z85?

Z85 is the ZeroMQ Base85 encoding. It packs every four bytes into five printable ASCII characters using a safe 85-character alphabet, giving roughly 25 percent better density than Base64.

Base85 (Z85) encoder and decoder

Base85 packs binary data more densely than Base64: every four bytes become five printable characters. This tool uses Z85, the ZeroMQ variant, whose 85-character alphabet avoids quotes and backslashes so the output is safe to embed in source code and config files.

How it works

To encode, your text is converted to UTF-8 bytes and processed in 4-byte groups. Each group is read as a 32-bit big-endian number, then expressed in base 85 as five digits, each mapped to a Z85 alphabet character. Because the encoding needs whole 4-byte groups, input whose length is not a multiple of four is padded with zero bytes (the tool reports how many). Decoding takes each 5-character block, rebuilds the 32-bit value (value = value × 85 + digit), and splits it back into 4 bytes.

Why 85 is the magic number

Four bytes hold 256⁴ = 4,294,967,296 possible values. To encode that range in five characters, each character needs to cover at least ⁵√4,294,967,296 ≈ 84.4 values — so 85 is the smallest integer that works. Base64 handles only 3 bytes per 4 characters (a ratio of 4/3 ≈ 1.333 bytes per character), while Base85 handles 4 bytes per 5 characters (4/5 = 0.8 bytes per character represented as output characters, or more practically: Base64 expands data by 33%, Base85 expands it by only 25%).

Z85 vs Ascii85 — the two Base85 families

Z85 and Ascii85 (used in PostScript and PDF) are both Base85 encodings, but they are not interchangeable:

PropertyZ85 (ZeroMQ)Ascii85 (PostScript/PDF)
Start/end markersNone<~~>
All-zero shorthandNonez (single char = 5 zeros)
AlphabetSafe for source codeDifferent character range
Defined inZeroMQ RFC 32Adobe PLRM / RFC 1924

Z85’s alphabet was chosen to exclude characters that would cause problems in C string literals, JSON, YAML, and XML — specifically no single quotes, double quotes, or backslashes. This makes it convenient for embedding keys and binary data directly in config files or source code without escaping.

Worked examples

Encoding the 4-byte text Gera:

Gera → bytes 47 65 72 61m}DZH

Bytes (hex)Z85
47 65 72 61 (Gera)m}DZH
86 4F D2 6FHello (the official ZeroMQ Z85 test vector)

Padding and what to watch for

If your input length is not a multiple of 4, this tool pads the end with zero bytes and tells you how many it added. When decoding, you need to know the original byte length to strip that padding correctly. If you are building a system that round-trips Z85, either store the original length separately or design your protocol so payloads are always a multiple of 4 bytes (e.g., by using a fixed-length structure or appending a 1-byte length indicator).

Everything runs in your browser — your input never leaves the page.