Base64 Image Decoder for Mac: Preview, Save, Re-encode
Decode a Base64 image on a Mac without a website: Terminal one-liner, or Bytepliers to preview a data URI, save the file or re-encode it.
GuideUpdated 7 min read
On this page
You have a long string that starts with data:image/png;base64, or iVBORw0KGgo, and you want the actual picture without pasting it into a random website. Online decoders work, but you paste, wait and download for every image, and your data goes to someone else's server unless the site says it decodes locally. A local route avoids both.
What a Base64 image string looks like
Base64 images usually arrive in one of three shapes:
- A data URI:
data:image/png;base64,iVBORw0KGgo... - A CSS value:
background-image: url("data:image/svg+xml,...") - Raw Base64 with no prefix at all.
The data URI format is defined in data:[<mediatype>][;base64],, where the appearance of ;base64 means the data is Base64-encoded. The prefix tells you the format. With raw Base64, the first characters usually give it away:
| Starts with | Format |
|---|---|
iVBORw0KGgo | PNG |
/9j/ | JPEG |
R0lGOD | GIF |
PHN2 or PD94bWw | SVG (text starting <sv or <?xml) |
Pick the output file extension to match. Apps open the file by extension, so a JPEG saved as image.png can confuse them.
Why a plain base64 command often fails
Most "it doesn't decode" problems come from the same few causes, most common first:
- The prefix is still on the string. The
base64command decodes raw Base64 only. As MDN notes for data URLs, the result cannot be decoded as Base64 without first removing the Data-URL declaration in front of the data. - The string was damaged when copied. A trailing quote, an ellipsis, a line of surrounding code or a truncated paste breaks the decode.
- It's URL-safe Base64. That variant omits the padding and replaces
+and/with-and_. A standard decoder can reject it. - It isn't Base64 at all. Percent-encoded SVG and other text data URIs need a different decoder.
- You can't see the result until you save it. Terminal writes bytes to a file, so you only find out the data was wrong when the file won't open.
Fix 1: decode with Terminal (built in)
macOS ships a base64 command, so there is nothing to install.
- Copy the whole string (data URI or raw Base64) to the clipboard.
- Open Terminal.
- Run this, changing
pngto match the format:
pbpaste | sed 's/^data:[^,]*,//' | base64 -D > image.png- Open the result:
open image.pngpbpaste prints the clipboard, sed strips a leading data:..., prefix if there is one (raw Base64 passes through untouched), and base64 -D decodes the rest into the file.
If the string is in a text file instead of the clipboard:
sed 's/^data:[^,]*,//' encoded.txt | base64 -D > image.pngTo check what you decoded, run file image.png. It reports the real type (PNG, JPEG and so on). If it says "data" or "ASCII text", the string wasn't valid Base64 or the prefix wasn't removed.
For URL-safe strings, convert the two characters first:
pbpaste | tr '_-' '/+' | base64 -D > image.pngIf the = padding was dropped, add it back until the length is a multiple of 4. The base64url variant is described in section 5 of RFC 4648.
If your Mac's base64 doesn't accept -D, try -d. Options differ between macOS versions.
Fix 2: preview, save or re-encode in Bytepliers
The Base64 Image tool in Bytepliers takes a data URI, a CSS url() or raw Base64, shows the picture, and saves or re-copies it. You don't strip prefixes or pick a format yourself. It needs macOS 14 Sonoma or later.
- Copy the string.
- Open Bytepliers and choose Base64 Image under Encode in the sidebar. Or press ⌘K (Command-K) and type "base64 image".
- Paste into the Base64 / Data URI input with ⌘V.
- Check the Preview. The image sits over a checkerboard, so transparency is visible, and the format and size are shown.
- Click Save… (⌘S) to write the file. Copy Data URI and Copy CSS url() put a clean value back on the clipboard.
The tool detects PNG, JPEG, GIF, WebP, BMP, ICO, TIFF, HEIC/AVIF, PDF and SVG, including percent-encoded SVG. That helps when you don't know what a blob of text is until you see it.
Let the clipboard find the tool
Bytepliers lists "Base64 image" among the clipboard kinds it recognises. Clipboard matches is off by default. Turn it on under Settings ▸ General ▸ Clipboard, or press ⇧⌘K (Shift-Command-K) after copying to check on demand. Details are in the clipboard detection docs.
Go the other way: image to data URI
Drop an image onto the tool or click Encode Image… (⌘O), then click Copy Data URI or Copy CSS url(). Image files are capped at 10 MB; a larger file is refused with "File is … — the limit is 10 MB."
Keep the size cost in mind. A Base64 version of a file is typically roughly a third larger than its source, so inlining big images in CSS or HTML is rarely a good idea. The data URI spec itself calls the scheme "only useful for short values".
Which method to use
| Terminal | Bytepliers Base64 Image | |
|---|---|---|
| Preview before saving | No (open the saved file) | Yes |
| Choose the format yourself | Yes (output file name) | No, it detects it |
Reads CSS url() values | Not directly | Yes |
| Percent-encoded SVG | No | Yes |
| Re-encode an image | Separate command | Drop it or Encode Image… |
| Many images at once | Yes, with a loop | No batch mode |
| Cost | Free, built in | Part of MacSuite |
If you decode an image now and then and already know its format, Terminal is enough. Bytepliers helps when you want to look before saving, when the input is a CSS value, or when you don't know what the string is.
Decode many images
Bytepliers has no batch mode for this tool; it handles one image at a time. For a pile of files, a Terminal loop does the work. This assumes each string is in its own .txt file and every image is a PNG:
for f in *.txt; do sed 's/^data:[^,]*,//' "$f" | base64 -D > "${f%.txt}.png"; doneIt writes name.png beside each name.txt, and it overwrites any existing PNG with the same name. If the images are mixed formats, sort them into one folder per format first and change the extension in the command.
Checklist before you try again
- The whole string is copied, with no trailing quote, ellipsis or surrounding code.
- You know whether it's standard Base64, URL-safe Base64 or percent-encoded text.
- The output file extension matches the format.
- You're writing to a new file name, not over one you want to keep.
- For Bytepliers on macOS 15.4 or later, you pasted into the input or pressed ⇧⌘K, rather than waiting for automatic detection.
If nothing works
- No preview in Bytepliers. The string is usually cut off or carries stray characters. Copy it again from the source and paste it on its own.
- Bytepliers doesn't pick up the clipboard on its own. Clipboard matches is off by default. On macOS 15.4 or later, automatic checks are skipped when the app's paste access is set to Ask or Deny. ⇧⌘K and pasting into the input still work.
- Dropping an image is refused. Files over 10 MB are refused. Encode those in Terminal with
base64 -i big.png > big.txt. - The Terminal file won't open. Run
file image.pngand rename it to the type it reports.
If the string is valid but the app still fails, contact support through the MacSuite support page. Include the exact message you see, your macOS version, the first 20 characters of the string (not the whole thing if it's private), and the steps you tried.
Subject: Base64 Image tool won't preview my string
Hi, I pasted a Base64 string into the Base64 Image tool in Bytepliers
and nothing shows in the preview.
macOS version: (your version)
Bytepliers version: (Bytepliers > About)
String starts with: (first 20 characters)
Approximate length: (characters)
Message shown: (exact text, or "none")
Already tried: copying again from the source, pressing Shift-Command-K,
decoding in Terminal with base64 -D.Common questions
Does Bytepliers send my image anywhere?
No. The Base64 Image tool doesn't use the network, and the app has no telemetry. The app's own network use is license checks and update checks, plus requests you explicitly send from other tools.
Does it work during the trial?
Yes. Every tool works for 7 days without a key. Bytepliers is part of MacSuite, a one-time $349 purchase as of November 2026. More on the Bytepliers page.
Can it decode a PDF or other non-image data?
The tool detects PDF alongside the image formats. For other binary data, the Hex ↔ ASCII or Base64 tools may fit better. See how to encode and decode Base64 on Mac.
Why does the data URI start with data:image/png;base64,?
That's the data URL syntax: scheme, media type, the ;base64 marker, then a comma and the data. MDN's data URL reference covers the format and its common problems.
Which should you pick?
Use Terminal if you decode images occasionally and know the format. Use the Base64 Image tool in Bytepliers when you want to see the image first, need to read CSS url() values or percent-encoded SVG, or want to turn an image back into a data URI. It handles one image at a time, and it's part of MacSuite, which you can try free for 7 days.