Base64 Encode / Decode Online Free

Encode any text to Base64 or decode a Base64 string back to plain text. Supports Unicode, URL-safe mode, and runs entirely in your browser.

What Is Base64 Encoding?

Base64 is an encoding scheme that converts binary or text data into a string of ASCII characters using a 64-character alphabet (A–Z, a–z, 0–9, +, /). It was originally designed to safely transmit binary data through systems that only handle text — such as email (MIME), HTTP headers, and XML documents.

Base64 is not encryption. Anyone can decode a Base64 string instantly — it provides no confidentiality. It is purely a way to represent data in a text-safe format.

Common Uses for Base64

  • Email attachments: MIME encoding uses Base64 to attach files to emails that were designed for 7-bit ASCII text.
  • Data URIs: Embed images directly in HTML/CSS as src="data:image/png;base64,..." to avoid extra HTTP requests.
  • JWT tokens: JSON Web Tokens encode the header and payload as Base64url (URL-safe Base64).
  • API credentials: HTTP Basic Auth sends username:password as a Base64 string in the Authorization header.
  • SSH keys and certificates: PEM files store keys as Base64-encoded DER data between header/footer lines.

URL-Safe Base64

Standard Base64 uses + and / characters, which have special meanings in URLs. URL-safe Base64 (Base64url) replaces + with - and / with _, and typically omits the padding = characters. This variant is used in JWTs, Google's APIs, and any context where Base64 data appears in a URL.

How Does Base64 Work?

Every 3 bytes (24 bits) of input become 4 Base64 characters (6 bits each). If the input length is not divisible by 3, padding characters (= or ==) are added to reach the nearest 4-character boundary. This means Base64-encoded output is always about 33% larger than the original input.

Unicode and Base64

Standard btoa() in browsers only handles Latin-1 characters. To correctly encode Unicode text (emojis, accented characters, Chinese, etc.), this tool first converts the text to UTF-8 bytes using TextEncoder before encoding. This ensures all characters are handled correctly.

Frequently Asked Questions

Is Base64 the same as encryption? +
No. Base64 is an encoding scheme, not encryption. It has no key, no secret, and anyone can instantly decode it. Never use Base64 to protect sensitive data — use proper encryption (AES, RSA) for that purpose.
Why is Base64 output longer than the input? +
Base64 encodes every 3 bytes as 4 characters, which is a 4/3 ratio — roughly 33% overhead. A 100-byte input produces about 136 Base64 characters, including padding.
What is URL-safe Base64? +
URL-safe Base64 replaces + with - and / with _ so the output can be included in URLs without percent-encoding. It also typically drops the = padding characters. Used in JWTs and Google APIs.
Can I encode images to Base64 here? +
This tool handles text input. For image files, use a dedicated file-to-Base64 converter. Once you have the Base64 string, you can embed it in HTML as a data URI: <img src="data:image/png;base64,[string]">
Is my data safe? +
Yes. All encoding and decoding happens in your browser using JavaScript. No data is sent to any server or stored anywhere.