Why Your Base64 String Fails to Decode (and the Fix)
Base64 decode errors usually mean padding, a stray newline, or a URL-safe mix-up. See each failure with its exact fix, using a fictional example.
↑↓ to navigate · Enter to open · Esc to close
Encode and decode Base64 for text and files, UTF-8 safe, entirely in your browser.
Runs in your browser. Nothing is uploaded — your input is processed on this device and discarded when you close the tab.
Everything on this page runs in your browser. Nothing you type, paste or open here is uploaded to a server.
Standard Base64 ends its alphabet with + and /. The URL-safe alphabet uses - and _ instead, so the result can sit inside a web address without extra encoding. The setting applies to both modes below, and decoding expects the alphabet you select here.
Padding fills the output to a multiple of four characters. Most decoders accept Base64 with or without it, and this tool’s decoder tolerates missing padding — but some strict systems insist on it, so it is on by default.
Text mode holds up to 1,000,000 characters. That cap is a practical browser-memory limit — the input, its encoded form and the output all have to fit in this tab at once — not a limit of Base64 itself. Larger jobs belong in File mode or a desktop tool.
Files up to 10 MB. Again, that is a practical browser-memory cap — the file, its encoded form (about a third larger) and the output field all live in this tab at once — not a property of the format. The file is read on this device only.
The pasted text is decoded exactly as bytes, with no attempt to read it as text, which is why this area can rebuild images, PDFs and archives that Text mode would refuse.
Base64 carries bytes only — it does not store the original file name or type. Give the result the name and extension it needs, for example photo.jpg or report.pdf.
The sample sentence is Base64 turns café text into safe ASCII. — chosen because it is not plain ASCII: its 39 characters include an é, which takes two bytes in UTF-8, so the text is 40 bytes before encoding. That is exactly the case a careless encoder gets wrong, by throwing an error or quietly mangling the accented letter. Select Load sample and the workspace fills with that sentence and encodes it with the standard alphabet and padding on, producing this output character for character:
QmFzZTY0IHR1cm5zIGNhZsOpIHRleHQgaW50byBzYWZlIEFTQ0lJLg==
The counts agree with the arithmetic on this page: 40 bytes become 56 Base64 characters, because every three bytes turn into four characters, rounded up. With the URL-safe alphabet selected and padding switched off, the same sentence encodes to QmFzZTY0IHR1cm5zIGNhZsOpIHRleHQgaW50byBzYWZlIEFTQ0lJLg — 54 characters, identical except for the missing == at the end, because this particular text happens to produce no + or / characters for the alphabets to disagree about. Decode either version in Text mode, with its matching alphabet setting, and you get the original sentence back, accent intact.
Base64 is a way of writing arbitrary bytes using only 64 safe characters: the letters, the digits, and two punctuation marks. It exists because many systems that move information around — email above all, but also web addresses, configuration files, data URIs and API tokens — were built for plain text and will damage, truncate or reject raw binary data. Encoding a file as Base64 turns it into a long, boring, dependable string of text characters that every one of those systems can carry untouched. At the far end, decoding turns the string back into exactly the bytes that went in. Nothing is compressed and nothing is summarised: the output is fully reversible by design, and it is about a third larger than the input, because four Base64 characters carry only three bytes of data.
That size cost is why Base64 is a transport format, not a storage strategy. Embedding a photograph directly in a web page or a document as Base64 makes that page a third heavier than the photograph itself, and the embedded copy cannot be cached separately the way a normal image file can. The honest uses are the ones where text is the only road available: an attachment inside an email, an image inlined in a CSS file or a single-file document, a binary value that has to pass through a JSON field, a key or certificate that must be pasted into a settings screen.
Two misunderstandings cause most of the trouble with Base64. The first is treating it as protection. It is not encryption, not hashing and not a password: anyone who sees a Base64 string can decode it in seconds — this page will do it — so never encode a secret and call it secured. The second misunderstanding is treating every Base64-looking string as text. Encoded photographs, PDFs and programs decode to bytes that are meaningless, and sometimes invalid, as text. That is why Text mode here decodes strictly as UTF-8 and refuses byte sequences that are not real text, pointing you to File mode instead, rather than handing back a page of replacement characters and pretending the job succeeded.
The two alphabets exist because the standard one contains + and /, both of which mean something special inside a web address. The URL-safe variant swaps them for - and _ and is otherwise identical — same bytes, same padding rules, same size. Mixing them up is the commonest real-world failure: the string looks fine, but a strict decoder rejects characters from the wrong alphabet, which is why this tool validates character by character and its error message names both the character and where it sits.
The most common error is a corrupted paste: a character dropped by a word processor that wrapped the string, a smart quote substituted by a document editor, or the first line of an email header included by accident. Because a single wrong character changes the bytes, the decoder here checks every character and reports the first one that cannot belong, with its position. The second common error is double encoding — encoding text that was already encoded — which decodes once into more Base64 rather than into your file; if your result still looks like Base64, decode it again and check whether that was intended. The third is expecting Base64 to remember what the file was. It does not: no name, no extension, no type. A download named wrongly is still the right bytes, so renaming decoded-file.txt to the extension the data actually needs usually fixes an “unreadable” result.
The limits are these. Text mode accepts up to 1,000,000 characters and File mode up to 10 MB, because the input, the encoded form and the output field must all fit in the browser tab’s memory at once; these are practical caps of running in a web page, and larger files should be encoded with a desktop or command-line tool. Text mode decodes as UTF-8 only, so binary data belongs in File mode. The tool checks characters, length and padding carefully, but it cannot know what the decoded bytes were supposed to be — a string of valid Base64 that encodes the wrong file will decode perfectly, into the wrong file. And nothing here verifies identity or safety: a decoded file deserves the same caution as a file from any other source before you open it.
No. Base64 is an encoding — a public, reversible way of writing bytes as text, with no key and no secrecy. Anyone holding a Base64 string can recover the original in seconds; this page does it in your browser. If something needs protection, it needs real encryption with a password or a key, applied before any encoding. Treat every Base64 string exactly as exposed as the file it came from.
Each Base64 character carries six bits of information, and the encoding works in fixed groups: three bytes (24 bits) become four characters. Four characters for every three bytes means the output is four thirds of the input size, plus up to two padding characters to complete the final group. It is a fixed cost of making binary data survive text-only systems, not a sign that anything went wrong.
Padding is one or two = characters at the end that bring the output to a multiple of four characters, so a decoder can tell exactly where the data ends. You can leave it off when the receiving system is known to tolerate that — most modern decoders, including the one on this page, restore it automatically. Keep it on for email, older systems, and anywhere a specification asks for standard Base64; a strict decoder that expects padding will reject the unpadded form outright.
Whenever the encoded string will sit inside a web address, a query parameter, a filename or a token that travels in a URL. The standard alphabet’s + and / are easily misread in those places — a + in a query string is commonly read back as a space. URL-safe output uses - and _ instead and passes through untouched. For email attachments, data files and most APIs, keep the standard alphabet the receiver expects.
Because the character at that position is not part of the alphabet you have selected — often a letter from a header line included in the paste, a symbol introduced by a document editor, or a - from URL-safe data being decoded with the standard alphabet selected (or the reverse). Count to the position in your pasted text, fix or remove that character, and check the alphabet toggle matches the system the string came from. Line breaks and spaces are ignored, so wrapped text is never the problem.
Most often, the name. Base64 stores bytes only, so the download needs the file name and extension the data actually belongs to — rename it to .jpg, .pdf, .zip or whatever it truly is. If the name is right and it still fails, the pasted string was probably incomplete (a copied block cut short) or double-encoded; decode it once more and see whether the result still looks like Base64.
Base64 Studio converts between ordinary text or files and Base64, the text-safe encoding that represents binary bytes with letters, digits, and a couple of symbols. In text mode, type or paste your text and encode it, or paste a Base64 string and decode it back; the text mode is UTF-8 safe, so accented characters survive the round trip instead of being corrupted. A file mode handles whole files, and a URL-safe variant swaps the standard alphabet for one that is safe inside web addresses. If decoding fails, the tool checks every character and reports the first one that cannot belong, together with its position, so you can find the fault. Everything runs in your browser and nothing is uploaded. When you are finished, copy the result straight into the place that needs it, since a Base64 string pasted through a word processor can pick up altered characters or line breaks that break decoding later.
Sam Rivera, a fictional developer, needs to pass a short fictional token through a system that only accepts plain text. Sam types the fictional string example-token-123 and encodes it. Input: example-token-123. Result: ZXhhbXBsZS10b2tlbi0xMjM=. Decoding that string returns the original token exactly. Later, Sam pastes a string copied from an email and decoding fails at one character position; checking that spot reveals a character that a word processor had altered, and fixing it lets the decode succeed.
Base64 is an encoding, not encryption: anyone can decode a Base64 string, so it must never be used to hide a password or other secret. A single wrong character changes the decoded bytes, so a paste damaged by line-wrapping, a smart quote substituted by a document editor, or a stray email header will fail or decode incorrectly. Double encoding is another trap: encoding text that is already encoded decodes once into more Base64, not into your original file, so if the result still looks like Base64, check whether a second decode was intended.
No. It is reversible encoding, not encryption. Anyone who sees the string can decode it.
Copying often drops or alters a character, or includes extra header text. The tool names the first invalid character and its position so you can inspect that spot.
Standard Base64 uses characters that have special meanings in web addresses. The URL-safe variant swaps them so the string can sit safely in a URL.
No. Encoding and decoding run entirely in your browser.
Format, validate, minify, query and compare JSON in your browser, with precise line-and-column errors.
LiveTest patterns against sample text with match highlighting, capture groups and a safe one-second timeout.
LiveCheck HSTS, CSP and other security headers, TLS details, and DNS/email authentication records (SPF, DKIM, DMARC).
LiveBase64 decode errors usually mean padding, a stray newline, or a URL-safe mix-up. See each failure with its exact fix, using a fictional example.
Older Base64 tools corrupt accented characters and emoji. Learn what UTF-8 safe encoding means and how to spot a tool that handles it correctly.
Base64 appears in data URIs, API tokens, and email attachments. Learn to recognise it in the wild and know when to use it — and when not to.