---
source: https://iinventedlight.com/library/notes/go-encoding-ascii85.md
title: "Go encoding/ascii85: encode binary data as used in PostScript and PDF"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Go Authors, encoding/ascii85; The Go Authors, ascii85.go (source). BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-encoding-ascii85"
tags: [go, ascii85, encoding, pdf, postscript]
client: Librarian
sources:
  - id: S1
    title: "encoding/ascii85"
    publisher: The Go Authors
    url: https://pkg.go.dev/encoding/ascii85
    accessed: 2026-11-26
    license: "BSD-3-Clause"
  - id: S2
    title: "ascii85.go (source)"
    publisher: The Go Authors
    url: https://go.dev/src/encoding/ascii85/ascii85.go
    accessed: 2026-11-26
    license: "BSD-3-Clause"
---
# Go encoding/ascii85: encode binary data as used in PostScript and PDF
**Answer:** The ascii85 package implements the encoding used by the btoa tool and by Adobe PostScript and PDF document formats.

## Encode and decode

Decode returns a CorruptInputError plus the number of bytes successfully written when src contains invalid ascii85 data.

Often, ascii85-encoded data is wrapped in <~ and ~> symbols.

Decode expects these wrappers to have been stripped by the caller. Encode does not add these.

Decode ignores space and control characters in src.

If flush is true, Decode assumes src is the end of the input stream and processes it completely rather than wait for another 32-bit block.

## Stream helpers

The encoding handles 4-byte chunks and uses a special encoding for the last fragment, so Encode is not appropriate for individual blocks of a large data stream.

Use NewEncoder instead.

MaxEncodedLen returns the maximum length of an encoding of n source bytes.

NewDecoder constructs a new ascii85 stream decoder.

NewEncoder returns a stream encoder. Bytes written to that writer are encoded, then written to w.

## See also

- [go-pem](https://iinventedlight.com/library/notes/go-pem/)
- [go-encoding-base64](https://iinventedlight.com/library/notes/go-encoding-base64/)
- [go-encoding-asn1](https://iinventedlight.com/library/notes/go-encoding-asn1/)

## Claims

- id: C1
  claim: Decode skips spaces and control characters in its input.
  source: S1
  evidence: "Decode ignores space and control characters in src."

- id: C2
  claim: Callers often wrap ascii85 data in <~ and ~> markers.
  source: S1
  evidence: "Often, ascii85-encoded data is wrapped in <~ and ~> symbols."

- id: C3
  claim: The source package comment names the btoa tool and Adobe PostScript and PDF formats.
  source: S2
  evidence: "as used in the btoa tool and Adobe's PostScript and PDF document formats."

## Sources

- [S1] encoding/ascii85. The Go Authors. https://pkg.go.dev/encoding/ascii85 . License: BSD-3-Clause. Accessed 2026-11-26.

- [S2] ascii85.go (source). The Go Authors. https://go.dev/src/encoding/ascii85/ascii85.go . License: BSD-3-Clause. Accessed 2026-11-26.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, encoding/ascii85; The Go Authors, ascii85.go (source). BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
