Start Here

How to convert an image to Base64 on a Mac

You can do this with B64, on your own machine, with nothing pasted into a website. Here is where the Base64 comes out, how to choose the shape you need it in, and what to do when the file is very large.

You have an image and something downstream wants it as text: a JSON field, an HTML email, a stylesheet that has to travel on its own, a configuration file, a test fixture. Base64 is how a picture becomes text without losing a byte — and you would rather not paste a private screenshot into a web form to get it.

This guide covers encoding an image in B64: where the result appears, the five shapes it can come out in, how to copy or export it, and how a very large file is handled.

Note

Every conversion happens on your Mac, inside the app. Nothing is uploaded, there is no account, and no usage is reported — which matters if the picture holds a customer's details, an unreleased asset or a signed document.

What Base64 actually does to your image

Base64 is not compression and it is not a format conversion. It re-expresses the exact bytes of your file using 64 printable characters, so the result can live anywhere text can live. Nothing is lost: decode it again and you get the identical file back, down to its EXIF data and its checksum.

The cost is size. Three bytes become four characters, so a Base64 string is always about 33% larger than the file it encodes, plus a little for line breaks. A 1,8 MB photograph becomes roughly 2,4 MB of text. The Inspector shows you the exact figure for your file, which matters when the destination has a size limit.

Encode an image

  1. Open the Encode workspace

    Click Encode in the sidebar, or press ⌘1. The workspace says Image → Base64 under its title, so you can always tell which direction you are pointing.

  2. Load your image

    Three ways in, and they are all equivalent. Drag the file from the Finder onto the Encode area. Click Choose File… (⌘O) and pick it. Or copy an image anywhere on your Mac and click Paste Image (⇧⌘V) — useful when the picture only exists on the clipboard and you would otherwise have to save it first.

    PNG, JPEG, HEIC, HEIF, GIF, TIFF, BMP, WebP, SVG and PDF are all accepted.

  3. Choose the output format

    The menu above the result switches between Plain Base64, Data URI, HTML, CSS Background and Markdown. Pick the one that matches where the string is going and the result is rewritten immediately — you never re-encode to change format.

  4. Copy it or export it

    Copy (⇧⌘C) puts the complete result on the clipboard. Export… (⌘E) writes it to a .txt file. Both always use the whole string, even when the display is showing it in pages.

Which output format do you want?

This is the only decision that really matters, and it is decided entirely by where the string is going.

The five output formats and where each one belongs
FormatWhat you getUse it when
Plain Base64The raw string, nothing around itA JSON field, an API payload, a config file, a test fixture
Data URIdata:image/png;base64,…A browser address bar, an href, or anywhere a URL is expected
HTMLA complete <img src="data:…"> tagAn email template or a single-file page with no second request
CSS BackgroundA background-image: url("data:…") ruleA stylesheet that has to carry its own assets
Markdown![alt](data:…)A README, a spec or a doc that must stay self-contained

If you are not sure, Data URI is the most portable of the five: it carries its own MIME type, so whatever reads it knows what kind of picture it is without being told.

Line wrapping

Plain Base64 can be wrapped at 64 or 76 columns, or left as one unbroken line. Seventy-six is the MIME line length, which is what most standards-minded tools and mail systems expect; sixty-four is the older PEM-style width and shows up in certificates and key files.

Wrapping is offered for plain output only. In a data URI, an <img> tag, a CSS rule or a Markdown reference a stray newline would break the thing you are producing, so the control is disabled rather than allowed to produce something invalid. Set the default you usually want in B64 ▸ Settings… ▸ General so you do not have to change it every time.

Reading the result

Three numbers sit under the result and they are the ones worth glancing at.

  • Character count. How long the string is. If the destination has a field limit, this is the number to compare against.
  • Size. How much text that is, in kilobytes or megabytes.
  • Page indicator. Only on very long results — see below.

Open the Inspector with ⌥⌘I for the rest: the source file's name, size, kind and MIME type, its pixel dimensions, the character count, the size overhead as a percentage, and a one-click SHA-256 checksum of the file you encoded.

Very large images

A result of several million characters is not something any window should try to render at once, so B64 shows it in pages and tells you it is doing so. Scrolling stays smooth, and Copy and Export still take the complete string — the paging is a display choice, never a truncation.

Above a certain size the app offers to encode straight to a file instead of holding the result in memory. Accept it: you get the same bytes written directly to disk, and the app never has to build a hundred-megabyte string just so you can look at the first screen of it.

Tip

If you know the result is going into a file anyway, use Export… rather than Copy. It skips the clipboard entirely, which is the slow part when a string runs to millions of characters.

Encoding more than one image

Encoding files one at a time is fine for one or two. For anything more, switch to Batch (⌘3), drop in a folder, and every image in it becomes its own Base64 text file in a single pass — with a list of anything that was skipped and why. See how to convert a folder of images to Base64.

Troubleshooting

The file was refused

Encode takes images and PDFs. A file that macOS does not read as either — a zip, a video, a spreadsheet — is not accepted, and a file with a misleading extension is judged on its actual bytes rather than its name. If a file you believe is an image is refused, the bytes are not what the extension claims.

The result looks shorter than I expected

Check the character count rather than the scrollbar. A long result is shown in pages, so what is on screen is one page of several — the page indicator under the result says which. Copy and Export are unaffected.

I need it wrapped but the control is greyed out

You are on a format where line breaks are not legal. Switch the format menu to Plain Base64 and the wrapping control becomes available.

The string will not fit where I am pasting it

Base64 costs about a third more than the file it encodes, and the Inspector shows the exact overhead. If the destination has a hard limit, encode a smaller version of the image — the encoding itself has no lever to pull, because it is a faithful representation of the bytes you gave it.

What else you can do with the result

  • Check it round-trips. Paste the result into Decode and confirm the picture comes back. Decoding is free, so this costs nothing.
  • Prove it is the right file. The Inspector's SHA-256 checksum of the source, compared against the checksum of the decoded bytes, is the end of any argument about whether something arrived intact.
  • Keep it. Export… writes a .txt file you can commit, attach or archive.

Frequently asked questions

Where does the Base64 appear?

In the right-hand pane of the Encode workspace, the moment the image loads. There is no convert button to press — loading the file is the conversion.

Does encoding change or re-compress my image?

No. Base64 is a faithful re-expression of the exact bytes of the file, so the image itself is untouched — same pixels, same compression, same metadata. Decoding the result anywhere reproduces the original file byte for byte.

Why is the Base64 bigger than my image?

Because three bytes of file become four characters of text. The result is always about 33 per cent larger, plus a little more if you wrap it. The Inspector shows the exact overhead for your file.

Can I encode a PDF?

Yes. PDFs encode exactly like images do, and come back out of Decode as the same document. See the guide on converting a PDF to Base64.

Is encoding free?

Decoding is free forever. Encoding and Batch are unlocked with a single one-time purchase, with no subscription, tied to your Apple Account across every Mac you own.