Skip to content

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to text, with UTF-8, URL-safe and data URL support. Runs in your browser: nothing is uploaded.

Direction

Processed locally in your browser. Your data never leaves your device.

About this Base64 tool

Base64 turns any sequence of bytes into a string of 64 safe printable characters (letters, digits, plus and slash), so binary data can travel through systems that only handle text: email attachments, JSON fields, HTML data URLs, HTTP headers and configuration files. This tool encodes text to Base64 and decodes Base64 back to text, with proper UTF-8 handling, the URL-safe alphabet, and forgiving input handling.

How to use it

  1. Choose Encode or Decode.
  2. Type or paste your input. The result updates as you type, after a short pause.
  3. When encoding, optionally choose the URL-safe alphabet, drop the padding, or wrap lines at 64 or 76 characters.
  4. Copy or download the result, or use Swap to feed it back in the opposite direction.

Example

The text Hello, World! encodes to SGVsbG8sIFdvcmxkIQ==. The two = at the end are padding: Base64 works in groups of three bytes, and padding fills the last group. Text with non-ASCII characters is converted to UTF-8 first, so 日本語 becomes 5pel5pys6Kqe.

What the decoder accepts, and what it rejects

  • Accepted: line breaks and spaces (as in MIME and PEM), missing = padding, either alphabet, and a leading data:...;base64, prefix, which is ignored.
  • Rejected with the exact position: characters outside the alphabet, = in the middle, mixing the standard and URL-safe alphabets, and lengths that cannot be valid.
  • Reported as binary: valid Base64 whose bytes are not UTF-8 text.

Common pitfalls

  • Double encoding. Base64 of Base64 looks valid but decodes to more Base64. If a decoded result still looks like Base64, decode it again.
  • Copying from a web page or chat app can introduce non-breaking spaces or smart quotes. The error message names them.
  • Size. Base64 is about 33% larger than the original data.
  • Treating it as security. Basic authentication headers and many tokens are only Base64-encoded, which is why they must be sent over HTTPS.

Frequently asked questions

Is Base64 encryption?
No. Base64 is an encoding, not encryption: anyone can decode it instantly, with no key. Never use it to hide passwords, tokens or personal data.
Why does btoa() fail on my text but this tool works?
The browser function btoa() only accepts characters up to U+00FF and throws an error for anything else, such as Chinese, Japanese, emoji or many accented letters. This tool first converts your text to UTF-8 bytes, which is what other systems expect, and then encodes those.
What is the difference between standard and URL-safe Base64?
Standard Base64 uses + and /, which have special meanings in URLs and file names. The URL-safe variant (RFC 4648 section 5, also called base64url) uses - and _ instead and often drops the = padding. JWTs use it.
Why do I get "not valid UTF-8 text" when decoding?
The Base64 was valid, but the bytes inside are not text. That is normal for images, PDFs, archives and encrypted data. This tool decodes text; it tells you when the content is binary.
Is my data sent to a server?
No. Encoding and decoding happen in your browser. Nothing you type or paste is uploaded, stored or logged.