Base64 Encode / Decode
Encode text to Base64 or decode Base64 strings instantly.
What is Base64?
Base64 is a binary-to-text encoding scheme that represents arbitrary binary data as an ASCII string using 64 printable characters: A–Z, a–z, 0–9, and the symbols + and /. The padding character = is appended so the encoded output length is always a multiple of four. Base64 was originally designed for safely embedding binary data in 7-bit channels such as email (MIME), where high-byte values would otherwise be corrupted by transport servers.
Modern uses of Base64 include data URIs in CSS and HTML, Basic Authentication tokens in HTTP headers, the payload section of JSON Web Tokens, and binary attachments in JSON or XML where a plain string is required. A URL-safe variant exists that replaces + with - and / with _ so the encoded string can travel inside a URL without further escaping.
This tool encodes and decodes Base64 entirely in your browser. Input is first converted to UTF-8 bytes via the standard TextEncoder, ensuring that Chinese, Japanese, Korean, emoji, and other multi-byte characters round-trip correctly. Whitespace inside Base64 input is tolerated during decoding.
Use cases
- Embed small images or fonts inline in CSS or HTML using data URIs.
- Encode binary payloads so they can travel safely inside JSON or XML.
- Decode Basic Auth tokens (the value after "Basic " in the Authorization header).
- Inspect the payload section of a JWT (the middle segment between the dots).
- Encode credentials or short messages that need to survive a 7-bit text channel.
Best practices
- Never treat Base64 as encryption — it is reversible by anyone with a few lines of code.
- Use the URL-safe variant ("-" and "_") when the encoded string is placed inside a URL.
- Strip whitespace before decoding if the source pasted in line breaks.
- Be aware that Base64 grows the payload by roughly 33%, plus the overhead of MIME line wrapping.
Code examples
const encoded = btoa(unescape(encodeURIComponent("héllo")));
// 'aMOpbGxv'
const decoded = decodeURIComponent(escape(atob(encoded)));import base64
encoded = base64.b64encode("héllo".encode("utf-8")).decode("ascii")
decoded = base64.b64decode(encoded).decode("utf-8")echo -n 'héllo' | base64 # encode
echo 'aMOpbGxv' | base64 -d # decode