Base64 Encoder / Decoder

Encode plain text or binary data to Base64, or decode a Base64 string back to readable text. Supports full Unicode and UTF-8. Nothing is uploaded — runs entirely in your browser.

Text Input
Waiting for input…
Output

        

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data as a sequence of printable ASCII characters. It uses an alphabet of 64 characters: uppercase letters A–Z, lowercase letters a–z, digits 0–9, and the symbols + and /, plus = for padding. Every 3 bytes of input becomes 4 Base64 characters, which is why Base64-encoded data is approximately 33% larger than the original.

This tool encodes and decodes in your browser — nothing is uploaded to any server. It handles full Unicode and UTF-8, so emoji, accented characters, and non-Latin scripts all encode and decode correctly.

Encode vs Decode

  • Encode (Text → Base64) — converts plain text into a Base64 string. The output contains only safe ASCII characters, making it suitable for embedding in URLs, JSON, HTML attributes, and anywhere that cannot safely contain raw binary.
  • Decode (Base64 → Text) — reverses the process, taking a Base64 string and recovering the original text. The input must be valid Base64 — if it contains characters outside the Base64 alphabet (other than whitespace), decoding will fail.

Common uses of Base64 encoding

  • HTTP Basic Authentication — the Authorization header encodes credentials as username:password → Base64. For example: Authorization: Basic dXNlcjpwYXNz.
  • Data URIs — embedding images, fonts, or other binary files directly in CSS or HTML using the data:image/png;base64,… URI scheme, eliminating additional HTTP requests.
  • JWT tokens — the header and payload sections of a JSON Web Token are Base64URL-encoded (a URL-safe variant that replaces + with - and / with _).
  • Email MIME encoding — binary attachments in emails are Base64-encoded because SMTP was designed for 7-bit ASCII text.
  • API payloads — encoding binary data (images, files, signatures) for inclusion in JSON request or response bodies which require string values.
  • Environment variables — encoding multi-line certificates, private keys, or JSON config blobs as a single-line Base64 string for storage in environment variables.

Base64 vs Base64URL

Standard Base64 uses + and / which are special characters in URLs. Base64URL is a URL-safe variant that replaces + with - and / with _, and omits the = padding. Base64URL is used in JWTs, OAuth tokens, and anywhere a Base64 value appears in a URL or filename. This tool uses standard Base64. If you need to decode a JWT payload, use the JWT Decoder which handles Base64URL automatically.

Why does Base64 add ~33% overhead?

Base64 encodes every 3 bytes (24 bits) as 4 ASCII characters (each representing 6 bits). 3 bytes → 4 characters = 4/3 ≈ 1.33× the original size. With line breaks and padding, real-world overhead is typically 33–37%. This size increase is the trade-off for making binary data representable as plain text.

Frequently asked questions

No. Base64 is an encoding scheme, not encryption. It is completely reversible and provides no secrecy — anyone can decode a Base64 string without a key. Never use Base64 to "hide" sensitive data. Use proper encryption (AES, RSA) for confidentiality.

The = signs are padding characters. Base64 works in blocks of 4 characters. If the input length is not a multiple of 3 bytes, padding is added to make the output length a multiple of 4. One = means 1 byte of padding was needed; == means 2 bytes. The padding can be safely stripped in contexts that know the expected output length (like JWTs).

Use the built-in atob() function: atob("SGVsbG8=") returns "Hello". For Unicode text, use: decodeURIComponent(atob(base64).split("").map(c => "%" + c.charCodeAt(0).toString(16).padStart(2,"0")).join("")). The encode direction uses btoa().

This tool encodes text input (including Unicode). To encode a binary file such as an image, you need a tool that reads binary data — browser-based file readers or command-line tools (base64 filename on macOS/Linux, or certutil -encode on Windows) are better suited for binary file encoding.

No. All encoding and decoding happens in your browser using JavaScript's native btoa() and atob() functions. Nothing is uploaded to MockServer or any other server.