How to convert a JPG to Base64 on a Mac
You can do this with B64, on your own machine. Here is how, what happens to the JPEG compression and the EXIF data, and why photographs are the case where size deserves a second thought.
JPEG is the photograph format, which makes it the one where Base64's overhead is most noticeable — a photograph is already a few megabytes before you add a third. It is also the format most often encoded for a good reason: a picture that has to travel inside a payload, an email, or a document that must not depend on a server still being there next year.
This guide covers encoding a JPEG in B64, what survives the trip, and how to read the size numbers before you paste the result somewhere.
The conversion runs in the app, on your Mac. Nothing is uploaded and there is no account, so a picture that should not leave the building does not have to.
Encode a JPEG
Open Encode
Click Encode in the sidebar or press ⌘1.
Load the photograph
Drag it from the Finder onto the Encode area, click Choose File… (⌘O), or press ⇧⌘V to encode a copy already on your clipboard.
Both
.jpgand.jpegare the same format and behave identically.Pick the output format
Data URI is the most portable; HTML gives you a finished
<img>tag; Plain Base64 is what a JSON field or a config file wants.Copy or export
Copy (⇧⌘C), or Export… (⌘E) for a
.txtfile — which is usually the better choice at photograph sizes.
The photograph is not re-compressed
A JPEG is already lossily compressed, and every extra save costs a little more quality. That does not happen here. B64 reads the file's bytes and re-expresses them; it never decodes the image and re-encodes it. There is no quality setting in the app because there is no re-encoding to apply one to.
Everything inside the file survives: the exact compression, the colour profile, the thumbnail, and the EXIF block with its camera model, timestamps, orientation and — if the photograph was taken on a phone with location on — its GPS coordinates.
If you are embedding a photograph somewhere public, remember that the location and camera metadata go with it. Strip the metadata from the JPEG before you encode it if that matters; encoding will faithfully carry whatever is in the file you hand it.
Size, and when to think twice
Base64 adds about 33%. For a photograph that is a real number:
| Source JPEG | Base64 result | Roughly |
|---|---|---|
| 200 kB web photo | ≈ 267 kB of text | Fine to embed |
| 1,8 MB phone photo | ≈ 2,4 MB of text | Think about it |
| 8 MB camera original | ≈ 10,7 MB of text | Leave it as a file |
The Inspector (⌥⌘I) gives you the exact character count and the exact percentage for your file rather than the rule of thumb. If the destination has a field limit, that is the number to compare against.
When the number is too big, the answer is a smaller source image — the encoding itself has no dial. Export a smaller or more heavily compressed JPEG first, then encode that.
Copying and exporting the result
Copy (⇧⌘C) puts the complete string on the clipboard. Export… (⌘E) writes it to a .txt file. Both always use the whole result, even when a long one is displayed in pages.
If you find yourself doing this often, turn on copy after encoding in B64 ▸ Settings… ▸ General. Dropping the file then is the whole interaction — the result is on your clipboard before you have reached for a shortcut.
Recognising a JPEG payload
Every JPEG Base64 string starts /9j/. It is a useful thing to know when you are staring at a payload in a log or a config file and want to know what it is before decoding it — though pasting it into Decode answers the question faster and for free.
Troubleshooting
The embedded photo is sideways
JPEG orientation lives in the EXIF block, and some consumers honour it while others do not. The encoding is faithful either way — the rotation flag is in the bytes. If the destination ignores it, rotate and re-save the JPEG so the pixels themselves are the right way up, then encode again.
The result is enormous
Check the source size in the Inspector. A camera original is several megabytes before encoding; a third on top of that is a lot of text to paste anywhere.
The string will not fit in the field
Encode a smaller version. There is nothing in Base64 to tune — the output length is a fixed function of the input length.
A folder of photographs
Batch (⌘3) encodes a whole folder in one pass, each result written as its own text file, with a checksum manifest if you want one. How to batch convert thousands of images.
Frequently asked questions
Does encoding a JPEG to Base64 reduce its quality?
No. B64 never decodes and re-encodes the image — it re-expresses the file's existing bytes as text, so there is no second lossy save and no quality setting to get wrong.
Is the EXIF data kept?
Yes, entirely. EXIF is part of the file's bytes, so camera model, timestamps, orientation and any GPS coordinates are carried into the Base64 and come back when it is decoded. Strip them from the JPEG first if that matters.
Why does JPEG Base64 always start with /9j/?
Because every JPEG begins with the same marker bytes, and Base64 is deterministic.
How do I make the Base64 smaller?
Make the image smaller. Base64's length is a fixed function of the input length — about four characters for every three bytes — so the only lever is the source file.