The classic Ascii85 example
Man
<~9jqo^~>
The 4 bytes of "Man " (with the trailing space) become 5 characters between the Adobe markers.
Encode and decode Base85 in the Ascii85 (Adobe and btoa) and Z85 (ZeroMQ) variants. The most compact text encoding in common use, about 25% overhead.
<~ ~> delimiters (PDF, PostScript), Ascii85 without delimiters, or Z85 (ZeroMQ).<~ and ~> markers and any line breaks are handled automatically.Man
<~9jqo^~>
The 4 bytes of "Man " (with the trailing space) become 5 characters between the Adobe markers.
<~87cURDZ~>
Hello
5 bytes: one full group of 4 (87cUR) and a final group of 1 byte, written with 2 characters (DZ).
Hi!!
nnfj<
Z85 needs the input to be a multiple of 4 bytes, and uses a different alphabet from Ascii85.
Base85 encodes every 4 bytes of data as 5 printable characters, using 85 different symbols. That adds only 25% to the size, compared with 33% for Base64 and 100% for hex. The price is a larger alphabet that includes punctuation such as ", ', \ and <, so Base85 needs care in JSON, XML, URLs and shell commands.
There is no single Base85. The common variants share the 4-bytes-to-5-characters idea but use different alphabets and rules: Ascii85 (Adobe, btoa), Z85 (ZeroMQ) and the alphabet used by Git and RFC 1924.
Take 4 bytes as one 32-bit number, then write it as 5 base-85 digits. 855 = 4,437,053,125 is just above 232 = 4,294,967,296, so 5 digits always fit:
| Step | Value for Man |
|---|---|
| Bytes | 4d 61 6e 20 |
| 32-bit number | 1,298,230,816 |
| Base-85 digits | 24, 73, 80, 78, 61 |
| Ascii85 (digit + 33) | 9 j q o ^ |
In Ascii85, each digit is written as the ASCII character with code digit + 33, so the alphabet runs from ! (33) to u (117).
z for zeros: a group of four zero bytes is written as a single z instead of !!!!!. This only applies to whole groups.<~ and ~>. Whitespace inside is ignored.| Variant | Alphabet | Notes | Used by |
|---|---|---|---|
| Ascii85 (Adobe) | ! to u | <~ ~> markers, z for zeros | PDF, PostScript |
| Ascii85 (btoa) | ! to u | No markers; the original btoa tool also used y for four spaces | Old Unix tools |
| Z85 | 0–9 a–z A–Z + .-:+=^!/*?&<>()[]{}@%$# | Input must be a multiple of 4 bytes; avoids quotes and backslash | ZeroMQ, CurveZMQ keys |
| RFC 1924 / Git | 0–9 A–Z a–z + !#$%&()*+-;<=>?@^_`{|}~ | Different alphabet from Ascii85 | git diff --binary, Python b85encode |
Z85 was designed to be safe inside source code strings: it leaves out ", ' and \. Its specification is ZeroMQ RFC 32, which also gives the reference example: the 8 bytes 86 4F D2 6F B5 59 F7 5B encode to the string HelloWorld.
ASCII85Decode filter.For JSON, URLs and HTTP headers, Base64 or Base64URL are usually the safer choice, because Base85 output can contain characters that need escaping there.
import base64 base64.a85encode(b'Man ') # b'9jqo^'base64.a85encode(b'Man ', adobe=True) # b'<~9jqo^~>'base64.a85decode(b'<~87cURDZ~>', adobe=True) # b'Hello' base64.b85encode(b'Hello') # RFC 1924 / Git alphabet (not Ascii85)base64.z85encode(b'Hi!!') # Python 3.13+: b'nnfj<'# GNU coreutils basenc supports Z85echo -n 'Hi!!' | basenc --z85 # nnfj<"Not a valid Ascii85 character"
Ascii85 only uses characters from ! to u, plus z. Letters v to y, {, |, } and ~ (outside the ~> marker) mean the value is a different variant, often Z85 or the Git alphabet. Switch the Variant option.
"z can only stand for a whole group"
A z appeared in the middle of a 5-character group. In Ascii85, z is a shortcut for four zero bytes and is only valid between groups. The data is probably not Ascii85, or it was damaged.
"Z85 only encodes data whose length is a multiple of 4 bytes"
Z85 has no padding rule. Pad the input to a multiple of 4 bytes before encoding (and remember to strip the padding after decoding), or use Ascii85, which handles any length.
Python b85decode fails on data from a PDF
b85decode uses the RFC 1924 alphabet. PDF and PostScript use Ascii85, so call base64.a85decode(data, adobe=True) instead.
Base85 data breaks inside JSON, XML or a shell command
Ascii85 can contain ", \, < and &, which those formats treat specially. Escape the value, use Z85 (no quotes or backslash), or switch to Base64.
Ascii85 is the most common Base85 variant. "Base85" is the general idea (4 bytes into 5 characters); Ascii85, Z85 and the Git/RFC 1924 alphabet are specific versions with different characters.
Base85 packs 4 bytes into 5 characters (25% overhead), while Base64 packs 3 bytes into 4 characters (33% overhead). The bigger alphabet carries more information per character.
They are the start and end markers Adobe uses for Ascii85 in PostScript and PDF. The data is only what sits between them.
Use Adobe Ascii85 for PDF or PostScript, Z85 for ZeroMQ or when the result goes into source code, and Base64 for web APIs, JSON and URLs.
No. Encoding and decoding run entirely in your browser.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.