How to use Base64 Encoder & Decoder
The Base64 Encoder / Decoder converts binary data or plain text to and from Base64 encoding — a scheme that represents arbitrary bytes using only 64 printable ASCII characters. It is widely used to embed images inline in CSS, transmit binary attachments over text-based protocols such as email (MIME) and JSON, and store compact binary data in cookies and JWTs.
- Choose the operation: Encode (text or file → Base64) or Decode (Base64 → text).
- For encoding, paste plain text into the input or upload a binary file.
- For decoding, paste a Base64 string into the input field.
- Select the variant if needed: standard Base64 or URL-safe Base64 (- and _ instead of + and /).
- Click Convert and copy the result from the output panel.
Your data never leaves your device — 100% private processing.
How Base64 encoding works
Base64 takes every 3 bytes of input (24 bits) and splits them into four 6-bit groups, each mapped to one of 64 printable characters (A–Z, a–z, 0–9, +, /). Because 3 input bytes become 4 output characters, the encoded size is always 133% of the original. If the input length is not divisible by 3, one or two = padding characters are appended to make the output length a multiple of 4.
Standard vs URL-safe Base64
Standard Base64 uses + and / which have special meaning in URLs (query-string separator and path separator), so embedding standard Base64 in a URL requires percent-encoding. URL-safe Base64 (RFC 4648 §5) replaces + with - and / with _, making the encoded value safe to use directly in URL paths and query strings without additional encoding. JWTs use URL-safe Base64 without padding characters.
| Variant | Characters 62–63 | Padding | Use case |
|---|---|---|---|
| Standard (RFC 4648 §4) | + and / | = required | MIME, email, file embedding |
| URL-safe (RFC 4648 §5) | - and _ | Optional | JWT, URL parameters, filenames |
| MIME | + and / | = with line breaks | Email attachments (76-char lines) |
Worked examples
Encode text to Base64
Inputs: 'Hello'
Result: SGVsbG8=
Decode Base64 to text
Inputs: SGVsbG8=
Result: 'Hello'
Standard vs URL-safe
Inputs: bytes producing + / =
Result: URL-safe swaps + → -, / → _ and drops = padding
Base64 vs URL encoding vs HTML entities
| Encoding | What it represents / escapes | Example | Typical use |
|---|---|---|---|
| Base64 | Any bytes → 64 ASCII characters | 'Hello' → SGVsbG8= | Binary in JSON, data URIs |
| URL (percent) encoding | Unsafe/reserved URL characters → %XX | 'a b&c' → a%20b%26c | Query strings, URL paths |
| HTML entities | Markup characters < > & " → entities | '<div>' → <div> | Showing text safely in HTML |
Glossary
- Base64
- A binary-to-text encoding scheme using 64 printable ASCII characters to represent arbitrary bytes.
- Padding
- The = characters appended to Base64 output to make its length a multiple of 4.
- MIME
- Multipurpose Internet Mail Extensions — a standard that uses Base64 to encode binary email attachments.
- URL-safe Base64
- A variant that substitutes + with - and / with _ to avoid conflicts with URL syntax.
- Data URI
- A URL prefixed with data: that embeds file content (often Base64-encoded) directly in HTML or CSS.
Related reading
Frequently Asked Questions
Why use Base64 Encoder & Decoder?
- Encode binary data to Base64 for safe transmission over text-based protocols like MIME and JSON
- Decode a Base64 JWT segment to inspect its raw JSON payload
- Switch between standard and URL-safe Base64 variants to match the target protocol
- Convert an image file to a data URI for direct embedding in HTML or CSS
Common use cases
- Encode a binary file to Base64 to include it in a JSON API request body
- Decode a Base64-encoded email attachment to verify its MIME content type
- Inspect the payload segment of a JWT by decoding its Base64URL component
- Convert an image to a data URI for embedding in an HTML email template
- Encode credentials for an HTTP Basic Authorization header
Get weekly tool tips & updates
New tools, power-user tips, and productivity hacks — delivered free every Friday.
No spam, ever. Unsubscribe with one click.
Related Developer Tools
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Includes syntax highlighting, error detection, and a collapsible tree view — free, private, in-browser.
Password Generator
Generate strong, secure, random passwords instantly. Uses the Web Crypto API — nothing is sent to any server, so your passwords stay private.
Base64 to PDF
Paste a Base64 string or data URI and convert it into a downloadable PDF instantly. Includes validation, preview, and in-browser processing for privacy.
PDF to Base64
Upload a PDF and get raw Base64 or data URI output instantly. Includes copy-ready output, line-wrap options, and in-browser privacy-safe processing.
Image to Base64
Convert images to Base64 strings or data URIs online with instant output. Free, private, and processed entirely in your browser.
Regex Tester
Test and debug regular expressions online. See live matches, capture groups, and replace output. Free, private, instant.
Explore all Developer Tools.