How the Base64 Decoder works
The decoder reads the input one character at a time. Spaces and line breaks are ignored, both the standard
(+ /) and URL-safe (- _) alphabets are accepted, and missing
= padding is added back automatically. If the input starts with a data URI header such as
data:image/png;base64,, the header is removed and its MIME type is remembered.
Any other character stops decoding with an error that gives its position (and line and column for multi-line input), so you can find a stray quote or a character damaged by copy and paste. Input that ends in the middle of a character group is reported as incomplete.
The decoded bytes are then checked. Valid UTF-8 text is shown in the output box. Bytes that are not valid UTF-8, contain null characters or start with the signature of a known file type (PNG, JPEG, GIF, WebP, PDF, ZIP or Gzip) are treated as a file: you get a Download decoded file button with a matching extension, and images are previewed.
How to use the Base64 Decoder
- Paste Base64 text or a data URI into the input box, open a text file that contains Base64, or select Load example.
- Select Decode Base64, or press Ctrl + Enter (Cmd + Enter on a Mac).
- If the result is text, it appears in the Decoded text box, ready to copy or download.
- If the result is binary data, select Download decoded file. Images are also previewed on the page.
- If the input contains an invalid character, the error message gives its position and the cursor moves to it.
Example
This input:
SGVsbG8sIFdvcmxkISBDYWbDqSDimJU=
is decoded to the text:
Hello, World! Café ☕
The URL-safe form without padding, SGVsbG8sIFdvcmxkISBDYWbDqSDimJU, gives the same result.
Input such as SGVsbG8h! is rejected with
Invalid Base64 character '!' at position 9.
Common use cases
- Reading a Base64 value from an API response, a configuration file or a Kubernetes secret.
- Turning a data URI from HTML or CSS back into an image file.
- Saving a PDF or ZIP attachment that an API returned as a Base64 string.
- Decoding the parts of a JWT or other URL-safe Base64 strings that have no padding.
- Finding a stray character that makes another program reject a Base64 string.
Common errors and how to fix them
- Invalid Base64 character
- Something in the input is outside the Base64 alphabet. Common causes are a line break or space introduced by copy and paste, or a URL-safe - or _ while the standard alphabet is selected. Remove the stray characters, or switch alphabets.
- The Base64 data is incomplete
- Base64 is read in groups of four characters and the input does not end on a complete group. The value was almost certainly truncated when it was copied; copy it again in full, including any trailing = padding.
- Too much padding, or the input contains only padding characters
- There are more = characters than a valid value can end with, which means the data is corrupted or two values have been concatenated. Re-copy the original.
- This data URI is not Base64-encoded
- The data URI header has no ;base64 marker, so its payload is percent-encoded rather than Base64. Use the URL Decoder for that data instead.
Frequently asked questions
Which Base64 variants does the decoder accept?
Standard Base64 and URL-safe Base64 (with - and _), with or without = padding. Spaces and line breaks are ignored, so MIME-wrapped Base64 from emails decodes too. A data: URI prefix such as data:image/png;base64, is removed automatically.
Why do I get an "Invalid Base64 character" error?
Base64 only uses A–Z, a–z, 0–9, + / (or - _) and = for padding. Anything else, such as a quote, a comma or a character damaged when copying, stops decoding. The message gives the position of the character, with the line and column for multi-line input.
How does the tool decide whether the result is text or a file?
The decoded bytes are treated as a file when they start with the signature of a PNG, JPEG, GIF, WebP, PDF, ZIP or Gzip file, are not valid UTF-8, or contain null or many control characters. Otherwise they are shown as UTF-8 text.
What file extension does the download get?
It comes from the MIME type of a data URI when there is one, otherwise from the file signature (for example .png or .pdf). If the type cannot be identified, the file is saved as decoded.bin.
Why is my text offered as a file instead of shown?
Text is shown only when the decoded bytes are valid UTF-8. Text saved in a legacy character set such as Windows-1252 or UTF-16 is not, so it is offered as a download. Open the downloaded file in an editor that lets you choose the character set.
Is my data sent to your server?
No. Decoding runs in your browser, and the input and the decoded file stay on your device.