How to encode a large image to Base64 on a Mac
You can do this with B64 without the window stalling. Here is what happens to a very large file and which route to take.
A forty-megapixel photograph, a scanned contract, a multi-page press kit. At these sizes the result runs to several million characters, which is more than any text view should be asked to lay out at once.
This guide covers what B64 does instead.
What happens with a large source
- The result is shown in pages. A result too long to display comfortably is paged, with an indicator telling you so. Scrolling stays smooth because the window is never asked to lay out the whole string.
- Copy and Export are unaffected. They always take the complete result, whichever page is on screen. Paging is a display choice, never a truncation.
- Above a threshold, you are offered a direct write. B64 can encode straight to a file rather than building the whole string in memory first.
If the result is going into a file anyway, writing it straight to disk skips the memory and the clipboard entirely. It is the fastest route and the one that scales.
The route to take
Load the file
Drag it in or press ⌘O. Loading is not where the time goes.
Set the format before you do anything else
Switching format rewrites the result. On a very large file, decide first.
Export rather than copy
⌘E writes the complete result to a
.txtfile. For anything above a few megabytes this beats pushing the string through the clipboard.Check the numbers
The Inspector (⌥⌘I) gives you the character count and the overhead. That is what you compare against whatever limit you are working to.
Ask whether it should be embedded at all
It works. The question is whether a ten-megabyte payload is the right shape for its destination. An embedded asset is downloaded with every copy of the document that carries it and cannot be cached separately.
| Source size | Usually |
|---|---|
| Under 100 kB | Embed without thinking about it |
| 100 kB – 1 MB | Embed if it must not go missing |
| 1 – 10 MB | Think hard; often better as a file |
| Over 10 MB | Almost always better as a file |
When the payload has to exist regardless — an API that takes a document as a string, an archive format, a transfer — none of that applies and the size is simply the size.
Reducing it, if you can
There is no compression setting in Base64. Every lever is on the source file: crop it, resize it, re-compress it, or pick a format that suits the content. See how to see how much bigger Base64 makes a file.
Many large files
Batch (⌘3) streams results to disk rather than accumulating them, which is what lets a folder of large sources go through in one pass. See how to batch convert thousands of images.
Troubleshooting
I can only see part of the result
It is paged. Check the character count in the Inspector against what you expect, and remember Copy and Export take all of it.
Copying is slow
Several megabytes through the clipboard is slow everywhere. Use Export… instead.
The destination rejected the payload
Compare the character count with its limit. If it is over, the source file has to get smaller — there is nothing in the encoding to adjust.
The file was refused
Size is not the reason. A file is refused when its bytes are not an image or a PDF, whatever the extension says.
Frequently asked questions
Is there a size limit?
No fixed one. Very large results are shown in pages so the window stays responsive, and above a threshold the app offers to encode straight to a file rather than holding the whole string in memory.
Does paging truncate my result?
No. Paging is only how the result is displayed. Copy and Export always take the complete string.
Should I copy or export a large result?
Export. Pushing several megabytes through the clipboard is slow, and if the destination is a file anyway the clipboard is a detour.
How do I make a large payload smaller?
Work on the source file — crop, resize, re-compress or change format. Base64 output length is a fixed function of input length.