Skip to main content

What is Base64 encoding?

Base64 encoding is a binary-to-text encoding scheme that represents arbitrary binary data as a sequence of printable ASCII characters. It is one of the most widely used encoding formats in computing, appearing in email attachments, JWTs, data URIs, API payloads, and TLS certificates.

PropertyValue
Encoding standardRFC 4648 §4 (text encoding) / RFC 2045 (MIME)
URL-safe variantRFC 4648 §5 — Base64URL
AlphabetA–Z, a–z, 0–9, +, / (64 characters)
Padding character= (makes output length a multiple of 4)
Size overhead~33% larger than the source bytes
Reversible without a keyYes
Provides encryptionNo

Origins and purpose

The name comes from the 64 printable characters that make up the encoding alphabet: uppercase A–Z, lowercase a–z, digits 0–9, and the symbols + and / (with = used as padding). This alphabet was chosen because all 64 characters are unambiguously representable in every 7-bit ASCII-compatible system.

Base64 was standardized as part of MIME (Multipurpose Internet Mail Extensions) in RFC 2045 in 1996, solving a concrete problem: SMTP email servers only transported 7-bit ASCII text. Attaching a binary file — an image, a PDF, an executable — required encoding its bytes as printable characters first. Base64 became that encoding layer and has never gone away.

How Base64 encoding works

Base64 processes input in 3-byte groups (24 bits). Each group is split into four 6-bit values, and each value is mapped to one of the 64 alphabet characters. The result is that every 3 bytes of binary input become 4 printable ASCII characters — roughly 33% larger than the original.

Example: encoding "yes"
y  →  0x79  →  01111001
e  →  0x65  →  01100101
s  →  0x73  →  01110011

24 bits  →  011110 010110 010101 110011
            30     22     21     51
             e      W      V      z

Result: "eWVz"
Try encoding "yes"

For a complete step-by-step walkthrough of the algorithm including padding and the full 64-character lookup table, see How Base64 works.

Is Base64 encryption?

No. Base64 is encoding, not encryption. Encoding is a reversible transformation with no secret key — anyone who receives Base64 data can decode it immediately using any Base64 decoder, including this tool. The purpose of Base64 is safe transport and storage, not confidentiality.

If you need to protect data, use a proper encryption algorithm (AES-GCM, RSA-OAEP) before or after encoding. Many encrypted payloads are then Base64-encoded for transport — but the security comes from the encryption, not the encoding.

Base64 vs. hexadecimal

Both Base64 and hexadecimal (hex) encode binary data as printable text, but with different trade-offs:

PropertyBase64Hex
Output size~33% larger~100% larger
Alphabet size64 chars16 chars (0–9, a–f)
Human readableLess soMore so (byte boundaries clear)
Common usesEmail, JWT, data URI, PEMHashes, color codes, memory dumps

Base64 is preferred when minimizing output size matters. Hex is preferred when human readability of individual bytes matters, such as inspecting cryptographic hashes.

Where you encounter Base64

Base64 encoding is embedded in everyday web and network infrastructure:

  • ·JSON Web Tokens (JWT)all three segments are Base64URL-encoded
  • ·Email attachmentsMIME Content-Transfer-Encoding: base64
  • ·Data URIsdata:image/png;base64,… in HTML and CSS
  • ·PEM certificatesTLS certs, SSH keys, and GPG keys
  • ·HTTP Basic AuthAuthorization: Basic base64(user:pass)
  • ·Binary in JSON APIsimages, file chunks, or keys as strings
  • ·WebSocket framesbinary protocol data encoded for text channels

See Base64 use cases for detailed examples and copy-pasteable code for each scenario.

When NOT to use Base64

Base64 solves a specific problem — binary data in text-only channels — and should not be reached for outside that context:

  • For security or encryptionBase64 is trivially reversible without any key. Storing a password or secret as Base64 provides no protection. Use a proper encryption algorithm (AES-GCM, ChaCha20) or a password hash (bcrypt, Argon2) instead.
  • When binary transport is availableHTTP/2 and gRPC carry binary frames natively. Encoding a request body as Base64 over these protocols adds the 33% overhead with no benefit. Use multipart/form-data or raw binary content types for file uploads.
  • For large files where overhead mattersA 1 GB file becomes ~1.37 GB when Base64-encoded. For bulk data transfers, streaming protocols or binary-safe channels are far more efficient. Base64 is appropriate for small-to-medium payloads (roughly up to a few MB).
  • As a checksum or integrity mechanismBase64 encoding does not detect corruption or tampering. It carries whatever bytes it was given, errors included. Use a cryptographic hash (SHA-256) or a MAC (HMAC-SHA256) for integrity verification.

About base64tool

base64tool is a fast, private Base64 utility built on a single principle: your input never leaves your browser. Every encode, decode, and file upload runs locally using the browser's native TextEncoder, TextDecoder, and FileReader APIs — no server, no network requests, no analytics.

It supports standard Base64, URL-safe Base64 (Base64URL) for use in JWTs and filenames, and three character set options: UTF-8 (default), ASCII, and Latin-1 for legacy compatibility. Files can be encoded by uploading or dragging and dropping them directly onto the page.

Open the encoder / decoder

Frequently asked questions

Is Base64 a form of encryption?

No. Base64 is encoding, not encryption. It is fully reversible without any key — anyone who receives Base64-encoded data can decode it instantly. Never use Base64 to protect sensitive information. Use proper encryption (AES, RSA) for that.

Why does Base64 output end with = or ==?

The = characters are padding. Because Base64 works in 3-byte groups, if the input length is not a multiple of 3, one or two = characters are added to make the output a multiple of 4 characters. One = means one byte of padding; == means two.

How much larger is Base64 output compared to the original?

Base64 output is approximately 33% larger than the input. Every 3 bytes of input become 4 characters of output (4/3 × original size), plus any padding.

What is the difference between Base64 and Base64URL?

Standard Base64 uses + and / as the 62nd and 63rd characters. URL-safe Base64 (Base64URL, defined in RFC 4648 §5) replaces them with - and _, making the output safe to embed in URLs, filenames, and HTTP headers without percent-encoding. JWTs use Base64URL.

Can Base64 handle Unicode and emoji?

Yes — as long as the text is first serialized to bytes using UTF-8. Base64 operates on bytes, not characters. base64tool uses the Web TextEncoder API to serialize UTF-8 automatically, so emoji and any Unicode character encode and decode correctly.

Is Base64 the same as Base32 or Base58?

No. Base32 uses a 32-character alphabet (A–Z and 2–7) and produces ~60% larger output than the original, used in TOTP/HOTP codes and some domain systems. Base58 (used in Bitcoin) drops visually ambiguous characters like 0, O, l, and I. Base64 is the most widely used and produces the smallest encoded output of the three.