Encode text to Base64 or decode it: UTF-8 or another charset, URL-safe, MIME lines, line by line
Convert text to Base64 and back. Handles UTF-8 and emoji, text in Latin-1, Windows code pages, UTF-16, Shift_JIS or GBK, URL-safe Base64, MIME lines and missing padding; binary results download as a file.
How to use it
Choose Encode or Decode. To encode for a URL or a JWT, turn on URL-safe; for email (MIME), turn on MIME for lines of 76 characters, and CRLF for CR LF line ends. Paste your text or Base64. Decoding accepts URL-safe characters, line breaks, missing padding and data: URLs. Turn on Line by line when each line is its own value; pick a Charset when the text isn’t UTF-8. Copy the result. If the decoded data is a file (image, PDF, ZIP, audio, a Word file …), download it instead.
Examples
Encode text with accents
héllo 👋
aMOpbGxvIPCfkYs=
Text is encoded as UTF-8 first, so non-English characters work.
Decode a Basic auth header value
YWRtaW46czNjcjN0
admin:s3cr3t
The part after "Basic " in an Authorization header is user:password in Base64.
Decode Latin-1 text
aOlsbG8= · Charset ISO-8859-1
héllo
In UTF-8 the byte e9 is not a character, so Auto shows binary data; Latin-1 reads it as é.
Encode a list, one value a line
one two three · Line by line
b25l dHdv dGhyZWU=
Standard vs URL-safe Base64
Base64 in code
Buffer.from('héllo', 'utf8').toString('base64'); // 'aMOpbGxv'
Buffer.from('aMOpbGxv', 'base64').toString('utf8'); // 'héllo'
Buffer.from('héllo').toString('base64url'); // URL-safe, no paddingWhen decoding fails
Node.js’s Buffer.from(text, 'base64') never throws: it skips what it can’t read, so bad input gives wrong bytes instead of an error. Paste the text here: it reads standard and URL-safe Base64, with or without = and line breaks, and names a character that is in neither.
| Error | Where | Usual cause |
|---|---|---|
Incorrect padding | Python | The = at the end was cut off, or the text is URL-safe Base64 (- and _): use urlsafe_b64decode |
number of data characters (5) cannot be 1 more than a multiple of 4 | Python | A character is missing: the text was cut while copying |
Non-base64 digit found | Python (validate=True) | A space, line break or - _ in the text |
The string to be decoded is not correctly encoded | Browsers (atob) | URL-safe characters, spaces, or text that was never Base64 |
illegal base64 data at input byte n | Go | The character at that byte; RawURLEncoding reads - _ and no = |
Character sets
Sources: WHATWG Encoding standard, RFC 2045 §6.8 (MIME Base64, 76-character lines)
Questions
- Why does decoding show "binary data"?
The decoded bytes aren’t valid UTF-8 text, so they are a file or text in another character set. The page names the file type from its first bytes (images, PDF, ZIP, Word, Excel and PowerPoint, audio, video, fonts and more) and lets you download it; up to 64 bytes, such as a key or a hash, also show in hex. For text in Latin-1, Windows-1252 or another set, pick it under Charset; UTF-16 with a byte order mark is read on its own. - Is Base64 a way to hide passwords?
No. It’s an encoding that anyone can reverse instantly. Credentials in Base64 (like Basic auth) are effectively plain text. - Why does Base64 end with = or ==?
Base64 writes every 3 bytes as 4 characters. When the last group has only 2 bytes, one = fills it; with 1 byte, two. URL-safe Base64 usually leaves the = out, and the decoder reads it either way. - Is my data or file uploaded?
No. Everything runs in your browser, so your data stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first. That includes files you open.