Encoding Tools
Base64 encode online.
Type or paste text and copy the Base64. Everything is converted to UTF-8 first, so accents, non-Latin scripts and emoji work. Choose the URL-safe alphabet and whether to keep the = padding. Runs in your browser; nothing is uploaded.
Short answer: type text and copy the Base64 below it. The text is turned into UTF-8 bytes, then every 3 bytes become 4 characters, so Hello, World! gives SGVsbG8sIFdvcmxkIQ== and € gives 4oKs.
Text and Base64
Result
How Base64 works
Encoding reads the UTF-8 bytes in groups of 3 (24 bits) and cuts each group into four 6-bit values, each written as one character. Man is the bytes 77, 97, 110, which become TWFu. If 1 or 2 bytes are left at the end, the last group is padded with == or =.
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 encode text to Base64?
Type or paste the text into the text box and copy the result from the Base64 box. The Base64 updates as you type.
How long is the Base64 output?
Every 3 bytes become 4 characters, so the output is about one third larger than the input. With padding it is 4 times the number of 3-byte groups, rounded up (RFC 4648 section 4). Note that non-ASCII characters take 2 to 4 UTF-8 bytes each.
Does it work with emoji and non-English text?
Yes. The text is encoded as UTF-8 bytes before the Base64 step, so any Unicode text works. Plain JavaScript btoa() throws an error on characters above U+00FF; this page does not.
When should I remove the = padding?
When the format you are feeding says so. JSON Web Tokens use base64url without padding (RFC 7515). RFC 4648 section 3.2 requires padding unless the referring specification says otherwise, so keep it for general use.
Why is my result different from another encoder?
Check for a trailing newline or space in what you pasted, because they are encoded too (foobar and foobar plus a newline differ). Also check the alphabet: URL-safe output uses - and _ instead of + and /.
Is Base64 a way to hide data?
No. It is a reversible encoding with no key, and anyone can decode it. It exists to carry bytes through systems that only accept text.