TC
TechnologyJanuary 28, 2025·6 min read

What is Base64 Encoding? Explained with Examples

What is Base64?

Base64 is an encoding scheme that converts binary data into a set of 64 printable ASCII characters. It's used to safely transmit binary data (images, files, binary protocols) through systems that only handle text.

The 64 characters are: A–Z, a–z, 0–9, +, / (with = used for padding).


How Base64 Works

Base64 takes 3 bytes (24 bits) of input and converts them into 4 Base64 characters (6 bits each):

1. Take 3 bytes of binary data

2. Split into four 6-bit groups

3. Map each group to the Base64 alphabet

Example:

  • Input: Hi (ASCII: 72, 105)
  • Binary: 01001000 01101001
  • Base64 output: SGk= (with = padding)

This means Base64 increases data size by approximately 33%.


Common Uses of Base64

Use CaseWhy Base64?

|---|---|

Email attachments (MIME)Email protocols handle text only
JWT tokensSafely embed JSON in HTTP headers
Data URIsEmbed images directly in HTML/CSS
API responsesEncode binary files in JSON
CookiesSome special characters are unsafe in cookies
XML/JSONBinary data can't go directly into text formats

Base64 is NOT Encryption

This is a common misconception. Base64 is encoding, not encryption:

  • It's completely reversible without any key
  • Anyone who sees Base64 data can decode it instantly
  • It provides zero security — it only changes the format

Do not use Base64 to hide passwords, API keys, or sensitive data.


Base64 Variants

VariantDifferenceUse Case

|---|---|---|

Standard Base64Uses `+` and `/`General purpose
URL-safe Base64Replaces `+` with `-`, `/` with `_`URLs, JWTs
Base64 without paddingOmits trailing `=`Some APIs prefer this

Quick Examples

InputBase64 Output

|---|---|

`hello``aGVsbG8=`
`case converter``Y2FzZSBjb252ZXJ0ZXI=`
`12345``MTIzNDU=`

Decoding Base64

Base64 decoding simply reverses the process. Use our free Base64 Encoder/Decoder tool to instantly convert text to Base64 or decode Base64 back to plain text — no setup required.