Base64 Encoder/Decoder

Encoding

Encode and decode Base64 strings and files instantly

Text
0 B
Base64
Encoded output will appear here...

Try an example:

What is Base64 Encoding?

Base64 is a group of binary-to-text encoding schemes that represent binary data as a string of printable ASCII characters. It was originally designed for transmitting binary data over channels that only support text, such as email (MIME) and early HTTP.

The name "Base64" comes from the 64 characters used in the encoding alphabet: A-Z, a-z, 0-9, +, and /, plus = for padding.

Today, Base64 is used everywhere in web development — from data URIs in CSS and HTML, to encoding authentication tokens, API payloads, and file uploads in JSON requests.

How Base64 Encoding Works

The encoding process converts every 3 bytes (24 bits) of input into 4 Base64 characters (6 bits each):

  1. 1 Take 3 bytes of input data (24 bits total)
  2. 2 Split into four groups of 6 bits
  3. 3 Map each 6-bit value (0-63) to a character in the Base64 alphabet
  4. 4 If the input length isn't divisible by 3, pad the output with = characters

For example, the text Hi (2 bytes: 0x48, 0x69) becomes SGk=. The = indicates one byte of padding was needed.

Common Uses of Base64

  • Data URIs: Embed images, fonts, and other assets directly in CSS or HTML using data:image/png;base64,... syntax, eliminating extra HTTP requests.
  • API Payloads: Send binary files (images, PDFs, documents) as JSON string fields in REST APIs, since JSON doesn't support raw binary data.
  • Authentication: HTTP Basic authentication encodes username:password as Base64 in the Authorization header. JWT tokens also use Base64url encoding for their header and payload segments.
  • Email (MIME): Email protocols were designed for ASCII text. MIME uses Base64 to encode binary attachments so they can be transmitted over SMTP.
  • Cryptographic Keys: SSH keys, SSL certificates, and PGP keys are commonly stored in PEM format, which is Base64-encoded DER data wrapped with header/footer lines.

URL-Safe Base64 (base64url)

Standard Base64 uses + and / characters that have special meaning in URLs and filenames. RFC 4648 defines an alternative "URL and Filename Safe" alphabet:

+
becomes
-
/
becomes
_
=
padding
removed

This variant is used extensively in JWTs, OAuth tokens, and anywhere Base64 data appears in URLs or query parameters. Toggle the URL-safe switch in our tool to use this encoding.

Frequently Asked Questions

What is Base64 encoding?+

Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A-Z, a-z, 0-9, +, and /). It is commonly used to embed binary data — such as images, files, or cryptographic keys — into text-based formats like JSON, XML, HTML, email, and URLs.

Is Base64 encoding the same as encryption?+

No. Base64 is an encoding scheme, not encryption. It transforms data into a different representation but does not provide any security. Anyone can decode a Base64 string back to its original form without a key. If you need to protect data, use proper encryption (e.g., AES or RSA) before encoding it as Base64.

Why does Base64 make data larger?+

Base64 encodes every 3 bytes of input into 4 ASCII characters, resulting in roughly a 33% size increase. This overhead is the trade-off for representing arbitrary binary data using only printable text characters, which is required by many text-based protocols.

What is URL-safe Base64?+

Standard Base64 uses + and / characters, which have special meaning in URLs. URL-safe Base64 (also called base64url, defined in RFC 4648) replaces + with - and / with _, and optionally removes trailing = padding. This variant is used in JWTs, data URIs in URLs, and other web contexts.

Is it safe to decode Base64 in the browser?+

Yes. Our Base64 tool runs entirely in your browser using JavaScript's built-in btoa() and atob() functions combined with the TextEncoder/TextDecoder APIs for proper UTF-8 support. No data is ever sent to a server.

Built With

This tool uses native browser APIs — no external encoding libraries needed.