Logo

MonoCalc

/

Z85 Encoder

Encode/Decode

Input (Plain Text)

About This Tool

🔐 Z85 Encoder – ZeroMQ RFC 32 Binary-to-Text Encoding

Z85 is a binary-to-text encoding scheme standardized in ZeroMQ RFC 32. It converts arbitrary binary data into a compact stream of printable ASCII characters by encoding every 4 bytes of input into 5 ASCII characters. This yields exactly 25% overhead — significantly less than Base64's 33% overhead — making Z85 the preferred encoding for binary data in text-based protocols, configuration files, and messaging systems.

How Z85 Encoding Works

The Z85 algorithm processes input in 4-byte blocks:

  1. Each 4-byte chunk is interpreted as a 32-bit big-endian unsigned integer.
  2. That integer is expressed as five base-85 digits (most significant first) by repeatedly dividing by 85.
  3. Each digit (0–84) is mapped to a character in the Z85 alphabet.

The encoding formula for one block:

value = b0×256³ + b1×256² + b2×256 + b3

c0 = alphabet[(value / 85⁴) % 85]
c1 = alphabet[(value / 85³) % 85]
c2 = alphabet[(value / 85²) % 85]
c3 = alphabet[(value / 85 ) % 85]
c4 = alphabet[(value      ) % 85]

Output: c0 c1 c2 c3 c4  (5 chars per 4-byte block)

The Z85 Alphabet

Z85 uses 85 carefully selected printable ASCII characters that are safe in shell scripts, JSON, YAML, XML, and most programming environments:

0123456789abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZz.-:+=^!/*?&<>()[]{}@%$#

The alphabet deliberately avoids ', ", \, and whitespace characters that would require escaping in most contexts.

Z85 vs Other Encodings

Z85 vs Base64

For 100 bytes of input: Base64 produces ~136 characters (33% overhead), Z85 produces 125 characters (25% overhead). Z85 output is approximately 8% smaller than Base64, and its character set is more shell- and URL-friendly without encoding.

Z85 vs ASCII85

ASCII85 (Adobe variant) uses characters ! to u and wraps output in <~ ~> delimiters. Z85 uses an alphanumeric-first alphabet and has no delimiters. Z85 is designed for modern protocols; ASCII85 is legacy PostScript/PDF.

Overhead Comparison Table

SchemeInput BytesOutput CharsOverhead
Z854525%
Base643433%
Base325860%
Hex12100%

Key Constraint: Input Must Be a Multiple of 4 Bytes

Unlike ASCII85, Z85 does not define a mechanism for partial final blocks. The input byte count must be exactly divisible by 4. This tool automatically zero-pads your input when needed and shows you how many padding bytes were added. Common inputs that naturally align to 4 bytes include:

  • Curve25519 public keys — 32 bytes → 40-character Z85 string
  • UUIDs / GUIDs — 16 bytes → 20-character Z85 string
  • SHA-256 hashes — 32 bytes → 40-character Z85 string
  • AES-128 keys — 16 bytes → 20-character Z85 string

UUID Shortening with Z85

A standard UUID (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) is 36 characters. By decoding it as 16 raw bytes and encoding with Z85, you get a 20-character compact representation — saving 44% of space. This is useful for compact database keys, URL path segments, or CLI argument identifiers.

Real-World Use Cases

ZeroMQ Curve25519 Keys

ZeroMQ's CURVE security mechanism uses Z85 to represent 32-byte Curve25519 public and private keys as 40-character ASCII strings. These can be safely included in configuration files and command arguments without escaping.

Binary Identifiers in APIs

Random nonces, session tokens, and correlation IDs are often 16 or 32 bytes of cryptographic data. Z85-encoding them produces compact, readable strings for API responses, log entries, and HTTP headers.

Configuration Files

Embedding cryptographic certificates, tokens, or binary blobs in YAML/TOML/JSON configuration files is cleaner with Z85 than with hex — strings are shorter and avoid the quoting issues of Base64's +, /, and = characters.

Tips for Using This Tool

  • Use Plain Text mode for quick experiments — the tool auto-pads your input to 4-byte alignment.
  • Use Hex String mode to encode exact byte sequences such as cryptographic keys or hash digests.
  • Use UUID / GUID mode to generate compact 20-character identifiers from standard UUIDs.
  • Enable Auto Encode to see the Z85 output update in real time as you type.
  • Toggle Show Alphabet to display the full Z85 character set with index values for reference.
  • The Block Mapping table shows up to 8 input blocks with their hex bytes and corresponding Z85 output — useful for learning and debugging.

Frequently Asked Questions

Is the Z85 Encoder free?

Yes, Z85 Encoder is totally free :)

Can I use the Z85 Encoder offline?

Yes, you can install the webapp as PWA.

Is it safe to use Z85 Encoder?

Yes, any data related to Z85 Encoder only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

What is Z85 encoding and how does it work?

Z85 is a binary-to-text encoding scheme defined in ZeroMQ RFC 32. It encodes every 4 bytes of binary data into 5 printable ASCII characters using a carefully chosen 85-character alphabet. This achieves 25% overhead, making it more compact than Base64's 33% overhead.

Why does Z85 require input to be a multiple of 4 bytes?

Z85 processes data in strict 4-byte blocks. Unlike ASCII85, it has no mechanism for handling partial final blocks, so the total input byte count must be exactly divisible by 4. This tool automatically zero-pads your input to the next multiple of 4 and reports how many padding bytes were added.

What is the Z85 character set?

The Z85 alphabet consists of 85 printable ASCII characters: digits 0–9, lowercase a–z, uppercase A–Z, and the symbols .-:+=^!/*?&<>()[]{}@%$#. This character set avoids quote marks and backslash, making Z85 strings safe in shell commands, JSON, YAML, and most text protocols.

How can I use Z85 to shorten a UUID?

A standard UUID is 36 characters (including hyphens). By stripping the hyphens and encoding the 16 raw bytes as Z85, you get a compact 20-character representation. This is useful in databases, URLs, and configuration files where compact identifiers are preferred.

Is Z85 the same as Base85 or ASCII85?

Z85 is a variant of Base85. ASCII85 (Adobe/PostScript) uses a different character set (! to u) and wraps output in <~ ~> delimiters. Z85 uses an alphanumeric-first character set and has no delimiters. Both encode 4 bytes into 5 characters but are not interchangeable.

Where is Z85 encoding commonly used?

Z85 is the native encoding used by the ZeroMQ messaging library for cryptographic keys and security tokens (e.g., Curve25519 public keys). It is also used to encode binary identifiers (UUIDs, nonces, hashes) in configuration files, APIs, and protocols where Base64's overhead is undesirable.