How to decode Base64
- Paste the Base64 string into Input. Line breaks and spaces are ignored, so MIME and PEM style Base64 split over many lines works as is.
- If the data is text, the decoded text appears in Output straight away.
- If it's a file, you'll see its type, a preview for images and PDFs, and a Download button that saves it with the right extension.
For example, SGVsbG8sIHdvcmxkIQ== decodes to Hello, world!, and Y2Fmw6k= decodes to café, because the bytes are read as UTF-8.
Base64 to image
Images embedded in HTML, CSS or JSON usually come as a data URL such as data:image/png;base64,iVBORw0KGgo…. Paste the whole thing: the data:…;base64, prefix is removed for you. PNG, JPEG, GIF and WebP images are shown as a preview and can be downloaded as a real image file.
Base64 to PDF
APIs often return documents such as invoices and labels as a Base64 field in JSON. A PDF in Base64 starts with JVBERi0, which is %PDF- encoded. Paste the value without the surrounding quotes and the PDF opens in the preview, ready to download as decoded.pdf.
Recognise the data by its first characters
| Base64 starts with | Decoded data |
|---|---|
iVBORw0KGgo | PNG image |
/9j/ | JPEG image |
R0lGOD | GIF image |
JVBERi0 | PDF document |
UEsDB | ZIP archive, or a .docx, .xlsx or .jar file |
H4sI | gzip-compressed data |
eyJ | JSON starting with {", for example a JWT header (use the JWT decoder for tokens) |
Decoding Base64 in code
When you need the same result in a program or script:
// JavaScript (browser), UTF-8 safe
const bytes = Uint8Array.from(atob(b64), c => c.charCodeAt(0));
const text = new TextDecoder().decode(bytes);
// Node.js
const text = Buffer.from(b64, 'base64').toString('utf8');
// Java
byte[] bytes = Base64.getDecoder().decode(b64);
String text = new String(bytes, StandardCharsets.UTF_8);
// Python
import base64
text = base64.b64decode(b64).decode('utf-8')
# Linux and macOS shell
echo 'SGVsbG8=' | base64 --decode
base64 --decode input.txt > output.pdf For Base64URL (with - and _), use Base64.getUrlDecoder() in Java and base64.urlsafe_b64decode in Python. Java's getDecoder() rejects line breaks; use getMimeDecoder() for Base64 split over lines.
Common errors
- Invalid characters: the input contains something other than A–Z, a–z, 0–9,
+,/,-,_and=. Often it's JSON quotes or an escaped\/copied along with the value. - Incomplete Base64: the string was cut off. Missing
=padding is fine and is added for you, but a length that leaves one stray character can't be decoded. - Garbled text: the original wasn't UTF-8 text. Binary data is shown as hex instead of as broken characters.
Frequently asked questions
Is Base64 encryption?
No. Base64 only changes how bytes are written as text. Anyone can decode it, so never rely on it to hide passwords or tokens.
Is my data uploaded?
No. Decoding, the image and PDF preview and the download all happen in your browser. Nothing is sent to our server.
Can I decode a data URL?
Yes. Paste the full data:image/png;base64,… value and the prefix is stripped before decoding.
Why does the output show hex instead of text?
The decoded bytes are a file or other binary data, not UTF-8 text. The tool shows the first bytes as hex, says what type of file it looks like and lets you download it.
How do I encode a file to Base64?
Switch to Encode and click File to Base64. Files up to 10 MB are read in your browser and the Base64 appears in the output.
Related tools
Encode / Decode for Base64URL, hex and HTML entities, JWT decoder, URL encoder and decoder, JSON escape and unescape and hash generator.