How to decode Base64
- Paste the Base64 text into the left box. A full
data:image/png;base64,…URI works too, and so does Base64 that is split over many lines. - The decoded result appears on the right as you type. Text is read as UTF-8, so accents and emoji decode correctly.
- If the data is a file, you get its type, a preview for images and a Download button with the right extension (.png, .pdf…).
- If something is wrong, the message names the invalid character and its position. Press Select it to jump to it.
Standard Base64 (+ and /) and URL-safe Base64 (- and _) are both detected automatically, and missing = padding is added for you. To go the other way, use the Base64 encoder.
Base64 decode examples
These results come from the same code as the decoder above:
| Base64 input | Decoded | Notes |
|---|---|---|
SGVsbG8sIFdvcmxkIQ== | Hello, World! | Standard Base64 with = padding, 13 bytes |
Y2Fmw6kgY3LDqG1lIGJyw7tsw6ll | café crème brûlée | Accented letters (UTF-8, 2 bytes each), 21 bytes |
8J+Ri/CfjI0= | 👋🌍 | Emoji (UTF-8, 4 bytes each), 8 bytes |
eyJ1c2VyIjoiYWRhIiwicm9sZSI6ImFkbWluIn0 | {"user":"ada","role":"admin"} | URL-safe Base64 (base64url), no padding, 29 bytes |
SGVs⏎bG8= | Hello | Line break inside: ignored, 5 bytes |
And two inputs that can't be decoded:
SGVsbG8!IFdvcmxk: “Invalid character "!" at position 8.” The exclamation mark is not part of the Base64 alphabet.Zm9vY: “Base64 length is invalid: 5 characters leaves 1 extra character.” Five characters can't be a whole number of bytes, so part of the text is usually missing.
How Base64 decoding works
Base64 writes binary data with 64 safe characters. Each character stands for 6 bits, so 4 characters carry 24 bits, which is exactly 3 bytes. To decode Base64 manually:
- Look up each character's value:
A–Z= 0–25,a–z= 26–51,0–9= 52–61,+= 62,/= 63. - Write each value as 6 bits and join them.
- Cut the bits into groups of 8. Each group is one byte. Leftover bits at the end (marked by
=padding) are dropped.
Worked example, SGk=:
| Character | S | G | k | = |
|---|---|---|---|---|
| Value | 18 | 6 | 36 | padding |
| 6 bits | 010010 | 000110 | 100100 | – |
Joined: 01001000 01101001 00. The two full bytes are 72 and 105, which are “Hi” in ASCII; the last two zero bits are padding. Because 3 bytes become 4 characters, Base64 is about 33% larger than the data it carries.
Base64 to image, PDF or file
When the decoded bytes aren't text, the decoder identifies the file from its first bytes (its “magic number”) rather than trusting a label. You can often recognise a file from the start of its Base64:
| Base64 starts with | File type | Download as |
|---|---|---|
iVBORw0KGgo | PNG image | .png |
/9j/ | JPEG image | .jpg |
R0lGOD | GIF image | .gif |
UklGR… | WebP image (RIFF…WEBP) | .webp |
JVBERi0 | PDF document (%PDF-) | |
UEsDB | ZIP, DOCX or XLSX (PK…) | .zip |
PHN2Zy | SVG image (<svg) | .svg |
For example, this 92-character string decodes to a 68 bytes PNG image (a single transparent pixel): iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=. And JVBERi0xLjcK is the start of a PDF document. Images, including SVG, are previewed with an ordinary image tag, so scripts inside an SVG never run. PDFs, ZIP files and other types are offered as a download: check files from unknown sources before you open them.
How to decode a Base64 link or URL parameter
Base64 in links is usually URL-safe Base64 (also called base64url): + becomes -, / becomes _, and the = padding is often dropped, because +, / and = have special meanings in URLs. Paste just the encoded part, for example the value after ?data=. If you see %2B, %2F or %3D, the Base64 was also percent-encoded: decode it with the URL decoder first. A token made of three parts separated by dots is a JSON Web Token; the JWT decoder splits it and explains the claims.
Is Base64 encryption?
No. Base64 is an encoding: a reversible way to write bytes as text, with no key and no secret. Anyone who has the Base64 can decode it, exactly as this page does. That makes it safe for moving data around (email attachments, images in HTML or CSS, binary fields in JSON) but useless for hiding it. If you find passwords or API keys “protected” with Base64, treat them as exposed. Use real encryption (AES, or TLS in transit) for secrets, and a password hash such as bcrypt or Argon2 for passwords.
Decode Base64 in Python, JavaScript and the command line
Python (the base64 module):
import base64
base64.b64decode("SGVsbG8sIFdvcmxkIQ==").decode("utf-8") # 'Hello, World!'
s = "eyJ1c2VyIjoiYWRhIiwicm9sZSI6ImFkbWluIn0"
base64.urlsafe_b64decode(s + "=" * (-len(s) % 4)) # URL-safe, padding restoredJavaScript in the browser. atob() alone returns one character per byte, which garbles UTF-8 (“café” comes out as “café”), so decode the bytes with TextDecoder:
const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
const text = new TextDecoder().decode(bytes);Node.js: Buffer.from(b64, "base64").toString("utf8") (it also accepts URL-safe input).
Linux and macOS: echo 'SGVsbG8sIFdvcmxkIQ==' | base64 -d, or base64 -d image.txt > image.png for a file (older macOS versions use -D). Windows PowerShell: [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("SGVsbG8sIFdvcmxkIQ==")).
Related developer tools
- Base64 encoder: text, images and files to Base64 or a data URI.
- URL decoder: turn
%20,%3Dand other percent-escapes back into text. - JWT decoder: read a token's header, payload and expiry, and verify its signature.
- JSON formatter: pretty-print JSON you decoded from Base64.
Frequently asked questions
What is Base64 decoding?
Base64 decoding turns Base64 text back into the original bytes. Every 4 Base64 characters stand for 3 bytes: each character is looked up in the 64-character alphabet (A–Z, a–z, 0–9, + and /), which gives 6 bits, and the bits are regrouped into 8-bit bytes. Those bytes can be text (usually UTF-8), an image, a PDF or any other file.
Is Base64 safe to use?
Base64 is safe for what it is designed for: carrying binary data through systems that only handle text, such as email, JSON, HTML and URLs. It is not a security measure. Base64 is an encoding, not encryption, so anyone can decode it without a key. Never use it to hide passwords, API keys or personal data; encrypt those instead.
How can I decode a Base64 link?
Copy the Base64 part of the link (often a query parameter such as ?data=… or the text after "base64,") and paste it into the decoder. Links usually use URL-safe Base64 with - and _ and no = padding, which this decoder accepts. If the text contains %2B, %2F or %3D, it was also URL-encoded: run it through the URL decoder first, or the % signs will be reported as invalid characters.
How do I decode Base64 manually?
Write down the index of each character in the Base64 alphabet (A=0 … Z=25, a=26 … z=51, 0=52 … 9=61, + = 62, / = 63), convert each index to 6 bits, join all the bits and cut them into groups of 8. Each group is one byte. Each "=" at the end means the last group is incomplete and its extra zero bits are dropped. For example SGk= gives the bytes 72 and 105, which are "Hi" in ASCII.
How do I convert Base64 to an image or PDF?
Paste the Base64 (or the whole data:image/png;base64,… URI). The decoder reads the first bytes, the file's "magic number", to detect PNG, JPEG, GIF, WebP, SVG, PDF, ZIP and more, shows a preview for images and offers a download with the right file extension. The detection doesn't depend on the data URI's label, so a mislabelled file still gets the right extension.
Why do I get an "invalid character" error?
Base64 only uses A–Z, a–z, 0–9, + and / (or - and _ in the URL-safe variant), with = at the end. Anything else, such as %, a dot, a comma or a quote, is invalid, and the decoder tells you which character and its position so you can find it. Spaces and line breaks are fine: they are skipped. A % sign means the text was URL-encoded; dots usually mean it is a JWT, which has three Base64url parts.
What does "=" at the end of Base64 mean?
It is padding. Base64 turns every 3 bytes into 4 characters, so when the data is not a multiple of 3 bytes long the last group is padded with one "=" (2 bytes left over) or two "==" (1 byte left over). Padding is optional in many systems, especially URL-safe Base64 and JWTs, so this decoder adds any missing padding for you.
Why does the decoded text show strange characters like é or �?
é instead of é means UTF-8 bytes were read as Latin-1, which is what JavaScript's atob() does on its own. This decoder always reads text as UTF-8, so accents and emoji come out right. A � (replacement character) means the bytes are not valid UTF-8: the data is probably binary, such as an image, or text in an older encoding. Switch "Show as" to Hex to see the raw bytes.
Is my data uploaded when I decode Base64 here?
No. Decoding runs in JavaScript in your browser, and the text, the decoded file and any download never leave your device. Nothing is saved either; only your display options are remembered.