Base64 Encode / Decode

Encode plain text to Base64 or decode Base64 back to plain text. Auto-detects which direction. Browser-only — your text never leaves the page.

Example: Hello WorldSGVsbG8gV29ybGQ=

Base64 encodes binary data as ASCII text using a 64-character alphabet (A–Z, a–z, 0–9, +, /). It expands the input by ~33% but produces output that survives email, URLs, JSON, and any text-only transport.

This tool auto-detects direction: if the input looks like a valid Base64 string, it decodes; otherwise it encodes.

How the encoding works

Base64 encoding maps binary data to a 64-character alphabet (A–Z, a–z, 0–9, +, /) as specified by RFC 4648. The input text is first encoded as UTF-8 bytes. These bytes are grouped into 24-bit blocks, each split into four 6-bit values (2^6 = 64) and mapped to the alphabet. If the last block has fewer than 24 bits, it is padded with zero bits and the output is padded with '=' characters to maintain a multiple of 4 characters. The tool auto-detects the operation: if the input matches the pattern of valid Base64 (alphabet characters and proper padding length), it attempts decoding; otherwise, it encodes. All processing occurs entirely in the browser using JavaScript's native btoa and atob functions, extended with a UTF-8 byte converter to handle non-ASCII characters.

How to use this encoder

  1. Type or paste your text into the input box.
  2. The tool automatically determines whether to encode or decode based on the input content.
  3. Click the 'Encode/Decode' button to process.
  4. Copy the result from the output box.

Edge cases worth knowing

Non-ASCII characters
When encoding non-ASCII characters, the tool first converts the string to UTF-8 bytes, which increases the Base64 output length accordingly.
Whitespace in input
Decoding ignores whitespace characters (spaces, newlines, tabs) to tolerate formatting from other sources.
Invalid characters
If the input contains characters outside the Base64 alphabet and cannot be decoded, the tool treats it as plain text and encodes it instead.

Encoding pro tips

  • For URL-safe Base64, replace '+' with '-' and '/' with '_' and strip '=' padding manually.
  • Base64 expands data by ~33%, so consider compression before encoding if size matters.
  • Since the tool runs entirely client-side, it is safe for sensitive data—no text is sent to a server.
  • Always verify padding: valid Base64 length is a multiple of 4 characters.

vs other encoders

Here's how this tool compares to common command-line and programming alternatives.

This toolPython base64 moduleNode.js Buffer
Input conveniencePaste-and-click, no setupRequires writing a scriptRequires Node.js runtime
UTF-8 handlingAutomatic via browserManual encoding to bytesNative support
AvailabilityAny modern browser, no installPython environment neededNode.js environment needed

A bit of history

Base64 encoding was first introduced for electronic mail in the late 1980s as part of the MIME (Multipurpose Internet Mail Extensions) specification (RFC 1341, later RFC 2045). It was designed to transmit binary data reliably over text-only protocols like SMTP, which could corrupt non-ASCII characters. The name 'Base64' reflects its use of a 64-character alphabet. The encoding was later adopted in many other contexts, including data URIs, XML, and JSON Web Tokens (JWT).

When to use this encoding

Embedding images in CSS or HTML

data:image/png;base64,... URIs let you inline images directly in HTML or CSS. This tool encodes the bytes; paste them after the prefix.

Encoding API tokens

Basic auth ("Authorization: Basic") expects a Base64-encoded "user:pass" string. Encode your credentials before pasting into a request header.

Decoding JWT payloads

JSON Web Tokens are three Base64-encoded parts separated by dots. Decode the middle part to read the claims (header and signature work the same way).

Email attachment debugging

Email attachments are Base64-encoded inside MIME parts. Pasting raw email source into the decoder reveals the original content.

Quick binary safe transport

Need to send binary content through a JSON API? Base64-encode it; decode on the receiving end.

Encoding FAQ

Is Base64 encryption?

No. It's encoding — anyone can decode it. It's for transport, not security. To secure data, encrypt before encoding.

Why does my Base64 output have an =?

Base64 output is padded to a multiple of 4 characters. = is the padding character — one or two are added as needed.

How does the auto-detect work?

If the input is only Base64-alphabet characters and its length is a multiple of 4, the tool tries to decode. If decoding produces valid UTF-8, that wins. Otherwise it encodes.

Does it handle Unicode?

Yes. The tool encodes UTF-8 bytes for non-ASCII input. Most other Base64 tools fail on emojis or accented letters; ours handles them correctly.

Embed our tools on your website

Free for any site. No signup. Iframe loads from our servers and stays up-to-date automatically.

📋 Embed the Word Counter

Copy this snippet:

Live preview:

📋 Embed this Base64 Encode / Decode

Copy this snippet:

Live preview:

Want more options? All embeddable tools →