How to use the Ascii85 encode / decode tool
- Under Operation, pick Encode to produce Ascii85 or Decode to read an Ascii85 block.
- Type or paste into the Text or encoded value box. When decoding, the <~ and ~> markers are optional as a pair.
- Select Convert. The Example button encodes Hello, world! so you can see the format.
- Read the Result box. Decoded bytes that are not UTF-8 text appear as a byte count and a hex dump.
- Select Copy, or Download after decoding to save the raw bytes as decoded.bin.
How Ascii85 encoding works
Ascii85 packs four bytes into five printable characters. The encoder reads four bytes as one 32-bit big-endian number and writes that number in base 85. Each of the five digits is added to 33, which gives characters from the exclamation mark (code 33) up to lowercase u (code 117).
The output is 25 percent larger than the input, against 33 percent for Base64. The price is an alphabet that includes quotes, angle brackets and the backslash, so Ascii85 text often needs escaping in JSON, XML or source code.
A worked Ascii85 example
The first four bytes of the sample are 48 65 6C 6C in hex, or the number 1,214,606,444. In base 85 that number has the digits 23, 22, 66, 52 and 49. Adding 33 to each gives the character codes 56, 55, 99, 85 and 82, which spell 87cUR.
The sample is 13 bytes long: three full groups give 15 characters and one byte is left over. A short final group is padded with zero bytes, encoded, and cut to one character more than its byte count, so the last byte becomes +T.
Hello, world!
→ <~87cURD_*#TDfTZ)+T~>What the Ascii85 encoder writes and the decoder accepts
Encoding reads your input as UTF-8 text and wraps the output in <~ and ~>. There is no file input. Decoding is relaxed about layout and strict about content.
- The <~ prefix and ~> suffix are removed when both are present. With only one of them the decode fails.
- Spaces, tabs and line breaks anywhere in the block are ignored, so wrapped data can be pasted as it is.
- A z between groups stands for four zero bytes, and the encoder writes it for such a group. A z inside a group is rejected.
- A final group of two, three or four characters yields one, two or three bytes. A final group of a single character cannot be decoded.
- A group whose value is above 4,294,967,295 is rejected, since it does not fit in four bytes.
Where Ascii85 is used, and its relatives
Adobe introduced this encoding in PostScript Level 2 as the ASCII85Encode filter, and PDF kept it as ASCII85Decode for carrying binary streams such as images and fonts in a text-safe form. Inside a PDF the stream normally ends with ~> but has no <~ at the start. Add the prefix or delete the suffix before you paste such a stream here.
Other base-85 schemes share the idea but not the alphabet. Z85 from ZeroMQ and the encoding used in Git binary patches pick different characters, so their output does not decode to the right bytes with this tool.
Frequently asked questions
Is Ascii85 the same as Base85?
Ascii85 is one member of the base-85 family. This tool implements the Adobe form: character codes 33 to 117, the <~ and ~> delimiters, and z for four zero bytes. Z85 and the RFC 1924 alphabet are different encodings.
Why does decoding stop with Invalid ASCII85 character?
Every character must have a code from 33 to 117, apart from a z between groups. The usual causes are a marker on one side only, a z in the middle of a group, or text from a different base-85 alphabet.
Can I decode binary data such as an image stream?
Yes. If the decoded bytes are not valid UTF-8, the Result box shows the byte count and the first 256 bytes in hex. Download saves all of the bytes as decoded.bin.
Is my Ascii85 data sent to a server?
No. The conversion is JavaScript that runs in the page, and the download is built from memory in your browser. The text you paste stays on your device.