When to use it
Use this tool to turn text into Base64, or Base64 back into readable text. Developers use Base64 for data in JSON, email attachments, HTTP Basic authentication headers, data URLs and configuration files. It is also handy when you find a long string of letters and numbers and want to see what it says.
How to use it
- Choose Encode to Base64 or Decode Base64.
- Type or paste into Your text, or click Example to try a sample. The Result updates as you type.
- When encoding, tick URL-safe (- and _ instead of + and /) if the result will go in a web address, and Split into lines of 76 characters for email or PEM-style formats.
- Click Copy result, or Download .txt to save it.
- Click Clear to start again.
The character and line counts under each box help you check the size.
Worked example
Encode the word Hello and you get SGVsbG8=. The = at the end is padding, added because 5 bytes do not divide evenly into groups of 3.
For a Basic authentication header, encode the text user:pass. The result is dXNlcjpwYXNz, which goes after the word Basic in the header. Remember that this only encodes the details, it does not protect them, which is why such headers must be sent over HTTPS.
To decode, switch to Decode Base64 and paste dXNlcjpwYXNz. The result is user:pass again. If you paste a data URL that starts with data:…;base64, the prefix is removed for you.
How Base64 works
Computers store text as bytes. Base64 takes the bytes three at a time, splits those 24 bits into four groups of 6 bits, and writes each group as one of 64 safe characters: A–Z, a–z, 0–9, + and /. That is why the output only ever uses those letters, digits and symbols.
Tips
- Use URL-safe mode for web addresses and tokens. JSON Web Tokens use this form.
- Do not split lines for JSON. Line breaks inside a JSON string can break the data.
- Check the end of the string. If decoding fails, the text may have been cut off when copied.
Common mistakes
- Treating Base64 as security. It hides nothing from anyone who knows what it is.
- Copying extra characters. Quotes, commas or spaces around the string can make decoding fail. The tool ignores spaces and line breaks, but not other symbols.
- Encoding twice. Base64 of Base64 still decodes, but only to more Base64.