Base64 Encoding Guide — What It Is and How to Use It
A comprehensive guide to Base64 encoding. Use our free Base64 Encoder/Decoder to instantly encode or decode Base64 strings — all in your browser with zero uploads.
What is Base64?
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It uses 64 characters (hence the name Base64): uppercase letters A-Z, lowercase letters a-z, digits 0-9, and two additional characters (+ and /, or - and _ for URL-safe variants). The = character is used for padding. Base64 is defined in RFC 4648 and is widely used for transmitting binary data over text-based protocols like HTTP, JSON, and email.
How Base64 Encoding Works
Base64 converts binary data into a text format by processing 3 bytes at a time:
- Take 3 bytes (24 bits) of input data
- Split into 4 groups of 6 bits each
- Map each 6-bit value to a character in the Base64 alphabet (A=0, B=1, ..., Z=25, a=26, ..., +=62, /=63)
- Add padding with = characters if the input length is not a multiple of 3
Base64 Encoding Examples
Input: "Hello" Encoded: SGVsbG8= Input: "Man" Encoded: TWFu Input: "M" Encoded: TQ==
Common Use Cases for Base64
Data URIs (Images in HTML/CSS)
Base64 allows embedding images directly in HTML or CSS using data URIs: data:image/png;base64,iVBORw0KGgo.... This reduces HTTP requests but increases page size.
JSON API Transmission
Binary data like file uploads, encrypted data, or image bytes can be transmitted in JSON APIs as Base64 strings. This is the standard approach when multipart form data is not suitable.
Email Attachments (MIME)
Email attachments are encoded in Base64 as part of the MIME (Multipurpose Internet Mail Extensions) standard. This allows binary files to be transmitted over SMTP, which is a text-only protocol.
JWT Tokens
JSON Web Tokens (JWTs) use Base64url encoding (URL-safe variant of Base64) for the header and payload sections. You can decode and inspect JWT tokens using our JWT Decoder.
How to Encode/Decode Base64 Online
Using our Base64 Encoder/Decoder:
- Select mode — choose Encode or Decode
- Enter your text — type or paste the string you want to encode or decode
- Get instant results — the output appears in real time as you type
- Copy the result — click Copy to grab the output for use in your project
Base64 vs Other Encoding Schemes
| Scheme | Character Set | Efficiency | Use Case |
|---|---|---|---|
| Base64 | 64 | 75% | General purpose binary-to-text |
| Base64url | 64 | 75% | URL-safe encoding (JWT, filenames) |
| Base32 | 32 | 62.5% | Human-readable (no ambiguous chars) |
| Base16 (Hex) | 16 | 50% | Hash representations, debugging |
| Ascii85 | 85 | 80% | PostScript, PDF encoding |