Output formats

How to wrap Base64 at 64 or 76 columns on a Mac

You can do this with B64 from the control beside the format menu. Here is what each width is for and why some formats will not let you.

Base64 can come out as one enormous line or as a block of neat, even lines. Both decode to exactly the same bytes — the line breaks are ignored — so which one you want depends entirely on what is going to read it.

This guide covers the wrapping control in B64 and when to use each setting.

Turn wrapping on

  1. Set the format to Plain Base64

    Wrapping is a plain-output feature. Pick Plain Base64 from the format menu and the wrapping control beside it becomes available.

  2. Choose a width

    Off, 64 columns or 76 columns. The result is rewritten immediately, so you can see what each one looks like.

  3. Copy or export

    Copy (⇧⌘C) and Export… (⌘E) both preserve the wrapping you chose.

To stop choosing every time, set the width you normally want as the default in B64 ▸ Settings… ▸ General.

Why 76, and why 64

The two standard widths
WidthComes fromYou will meet it in
76 columnsThe MIME specification Base64 was defined inEmail bodies and attachments, and anything written to MIME conventions
64 columnsThe older PEM family of conventionsCertificates, keys and similar text-armoured formats
OffNothing in particularJSON fields, config values, data URIs — anywhere a newline would be a nuisance

Both numbers are chosen so a line plus its break fits comfortably inside the 80-character terminals and mail systems of the era in which they were defined. The conventions outlived the constraint because the systems that expect them outlived it too.

When wrapping is not offered

The control is disabled on Data URI, HTML, CSS and Markdown. That is deliberate rather than an omission: a line break inside any of those breaks the thing you are producing.

Where wrapping is legal

Wrapping is legal where the Base64 stands on its own and the reader is a decoder that skips whitespace. It is not legal where the Base64 is inside a URI, an attribute value or a CSS value, because those are parsed by something that does not skip newlines.

If a destination insists on wrapped lines, it wants plain wrapped Base64 rather than a data URI. If it insists on a data URI, it wants one unbroken line.

Wrapping does not change the data

A decoder ignores whitespace, so the wrapped and unwrapped forms of the same file produce identical bytes. You can prove it in B64: encode a file wrapped, decode the result, and compare the SHA-256 in the Inspector against the source. Then do it unwrapped. Same checksum both times.

The one thing wrapping does change is the length of the text: each line break is an extra character or two. At 76 columns that is roughly 1,3% on top of the 33% the encoding already costs.

Reading wrapped Base64 that arrives from elsewhere

You do not have to unwrap anything. Paste a wrapped payload into Decode exactly as it came and the picture appears — whitespace and line breaks are skipped.

Troubleshooting

The wrapping control is greyed out

You are on a format where line breaks are not legal. Switch to Plain Base64.

The consumer at the far end rejects my wrapped payload

Some strict parsers accept only unwrapped input, or only one specific width. Try Off first; if it still complains, the width is probably the issue and 76 is the convention most tools assume.

My wrapped output lost its line breaks

Something between here and there normalised the whitespace — a form field, a chat client, a JSON encoder. Export to a .txt file instead of copying, and move the file.

Frequently asked questions

Does wrapping change the decoded file?

No. Decoders ignore whitespace, so wrapped and unwrapped Base64 of the same file produce identical bytes.

Why is 76 the standard width?

It comes from the MIME specification that Base64 was defined in, chosen so a line plus its break fits inside the line limits of the mail systems of the time.

What is the 64-column option for?

The older PEM family of conventions — the width you see in certificates and key files.

Why can I not wrap a data URI?

A newline inside a data URI invalidates it. The same is true inside an HTML attribute, a CSS value or a Markdown reference, which is why the control is disabled on those formats.