Base64 Encoder & Decoder
This free online Base64 encoder and decoder shows both results live as you type: paste text or a Base64 string and the encoded and decoded output appear at the same time, with no mode switching and no button to press.
Base64 represents binary data with 64 printable characters (A-Z, a-z, 0-9, + and /, with = for padding). Every 3 bytes become 4 characters, so the output is about a third larger but travels safely through any text-only protocol. Base64 is encoding, not encryption: there is no key, and anyone can reverse it. The phrases "Base64 encryption" and "Base64 decryption" are misnomers.
Features:
- Live two-way conversion: encoding turns text into bytes using the selected character set; UTF-8 handles Chinese, emoji and line breaks, with no input length limit
- Tolerant decoding: whitespace and line breaks are ignored, missing = padding is restored, and both standard +/ and URL-safe -_ input are accepted
- Character set: one setting shared by encoding and decoding — UTF-8, GBK, GB18030 or Latin-1. Pick GBK to produce the same Base64 as a legacy system, or to recover Chinese text from GBK bytes
- Hex bytes: with "Hex bytes" selected, paste a byte string such as d6 d0 ce c4 to get its Base64 directly; the decode box shows each byte in hexadecimal
- URL-safe output: checked, the encoded result uses - and _ instead of + and / and drops the trailing =, ready for URLs, filenames or JWTs. This changes encoding only; decoding accepts both forms
- Copy: each result box has its own copy button, shown only when there is a result
- If the input is not valid Base64, the decode box stays empty while encoding still runs. Valid Base64 whose bytes are not readable text shows "Cannot decode". If the character set cannot represent the input (an emoji under GBK, for example), or the hex string is malformed, the encode box shows "Cannot encode"
FAQ:
- Q: Why is the decode box empty when I type plain text?
A: Decoding is only attempted when the whole input consists of valid Base64 characters. Chinese text, or anything containing commas and quotes, is still encoded above while the decode box stays empty. Plain alphanumeric words such as "test" are technically valid Base64; when the resulting bytes are not readable text, the box shows "Cannot decode". That is not an error. Paste an actual Base64 string to see the decoded text. - Q: The decode box says "Cannot decode" — what should I change?
A: The original text was probably not UTF-8. Chinese text from older systems is usually GBK or GB18030; switch the character set and it will display correctly. For Western text try Latin-1. If the data is an image or a file, choose "Hex bytes" to inspect every byte — a text box cannot show binary content. - Q: Will it decode Base64 with missing = padding, line breaks or surrounding spaces?
A: Yes. All whitespace is stripped and missing padding is restored before decoding, so multi-line values copied from emails or logs can be pasted as they are. - Q: What is the difference between URL-safe output and standard Base64?
A: Standard Base64 uses +, / and =, which need escaping in URLs and filenames. The URL-safe variant swaps them for - and _ and drops the padding. Checking "URL-safe output" changes only the encoded result above; decoding accepts both forms automatically, so there is nothing to set. - Q: Is Base64 encryption? Can I use it for passwords?
A: No. There is no key — anyone with the string can recover the original. It only changes how the data is represented. Use a real cipher such as AES when you need confidentiality. - Q: Why does my Chinese text encode differently from a legacy system?
A: Almost always a different character set. This tool encodes UTF-8 bytes by default, while older systems often produce Base64 from GBK bytes; different bytes mean different output. Switch the character set to GBK and both the encode and decode boxes use GBK, so the two sides line up. GBK and Latin-1 cannot represent emoji and similar characters — those show "Cannot encode", so use UTF-8 or GB18030. - Q: I already have a hex dump — how do I turn it into Base64?
A: Choose "Hex bytes" and paste something like d6 d0 ce c4. Spaces, line breaks and 0x prefixes are ignored, and the encode box returns the Base64 of those bytes. With the same setting, the decode box shows each byte of a valid Base64 string in hexadecimal. - Q: How much longer is the output, and is there a length limit?
A: Every 3 bytes become 4 characters, so the result is roughly a third larger. There is no input limit, and long text is processed as you type.
Common uses:
- Carrying images and files inside text protocols such as HTTP, JSON and XML, including data:image/png;base64,... in HTML
- HTTP Basic authentication, JWT payloads and other values that need URL-safe output to avoid escaping +, / and =
- MIME email attachments, cookies and simple API parameters
- Storing binary content in text-only config files or database fields
- Checking a backend's Base64 output during API debugging (including GBK-based systems), or recovering the original text from a Base64 field in a log or message
Related tools: