Encoding Tools
Base64 encoder.
Type text and see the Base64 appear, or paste Base64 and see the text. One live two-way box, UTF-8 safe, with a URL-safe option and exact error messages. Runs in your browser; nothing is uploaded.
Short answer: Base64 turns every 3 bytes into 4 printable characters (A-Z a-z 0-9 + /), padding the end with =. Hello, World! becomes SGVsbG8sIFdvcmxkIQ==, and the lower box decodes it back. Text goes through UTF-8 first, so € becomes 4oKs.
Text and Base64
Result
How Base64 works
Base64 reads bytes in groups of 3 (24 bits) and cuts each group into four 6-bit values, each written as one character from a 64-character alphabet. Man is the bytes 77, 97, 110, which become TWFu. When the data ends mid-group, the last group is filled out with =. That is why Base64 is always about 4/3 the size of the original.
Source: RFC 4648 section 4, rfc-editor.org/rfc/rfc4648.
Examples
Press Try to load an example into the text box.
| Text | Base64 | Note | Load |
|---|---|---|---|
foobar | Zm9vYmFy | RFC 4648 section 10 test vector. 6 bytes make exactly 8 characters, so no padding. | |
foob | Zm9vYg== | RFC 4648 test vector. 4 bytes leave 1 over, so two "=" pad the last group. | |
fooba | Zm9vYmE= | RFC 4648 test vector. 5 bytes leave 2 over, so one "=". | |
Hello, World! | SGVsbG8sIFdvcmxkIQ== | The usual first example. | |
€ | 4oKs | The euro sign is 3 UTF-8 bytes (E2 82 AC). Plain btoa() cannot take it. | |
héllo | aMOpbGxv | An accented letter takes 2 UTF-8 bytes. | |
ab?> | YWI/Pg== | Standard output has "/". URL-safe gives YWI_Pg (tick URL-safe and no padding). | |
foobar\n | Zm9vYmFyCg== | A trailing newline changes the result: always check what you pasted. |
Unicode, URL-safe and padding
Unicode. Base64 encodes bytes, not characters, so text must first become bytes. This tool uses UTF-8. The browser’s btoa() instead throws an InvalidCharacterError for any character above U+00FF, which is why € or an emoji fails there. Source: HTML Standard, btoa().
URL-safe (base64url). Section 5 of RFC 4648 swaps + for - and / for _ so the result can sit in a URL or file name. JSON Web Tokens use this alphabet with the trailing = removed (RFC 7515 section 2); the JWT decoder splits a whole token for you.
Padding. RFC 4648 section 3.2 requires = padding unless the specification using Base64 says otherwise. The decoder accepts missing padding, as the browser’s own forgiving-base64 rules do (WHATWG Infra), and notes it. It rejects padding that is the wrong length, padding in the middle, and a single leftover character.
Line breaks. MIME limits encoded lines to 76 characters (RFC 2045 section 6.8), so Base64 copied from an email is often wrapped. The decoder ignores spaces and line breaks. This tool does not add line breaks when encoding.
Images and files. To turn an image into Base64, use the Image to Base64 (Data URI) generator. To turn Base64 back into an image or PDF, use the Base64 to File decoder.
Frequently asked questions
How do I decode Base64 online?
Paste the Base64 into the lower box. The decoded text appears in the upper box as you type. Standard (+ /) and URL-safe (- _) Base64 are both detected, line breaks and spaces are ignored, and missing "=" padding is filled in with a note.
How do I encode text to Base64?
Type or paste the text into the upper box. The Base64 appears in the lower box as you type. The text is converted to UTF-8 bytes first, so accented letters, non-Latin scripts and emoji work.
Why does JavaScript btoa() fail on some text?
btoa() only accepts characters up to U+00FF and throws an InvalidCharacterError for anything above (the HTML Standard defines this). This page encodes the text to UTF-8 bytes first, then Base64-encodes the bytes, which is why € or an emoji works here.
What is URL-safe Base64 (base64url)?
The same encoding with - in place of + and _ in place of /, defined in RFC 4648 section 5. JSON Web Tokens use it with the trailing "=" removed (RFC 7515). Tick URL-safe and untick padding to produce that form; the decoder recognises it automatically.
Is Base64 encryption?
No. Base64 is a reversible encoding with no key: anyone can decode it, as this page does. Never use it to protect a password or secret.
Is my text uploaded?
No. Encoding and decoding run in your browser with the script on this page. The text you type is not sent to a server by this tool.