Developer Tools

Base64 Encoder / Decoder β€” Text & File Encoding Online

Encode or decode Base64 strings instantly β€” supports plain text, Unicode, and file upload up to 2 MB. 100% browser-based, your data never leaves your device.

0 chars
πŸ”’Your data never leaves your browser β€” all encoding and decoding runs locally in JavaScript.

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that converts arbitrary binary data β€” or any string of bytes β€” into a sequence of 64 printable ASCII characters: A–Z, a–z, 0–9, +, and /, with = used as padding. The name comes from the 64 characters in its alphabet.

The core reason Base64 exists is that many systems β€” email (MIME), HTTP headers, HTML data URIs, JSON payloads, and configuration files β€” were designed for text, not arbitrary binary data. Encoding binary as Base64 makes it safe to transmit through these channels without corruption. Every 3 bytes of binary input become exactly 4 Base64 characters, which means encoded output is roughly 33% larger than the original.

You encounter Base64 constantly in web development: images embedded in CSS as data:image/png;base64,…, JWT tokens (which are three Base64url-encoded sections joined by dots), API keys stored in environment variables, and SSH public keys all use Base64 encoding.

Base64 vs Base64url β€” What's the Difference?

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 = character. JWT tokens use Base64url. This tool produces standard Base64 β€” if you need Base64url, replace +β†’- and /β†’_ in the output.

How to Encode or Decode Base64

  1. Text tab: Paste your plain text or Base64 string into the input box, then click Encode to Base64 or Decode from Base64.
  2. File tab: Drag and drop any file (up to 2 MB) onto the drop zone, or click to browse. The tool reads the file and outputs its Base64 representation instantly β€” useful for embedding images, fonts, or binary assets.
  3. Swap: Use the Swap button to move the output back into the input field for further processing.

FAQ

Frequently Asked Questions

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that converts arbitrary bytes into a sequence of 64 printable ASCII characters: A–Z, a–z, 0–9, +, and /. It is used to safely transmit binary data β€” such as images, files, or binary API payloads β€” through systems that were designed to handle text, such as email (MIME), HTTP headers, HTML data URIs, and JSON.

How do I encode a file to Base64?

Switch to the File tab, then drag and drop your file onto the drop zone or click to browse. The tool reads the file in your browser using the FileReader API and outputs the Base64 string immediately. The maximum supported file size is 2 MB. The output is the raw Base64 data without the "data:mime;base64," prefix β€” add that prefix back if you need a data URI for use in CSS or HTML.

What is the difference between Base64 and Base64url?

Standard Base64 uses + and / characters, which are reserved in URLs and must be percent-encoded if used in a query string. Base64url is a URL-safe variant that replaces + with - and / with _, and omits the trailing = padding characters. JWT tokens use Base64url. This tool produces standard Base64 β€” to convert to Base64url, replace + with - and / with _ in the output.

Why does Base64 output end with == or =?

Base64 encodes data in blocks of 3 bytes into 4 characters. When the input length is not a multiple of 3, padding characters (=) are added to make the output a multiple of 4. One = means the last block had 2 bytes; two == means it had 1 byte. This padding is part of the standard and ensures decoders know where the data ends.

Does this tool support Unicode and emoji?

Yes β€” the tool uses the browser's TextEncoder API to convert your text to UTF-8 bytes before encoding to Base64. This means emoji, Chinese characters, Arabic script, and any other Unicode text is handled correctly. Without TextEncoder, btoa() would throw an error for characters outside the Latin-1 range.

Related Tools

← All tools