Encoding images & PDFs

How to convert a PDF to Base64 on a Mac

You can do this with B64, on your own machine, which is the part that matters when the document is a signed contract. Here is how, and what to expect from the round trip.

PDFs get encoded for the same reasons images do — an API field that takes a document as a string, an email payload, a record stored inside a larger structure — but with one difference that matters more than any technical detail: the documents people encode tend to be the ones they cannot afford to upload to a stranger's website.

This guide covers encoding a PDF in B64, which happens entirely on your Mac.

Nothing leaves your Mac

There is no server, no account and no telemetry. A signed contract, an invoice with bank details on it or an unpublished report is converted in the app on your machine.

Encode a PDF

  1. Open Encode

    Click Encode in the sidebar or press ⌘1.

  2. Load the document

    Drag the PDF onto the Encode area, or click Choose File… (⌘O). The whole document is encoded — every page, in one string.

  3. Pick the output format

    Plain Base64 for a JSON field or an API payload. Data URI when the consumer expects a URL; the type declared is application/pdf.

  4. Copy or export

    Export… (⌘E) is usually the better choice here — documents are big, and writing straight to a .txt file avoids pushing several megabytes through the clipboard. Copy is ⇧⌘C.

The whole document, not a page of it

Encoding a PDF encodes the file. There is no page selection, because there is no rendering step — a fifty-page report is one string, and decoding it gives you the fifty-page report back. Everything inside comes with it: embedded fonts, form fields, attachments, bookmarks, and any digital signature.

Signatures survive, because the bytes do

A digitally signed PDF stays valid through a Base64 round trip, because the signature covers the bytes and the bytes are unchanged. That is not true of anything that re-renders or re-saves the document.

Size

Base64 adds about a third. Documents are frequently larger than people expect — a scanned contract is a sequence of images, and a report with photographs in it carries them at full resolution.

What Base64 costs a typical document
Source PDFBase64 result
A 2-page text-only letter, 90 kB≈ 120 kB of text
A 20-page report with figures, 3 MB≈ 4 MB of text
A scanned 40-page contract, 18 MB≈ 24 MB of text

At the top of that range, use Export… rather than Copy, and let B64 encode straight to a file when it offers to. See encoding large files.

Getting the document back

Paste the string into Decode and the PDF is recognised and recovered. Save… writes it back to disk as a PDF, byte for byte identical to the one you started from.

The Inspector (⌥⌘I) gives you a SHA-256 of the source and of the decoded bytes. For a document that matters, comparing those two values is the only proof that really settles the question of whether it arrived intact.

A folder of documents

Batch (⌘3) takes a folder of PDFs and encodes every one in a single pass, each to its own text file, with an optional checksum manifest covering the whole run. How to create a checksum manifest.

Troubleshooting

The PDF was refused

A file named .pdf whose bytes are not a PDF is judged on the bytes. Open it and check what it really is.

The result is very large

Check the source size in the Inspector. A scanned document is a stack of images; the encoding adds a third to whatever that already was.

The decoded PDF will not open at the far end

Almost always a truncated payload. Compare the character count at both ends, or compare the SHA-256 of your source against the decoded bytes — if they differ, something in between cut the string.

Frequently asked questions

Can I encode just one page of a PDF?

No — encoding works on the file, so the whole document becomes one string. Extract the pages you want into a separate PDF first if you need a subset.

Does a digital signature survive Base64?

Yes. The signature covers the file's bytes and Base64 does not change them, so a signed PDF that is encoded and decoded is still validly signed.

Is my document uploaded anywhere?

No. Everything happens in the app on your Mac — no server, no account, no telemetry. That is what makes it reasonable to convert a contract this way at all.

What MIME type does a PDF data URI use?

application/pdf, which B64 writes for you.