How to Decode Base64: Read Encoded Text, Tokens and Data URIs
Published: 22 November 2026 · by QuikTools Hub
A Base64 string looks like gibberish: a run of letters, digits and punctuation that ends, very often, in one or two equals signs. It is not random and it is not encrypted. It is ordinary text or data, rewritten in an alphabet of 64 safe characters so it can travel through systems that only trust plain text. Decoding it is the way back: paste the string, and the original text comes out. The free Base64 Encoder / Decoder on this site decodes in your browser, so you can test every example below against the real tool.
This guide is decode-led: it starts from the string in front of you and works out what it says. It covers how to recognize Base64, the alphabet and padding rules, what the decoder does with missing padding and truncated input, how accents and emoji survive, the Base64URL variant used by JWTs, data URIs, and the one warning that matters most: Base64 is not encryption.
What Base64 is
Base64 exists because many systems can only be trusted with a small set of printable characters: email, older protocols, text file formats. The encoding takes your data three bytes at a time and rewrites each group as four characters drawn from a 64-character alphabet: A to Z, a to z, 0 to 9, plus and slash. Three bytes become four characters, so the output is predictably about a third longer than the input. That is the whole mechanism, and it is defined in RFC 4648, the standard that fixes the alphabet, the padding, and the rules for what a decoder should accept.
The size cost is easy to check. The thirteen bytes of Hello, World! become the twenty characters SGVsbG8sIFdvcmxkIQ==. A hundred characters of plain text become 136 characters of Base64. The extra third is the price of making arbitrary bytes safe for text-only channels, and it is why large files are linked rather than embedded whenever there is a choice.
Base64 is also used simply because it makes data possible to handle with text editors: an encoded value can be pasted into a header, a JSON string, an environment variable, or a configuration file, and it survives the journey intact. In nearly every case the job is the same as the one on this page: inspect what an encoded string really says, or prepare a string for a system that expects the encoded form.
How to recognize a Base64 string
Four signs point at Base64. The length is usually a multiple of four. Every character comes from the alphabet: upper and lowercase letters, digits, plus, and slash. The string often ends in one or two equals signs, which are padding, not part of the data. And the string looks meaningless: no spaces, no recognizable words, just a dense run of characters.
None of those signs proves anything on its own. Only decoding tells you what a string is, and a string can satisfy all four signs and still fail to decode, if one character is wrong or the length is off by one. Treat recognition as a guess and decoding as the test.
Two traps hide in recognition. The first is case: Base64 is case sensitive, and lowercase letters are different values from uppercase ones. The lowercase string sgvsbg8= does not decode to Hello; it decodes to a handful of replacement and control characters, because those letters mean different bytes. The second trap is the lookalike variant: a string containing minus and underscore instead of plus and slash is Base64URL, not standard Base64, and this tool rejects it. That variant is covered in its own section below.
A wrapped string is a third case worth knowing. Email systems historically wrap Base64 at 76 characters per line, so a value copied out of an email may arrive with line breaks in the middle. This decoder ignores whitespace anywhere in the string, so a wrapped value decodes without cleaning. The padding and whitespace rules are set out in full two sections below.
Decoding step by step
Decoding with this tool takes four steps. Paste the Base64 string into the box. Click Decode. Read the result in the panel below the buttons. If the string is not valid Base64, the tool shows the message Invalid Base64 input instead of a garbled result. Click Copy to take the decoded text into your editor or terminal.
Three details of the tool matter for the rest of this guide. First, conversion runs when you click, not as you type: there is no live mode, and pasting alone changes nothing until Decode is clicked. Second, the box starts with the text Hello, World!, so the Encode direction is visible before any input is pasted; the Decode direction needs your string. Third, the tool converts text only. It has no file picker and no image input, so a pasted filename is just more text, and a decoded file's bytes come back as text with replacement characters where the bytes are not valid UTF-8.
Worked examples: the padding ladder
The shortest examples show the padding rules most clearly. One byte becomes two characters plus two equals signs, two bytes become three characters plus one equals sign, and three bytes need no padding at all:
- a becomes YQ==
- ab becomes YWI=
- abc becomes YWJj
- abcd becomes YWJjZA==
The same ladder appears in the standard's own test vectors: f becomes Zg==, fo becomes Zm8=, foo becomes Zm9v, and foobar becomes Zm9vYmFy. Decoding reverses each one exactly: Zg== gives back f, and Zm9vYmFy gives back foobar.
Longer examples follow the same rules. Hello, World! encodes to SGVsbG8sIFdvcmxkIQ==, thirteen bytes in and twenty characters out. The credential-shaped string user:password encodes to dXNlcjpwYXNzd29yZA==, which is why strings of this shape turn up wherever basic authentication and API examples are discussed. Decoding 4pyT gives back a single check mark, and the check mark is three UTF-8 bytes, so three bytes always become exactly four Base64 characters with no padding needed.
The examples that separate one converter from another are the non-English ones. The word café encodes to Y2Fmw6k= because the accented e is two bytes in UTF-8, and the waving-hand emoji encodes to 8J+Riw==. The Japanese greeting encodes to 44GT44KT44Gr44Gh44Gv. Decode any of those strings here and the original comes back exactly, accents and emoji intact, because this tool converts text to UTF-8 bytes before encoding, and decodes bytes back to UTF-8 text after decoding.
Padding: the rules, and where this decoder is forgiving
Padding exists to complete the final group of four characters. A final group of one byte takes two equals signs, a final group of two bytes takes one, and a final group of three bytes takes none. That is the strict rule, and it is what encoders produce. Decoders, however, are more forgiving than encoders, and this one follows the browser's forgiving rules. Knowing exactly where it forgives and where it refuses is the difference between a quick decode and a confusing error.
Missing padding is accepted. SGVsbG8 without its equals sign decodes to Hello, and SGVsbG8sIFdvcmxkIQ without either of its equals signs decodes to Hello, World!. The padding is redundant when the length of the string already says how many bytes the last group holds, so a value that lost its padding on the way to you still decodes.
Wrong padding is rejected. SGVsbG8== with an extra equals sign fails, YQ= with one equals sign where two belong fails, and SGVsbG8sIFdvcmxkIQ= with one where two belong fails. The rule is exact: the padding must bring the total length to a multiple of four with the right count for the final group, or it must be absent altogether.
A length that leaves a remainder of one when divided by four is rejected. SGVsb, at five characters, fails, and SGVsbG8sI, at nine characters, fails. No Base64 string can have that length, so the decoder refuses rather than guessing.
The case to watch is a length that leaves a remainder of two or three. Those decode, silently, to fewer bytes. SGVsbG, at six characters, decodes to Hell with no error at all: the first four characters give Hel, and the last two give one more byte, l, while the missing characters are simply never supplied. A truncated string can therefore produce a shorter answer instead of an error, and the only defence is to check the source: if the string was cut off when it was copied, the decoded text is incomplete and no error will tell you so.
Two smaller rules complete the picture. Non-alphabet characters are rejected: SGVsbG8! fails because of the exclamation mark, and plain text such as Hello, World! fails because of the comma and the exclamation mark. And non-canonical pad bits are not checked: QQQ= decodes to the letter A followed by a garbage byte, because the standard says the unused bits in the final character must be zero, but this decoder does not enforce that. A strict decoder would refuse it; this one returns the letter and the garbage.
Accents, emoji and other languages
The browser's built-in Base64 function, btoa, was designed for single-byte text and throws an error on characters like the accented e or an emoji. Tools built directly on it inherit that limit. This converter encodes text to UTF-8 bytes first, which is the step that makes the difference: the TextEncoder turns the string into its UTF-8 bytes, those bytes are passed to btoa, and decoding reverses the process with atob and a TextDecoder. That is also the pattern the MDN documentation recommends for Unicode text, and it is why café, the waving-hand emoji, and Japanese text all round-trip exactly.
The reverse direction has one asymmetry worth knowing. Decoding always produces bytes, and those bytes are then read as UTF-8 text. Bytes that are not valid UTF-8 do not produce an error: the TextDecoder replaces each invalid sequence with the Unicode replacement character. Decoding the single byte encoded as /w== gives a replacement character, and decoding AAEC, three bytes that are control characters, gives three control characters. So a decoded file's bytes come back as text with replacement characters scattered through it, which is a sign that the value was binary data, not text, and needs a file tool rather than a text decoder.
Base64URL and JWTs
Standard Base64 uses plus and slash, and both characters have special meanings in URLs: plus means a space in a query string, and slash separates path segments. The URL-safe variant, Base64URL, swaps exactly those two characters for minus and underscore, and usually drops the padding as well. The two alphabets are otherwise identical, but they are different encodings, and a string in one is invalid in the other.
JSON Web Tokens use Base64URL. A token has three dot-separated segments: a header, a payload, and a signature, each Base64URL-encoded. The header and payload are JSON, so decoding them shows the token's contents: the header eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 decodes to a JSON object naming the HS256 algorithm and the JWT type, and the payload eyJzdWIiOiIxMjM0NTY3ODkwIn0 decodes to a JSON object with the subject 1234567890. Those two segments happen to contain no minus or underscore characters, so they decode in this tool as they stand, and their missing padding is tolerated.
A segment that does contain minus or underscore is rejected here: ab-_cd fails, and PDw_Pz8- fails. To decode such a segment, replace every minus with a plus and every underscore with a slash, then restore the padding to a multiple of four, and decode the result as standard Base64. This tool does not do that conversion for you; do it by hand, or use a decoder that accepts the URL-safe alphabet.
The third segment is different in kind: it is the signature, raw bytes rather than JSON, so decoding it gives binary data, not readable text. And reading a token's header and payload tells you what the token claims, not whether it is genuine: verifying a signature is a separate step this tool does not do.
Data URIs: decode the payload, not the whole string
A data URI embeds a small piece of data directly in a URL, in the form data, media type, an optional base64 marker, a comma, and then the data. The standard example is data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==, which is the text Hello, World! in Base64 form. Small images and fonts are embedded in CSS and HTML the same way, with an image media type instead of text.
Decoding a data URI means decoding only the part after the comma. Paste the whole URI into this tool and it fails, because the colon, the semicolon, and the comma are outside the Base64 alphabet. Paste only SGVsbG8sIFdvcmxkIQ== and it decodes to Hello, World!. The rule is simple: strip everything up to and including the comma, then decode what remains.
For an image data URI the same rule applies, with one more limit: the payload decodes to binary image bytes, and this text-only tool shows those bytes as text with replacement characters. That output is not the image, and it is not useful as text. To see the image, save the payload to a file with a binary decoder instead.
Base64 is not encryption
This is the most important thing in the guide. Base64 is a public, reversible encoding: anyone who sees dXNlcjpwYXNzd29yZA== can turn it back into user:password in seconds, exactly as this page does. Encoding a password, key, or personal data gives it no protection at all. The standard says it plainly: base encoding visually hides otherwise easily recognized information, such as passwords, but does not provide any computational confidentiality, and it adds no entropy to the plaintext.
That is why the credential-shaped example matters. An Authorization header carrying Basic authentication is just base64 of username:password, and anyone who intercepts it reads the password by decoding it. Base64 is safe to use for moving data through text channels, and it is never a substitute for encryption, hashing, or access control. If a value must stay secret, encrypt it; if it must only travel safely, encode it.
There is a second, practical side to the same warning. Because Base64 strings are so easy to decode, pasting one into a random online decoder hands your data to that server. If the string is a token, an API response, or anything you would treat as a credential, decode it locally: in the terminal, in the browser console, or in a client-side tool that never sends it over the network. This tool runs entirely in your browser, so the strings you paste never leave your device.
What this tool does not do
The limits are part of the tool, and they are stated here so nobody discovers them mid-task. The tool converts text only: there is no file picker and no image input, and pasting a filename simply encodes the filename's characters as text. If the real job is turning an image file into a Base64 data URI, a file-based tool is needed. The tool accepts the standard alphabet only: a URL-safe string with minus and underscore is rejected, and the padding must be correct or absent. The tool returns text only: decoded bytes that are not valid UTF-8 come back with replacement characters, and binary data needs a binary decoder. The tool does not wrap its output: a 200-character input encodes to a single unbroken line, so long values stay on one line however long they get. And the tool converts on click, not as you type, and has no reset button.
None of those limits is a fault. They are the shape of a small text converter, and the guide above is written around them: every procedure in it works with the tool as it actually behaves.
Which job needs which tool
- Read an encoded token, API payload, or configuration value: paste it here and click Decode.
- Check what a data URI contains: paste only the part after the comma and decode it.
- Read a JWT header or payload: decode the segment, if it has no minus or underscore characters.
- Prepare text for a system that expects Base64: paste the text and click Encode.
- Encode a file or an image: use a file-based tool, not this one.
- Decode a URL-safe string: convert minus to plus, underscore to slash, and restore the padding first, or use a Base64URL decoder.
- Hide a password or a secret: do not use Base64 at all. Encrypt it instead.
Conclusion
Base64 is a small idea with a large footprint: three bytes become four characters, the alphabet is 64 safe characters plus padding, and the encoding lets binary data travel through text-only systems. Decoding is the way back, and most of the skill is in the edge cases: recognizing the string, reading the padding, knowing that missing padding is forgiven and truncation is silent, handling accents and emoji through UTF-8, converting Base64URL by hand, and stripping a data URI down to its payload. The converter on this site does the mechanical part honestly — UTF-8 safe, in the browser, with a clear error for invalid input — and this guide documents where its forgiveness ends. Try the Base64 Encoder / Decoder with the examples in this guide and see each rule in action.
Sources
IETF, RFC 4648: The Base16, Base32, and Base64 Data Encodings — https://datatracker.ietf.org/doc/html/rfc4648 — base encoding for US-ASCII-restricted environments; line feeds and the MIME 76-character limit; padding rules; non-alphabet characters; canonical encoding and pad bits; the Base64 alphabet and 24-bit groups; the URL and filename safe alphabet; test vectors; security considerations including no computational confidentiality and no added entropy. Accessed 21 November 2026.
WHATWG, Infra Standard §7: Forgiving base64 — https://infra.spec.whatwg.org/#forgiving-base64-decode — forgiving-base64 decode: remove all ASCII whitespace; strip one or two trailing equals signs when the length divides by 4; fail when the length leaves a remainder of 1; fail on code points outside plus, slash, and ASCII alphanumeric; discard trailing bits, so YQ and YR both return a. Accessed 21 November 2026.
MDN, Window: atob() method — https://developer.mozilla.org/en-US/docs/Web/API/Window/atob — atob decodes a Base64-encoded string; throws InvalidCharacterError if the input is not valid base64; the result is a binary string of raw bytes. Accessed 21 November 2026.
MDN, Window: btoa() method — https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa — btoa expects binary data with code points below 256 and throws InvalidCharacterError for anything wider; for arbitrary Unicode text the string must first be converted to its UTF-8 bytes; the recommended solution is the TextEncoder and TextDecoder pattern. Accessed 21 November 2026.
MDN, TextEncoder — https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder — TextEncoder encodes a JavaScript string using UTF-8; its encoding property always returns utf-8. Accessed 21 November 2026.
IETF, RFC 7515: JSON Web Signature (JWS), §2 Terminology — https://datatracker.ietf.org/doc/html/rfc7515 — Base64url Encoding: the URL- and filename-safe character set of RFC 4648 §5, with all trailing equals characters omitted and without any line breaks, whitespace, or other additional characters; JWS Compact Serialization for space-constrained environments such as HTTP Authorization headers and URI query parameters; the JWS Signature as a digital signature or MAC over the Protected Header and the Payload. Accessed 21 November 2026.
MDN, data: URLs — https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs — data URL syntax as data, media type, optional base64 marker, comma, data; the worked example data:text/plain;base64,SGVsbG8sIFdvcmxkIQ== for the text Hello, World!; plus and slash have special meanings in URLs, but data URLs have no path segments or query parameters, so the encoding is safe in that context. Accessed 21 November 2026.
Frequently asked questions
How can I tell whether a string is Base64?
Look for the four signs: a length that is usually a multiple of four, characters only from the alphabet of letters, digits, plus and slash, often one or two equals signs at the end, and no recognizable words. None of those signs proves it: only decoding tells you what a string is. A string with minus and underscore characters is Base64URL, not standard Base64, and a string with spaces or line breaks may be a wrapped value from an email.
Why does my Base64 string decode even though the padding is missing?
Because the decoder is forgiving about padding. The equals signs are redundant when the length of the string already says how many bytes the last group holds, so SGVsbG8 decodes to Hello and SGVsbG8sIFdvcmxkIQ decodes to Hello, World! with no padding at all. Encoders still produce padding, and you should keep it when you produce a value; but a value that lost its padding on the way to you still decodes.
Why did a truncated Base64 string decode to shorter text instead of an error?
Because only some truncations fail. A string whose length leaves a remainder of 1 when divided by 4 is rejected, but a length leaving a remainder of 2 or 3 decodes silently to fewer bytes: SGVsbG, at six characters, decodes to Hell with no error. The decoder cannot tell a complete short string from a truncated long one, so check the source if the decoded text looks cut off.
Can I decode a data URI with this tool?
Yes, but decode only the payload. A data URI has the form data, media type, an optional base64 marker, a comma, and then the data, and the whole URI fails because the colon, semicolon, and comma are outside the Base64 alphabet. Strip everything up to and including the comma, then paste what remains: for data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==, decode SGVsbG8sIFdvcmxkIQ== to get Hello, World!. For an image data URI the payload decodes to binary bytes, so use a binary decoder instead of this text tool.
What is Base64URL, and why does this tool reject it?
Base64URL is the URL-safe variant of Base64: it swaps plus and slash for minus and underscore, and usually drops the padding, because plus and slash have special meanings in URLs. JSON Web Tokens use it for their header, payload, and signature segments. This tool validates against the standard alphabet only, so any segment containing minus or underscore is rejected as invalid input. To decode one, replace minus with plus and underscore with slash, restore the padding to a multiple of four, and decode the result as standard Base64.
Why does decoding a file's Base64 give me strange characters?
Because the decoded bytes are not UTF-8 text. This tool reads decoded bytes as UTF-8, and bytes that are not valid UTF-8 become the Unicode replacement character instead of an error: decoding /w== gives a single replacement character. A file's bytes are binary data, not text, so a text decoder cannot show them meaningfully. Save the decoded bytes to a file with a binary decoder, and use this tool only for values that decode to readable text.
More guides on the QuikTools Hub blog.