Programming tool
Base64 Encoder / Decoder
Convert UTF-8 text to Base64 or turn Base64 back into readable text, entirely in your browser.
Unicode text is supported.
Base64 result
What is Base64?
Base64 is a text representation for binary data. It uses 64 characters to make bytes easier to store or send through systems designed for text, such as email, JSON, and URLs.
How Base64 encoding works
Encoding converts your text to UTF-8 bytes, groups those bytes into six-bit values, and maps each value to a Base64 character. Padding with equals signs may be added so the result fits complete groups.
Encoding is not encryption
Base64 does not protect secrets or require a key. Anyone can decode it, so use encryption for passwords, tokens, personal data, and anything confidential.
Common Base64 uses
Base64 is commonly used for email attachments, data URLs, API payloads, configuration values, and embedding small binary files in text formats. It usually increases data size by about one third.
Unicode and Base64
This tool encodes Unicode as UTF-8 before converting it to Base64, so characters such as こんにちは, مرحبا, emoji, and ✓ round-trip correctly. Decoding expects UTF-8 text.
Frequently asked questions
Does this tool send my text anywhere?
No. Encoding and decoding happen in your browser. No API request is needed, and decoded content is treated only as text.
Why does Base64 make data larger?
Base64 represents every 6 bits with one character. Because text characters carry fewer useful bits than the original bytes, the encoded form is typically around 33% larger.
Why was my Base64 rejected?
The value may contain unsupported characters, incorrect padding, or bytes that are not valid UTF-8 text. Whitespace is allowed and removed before validation.
How the Base64 encoder and decoder works
Switch between Encode and Decode, paste your text, and press the button. Encoding converts the text to UTF-8 bytes first and then to Base64, so accented characters, non-Latin scripts, and emoji are handled correctly rather than failing the way a bare call to btoa does. The result can be copied with one click.
Decoding strips spaces, tabs, and line breaks, then checks that the remaining characters belong to the standard Base64 alphabet, that the length is a multiple of four, and that any = padding is at the end. The bytes are decoded as strict UTF-8, and the tool re-encodes the result to confirm it matches the input, which catches values with incorrect padding bits. Anything that fails those checks produces an error instead of garbled text.
How Base64 encoding works
Base64 turns arbitrary bytes into a small set of printable characters: A–Z, a–z, 0–9, plus (+) and slash (/). It works on groups of three bytes. Three bytes are 24 bits, and 24 bits split evenly into four 6-bit values, each between 0 and 63, which index into the 64-character alphabet. That is why every 3 input bytes become exactly 4 output characters.
When the input length is not a multiple of three, the last group is padded with zero bits to fill the 6-bit values and one or two equals signs are appended so the output length stays a multiple of four. In the example above, two bytes produce three characters plus one = sign. A single trailing byte produces two characters and two = signs. Because every character carries only 6 bits of data, the encoded text is about 33 percent longer than the original: 3 bytes become 4 characters, so 1 MB becomes roughly 1.33 MB.
Base64 and Unicode text
Base64 encodes bytes, not characters, so text has to be turned into bytes first and the character encoding matters. The browser's built-in btoa function only accepts characters in the Latin-1 range and throws on anything else, including emoji and most non-English text. This tool uses TextEncoder to produce UTF-8 bytes before encoding, which is what nearly every modern API and file format expects.
For example, the letter é is a single character but two UTF-8 bytes (0xC3 0xA9), so it encodes to w6k=, not to the single-byte Latin-1 result 6Q==. When decoding, the tool assumes the bytes are UTF-8 text. Base64 that represents a binary file such as an image or PDF will decode to bytes that are not valid UTF-8, and the tool reports an error rather than showing meaningless characters.
Standard, URL-safe, and MIME Base64
Several variants of Base64 exist, and they are not interchangeable. This tool uses the standard alphabet from RFC 4648 section 4. The URL-safe variant replaces + with - and / with _ so the output can sit in a URL or filename without percent encoding, and it often omits padding. JSON Web Tokens (JWTs) use the URL-safe alphabet without padding. MIME email attachments use the standard alphabet but insert a line break every 76 characters.
Line-wrapped MIME output decodes here without changes because whitespace is removed first. URL-safe input needs a small edit: replace every - with + and every _ with /, then add = signs until the length is a multiple of four.
- Standard (RFC 4648 §4) – alphabet A–Z a–z 0–9 + /, padded with =, used by this tool
- URL-safe (RFC 4648 §5) – alphabet A–Z a–z 0–9 - _, padding usually omitted, used in JWTs and URLs
- MIME (RFC 2045) – standard alphabet wrapped at 76 characters, used in email
When to use Base64 and common pitfalls
Base64 is the right choice when binary data has to travel through something that only understands text: embedding an image in a data: URL or CSS file, attaching a file to an email, putting bytes in a JSON field, or building an HTTP Basic authentication header, which is the Base64 of username:password. It is also used for Kubernetes secrets and many configuration formats.
The most common mistake is treating Base64 as a form of protection. It is an encoding, not encryption: anyone can decode it instantly, and a Base64 password in a config file or URL is effectively plain text. Other pitfalls include pasting URL-safe Base64 into a standard decoder, losing = padding when copying, and encoding large files when a binary upload would be a third smaller.
Frequently asked questions
Is Base64 a form of encryption?
No. Base64 is a reversible encoding with no key, so anyone who sees the text can decode it. Use real encryption for passwords, tokens, and anything confidential.
Why does Base64 end with one or two equals signs?
The = characters are padding. Base64 processes bytes in groups of three, and when the last group has only one or two bytes, padding is added so the output length stays a multiple of four. Two = signs mean the final group had one byte; one = sign means it had two.
Why is Base64 output larger than the original?
Each Base64 character carries 6 bits but takes a full 8-bit byte to store, so every 3 bytes of input become 4 characters of output. The encoded text is about 33 percent larger, plus a little more if line breaks are added.
Can I decode a JWT or URL-safe Base64 with this tool?
Not directly. JWTs use the URL-safe alphabet without padding. Replace - with + and _ with /, add = until the length is a multiple of four, and then decode each segment separately.
Why does my Base64 fail to decode?
The usual causes are characters outside the A–Z, a–z, 0–9, +, / alphabet, missing or misplaced = padding, a length that is not a multiple of four, or bytes that are not valid UTF-8 text, such as an encoded image. Whitespace is fine because the tool removes it before checking.
Does Base64 work with emoji and non-English text?
Yes. The tool converts text to UTF-8 bytes before encoding, so Japanese, Arabic, accented characters, and emoji round-trip correctly. Decoding expects UTF-8 as well.