Skip to main content
BE

Base64 Encode & Decode

Encode any text or binary data to Base64 and decode Base64 back to its original form — all instantly in your browser.

Did you like the tool? Thanks!
Share:

How to Use Base64 Encode & Decode

Type or paste text into the input box, press Encode to get its Base64 representation, or paste a Base64 string and press Decode to see the original. The tool handles UTF-8 text correctly using the TextEncoder and TextDecoder APIs, so characters outside the Latin-1 range (emojis, Cyrillic, Chinese, etc.) are encoded and decoded faithfully. A Copy button lets you grab the result in one click. Everything runs locally — nothing you type is sent to a server.

About Base64 Encode & Decode

Base64 is one of those encoding schemes that is everywhere once you know to look for it — it turns any binary data into a string of 64 safe, printable ASCII characters (A-Z, a-z, 0-9, +, /, and = for padding), so that data can travel through channels that only handle text: email attachments (MIME), JSON Web Tokens, data URIs in HTML and CSS (data:image/png;base64,...), inline images in SVG, and the raw bytes of files stored inside XML or JSON payloads. It is not encryption or compression — anyone who sees the Base64 string can decode it back trivially. What it solves is the transport problem: how to get arbitrary bytes from A to B through a medium that expects plain text.\n\nHow it works is surprisingly simple. Base64 takes the input bytes in groups of three (3 × 8 bits = 24 bits), splits those 24 bits into four groups of 6 bits each, and maps each 6-bit value to one of the 64 characters in its alphabet. If the input does not divide evenly into groups of three bytes, one or two = padding characters are appended so the decoder knows how many bytes the original had. This is why Base64 output is always about 33% larger than the original input (4 output characters for every 3 input bytes, minus a couple of characters of padding in the last chunk). It is also why a Base64-encoded JPEG is noticeably larger than the binary JPEG file itself — the overhead is real and unavoidable given the 64-character constraint.\n\nThis tool encodes and decodes in real time, entirely in your browser. The browser's TextEncoder and TextDecoder APIs handle the UTF-8 side correctly, which matters because many online Base64 tools only support Latin-1 (ISO-8859-1) and silently corrupt any character with a code point above U+00FF — you paste café and the output decodes as café, and you do not notice until it is too late. This tool uses TextEncoder to convert your text to UTF-8 bytes before Base64-encoding, and TextDecoder to convert the decoded UTF-8 bytes back to a proper JavaScript string. The same code path handles ASCII, accented Latin, emoji, CJK, and any other Unicode script without loss.\n\nWhen should you use Base64? To embed an image directly in an HTML or CSS file as a data URI. To include a binary blob inside a JSON API response. To send a file as part of an XML document. To create the signature segment of a JSON Web Token. And when debugging, to inspect the actual bytes of a piece of data without needing a hex editor. Base64 is the universal adapter between the world of raw bytes and the world of text — it does not add security, but it removes a whole category of transport-headaches that arise when binary data meets text-only systems.

Details & Tips

Technical encoding detail: every 3 input bytes (24 bits) produce 4 Base64 characters (4 × 6 = 24 bits). The 64-character alphabet is ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/. Padding uses = — if the input has 1 byte left over (after grouping into threes), the output gets 2 Base64 chars plus ==; if 2 bytes left, the output gets 3 Base64 chars plus =. The decoder reads these padding characters to know exactly how many bytes the original input had, which is critical — without them, a trailing A could represent bits that were not actually in the input.\n\nUTF-8 handling is critical: the JavaScript atob() and btoa() functions only handle Latin-1 and throw on any character above U+00FF, which makes them broken for real-world text. This tool uses TextEncoder to convert the JavaScript string (internally UTF-16) to UTF-8 bytes, then encodes those bytes to Base64. The decoder reverses: Base64 → binary bytes → TextDecoder → JavaScript string. The UTF-8 round-trip is lossless for the entire Unicode range.\n\nKnown edge cases: an empty input produces an empty result. A Base64 string that contains characters outside the Base64 alphabet (spaces, line breaks, the - and _ used in Base64URL) is automatically cleaned — whitespace and newlines are stripped, and Base64URL characters are converted to their standard equivalents (-→+, _→/) before decoding, so you can paste a JWT segment or a URL-safe Base64 value directly without manual reformatting. A clean error message is shown if the input after cleaning still cannot be decoded (wrong length or non-Base64 characters).

Frequently Asked Questions

Is Base64 encryption?
No. Base64 is an encoding, not encryption — anyone can decode it. It simply represents binary data using printable ASCII characters so it can travel through text-only channels like email or JSON.
Why is my Base64 output about 33% larger than the input?
Base64 converts every 3 bytes of input into 4 characters of output (3×8=24 bits → 4×6=24 bits). The 33% overhead is inherent to the encoding and cannot be avoided.
Does this tool support UTF-8 text like emoji and accented characters?
Yes. It uses the TextEncoder and TextDecoder APIs to correctly convert text to UTF-8 bytes before Base64 encoding, and to decode UTF-8 bytes back to text. The older btoa()/atob() approach (Latin-1 only) is not used.
Can I decode a JWT payload with this tool?
Yes. A JWT is three Base64URL-encoded segments separated by dots. Copy the middle segment (the payload), paste it into the Decode input, and it will be decoded automatically — the tool converts Base64URL characters (- and _) to standard Base64 before decoding.
What is the difference between Base64 and Base64URL?
Base64URL uses - instead of + and _ instead of /, and omits the = padding, making it safe for use in URLs and filenames. This tool automatically converts Base64URL input to standard Base64 when decoding, so both formats work.
Why do I get an error when decoding a Base64 string?
Either the string contains characters outside the Base64 alphabet (after cleaning whitespace and Base64URL conversion), or its length is not a multiple of 4 after stripping padding, which makes it impossible to decode. Check for missing or extra characters.
Can I use Base64 to embed an image in HTML?
Yes — encode the image to Base64, then use it in a data URI: <img src="data:image/png;base64,...">. Note that this increases the file size by about 33% and prevents browser caching of the image as a separate resource, so it is best for small icons and inline graphics.
Is my text sent to a server when I encode or decode?
No. All encoding and decoding runs in your browser using JavaScript — nothing you type, paste, or encode is transmitted, logged, or stored anywhere.
What happens if I try to decode binary data (like a PDF) that was Base64-encoded?
The tool decodes it to a raw string. If the bytes are valid UTF-8, they display as text; if not, a message is shown explaining the output is binary. For binary files, use the Download button to save the decoded bytes as a file.
Can I encode line by line or should I paste the whole block at once?
Paste the whole block. Base64 encodes the entire input as one continuous byte stream — encoding line by line would produce different output because the line breaks become part of the encode and decode process.

Part of These Collections

Also Available As

base64 encoder, base64 decoder, base64 encode online, base64 decode online, text to base64, base64 to text, base64 converter, base64 utf8

Found a Problem?

Let us know if something with Base64 Encode & Decode isn't working as expected.

Thanks — we'll take a look.