Overview
What Base64 encoding is
Base64 turns arbitrary bytes into a string made only of letters, digits, and a couple of symbols.
Many protocols and document formats are text-oriented. They mishandle raw binary — null bytes, high-bit characters, or line breaks can corrupt a payload. Base64 maps every trio of bytes to four printable characters drawn from a 64-symbol alphabet, so the result survives copy-paste, JSON, HTML attributes, and email bodies.
This tool encodes and decodes text by first converting your input to UTF-8 bytes, then applying standard Base64 (or the optional URL-safe variant). Decoding reverses the process and returns Unicode text.
Guide
How Base64 encoding works
- 1
Convert text to UTF-8 bytes
Each character becomes one or more bytes. Plain ASCII letters are a single byte; emoji and many non-Latin characters use multiple bytes.
- 2
Group bytes into sets of three
Three bytes are 24 bits. If the final group is shorter, padding bits are added so the bit length is still a multiple of six.
- 3
Split into 6-bit indexes
Each 6-bit chunk is a number from 0 to 63. That index selects a character from the Base64 alphabet.
- 4
Add padding when needed
If the original length was not a multiple of three bytes, one or two = characters are appended so the encoded string length is a multiple of four.
Example
Worked example
Encoding the text Hi (UTF-8 bytes 48 69):
- Bytes: 0x48 0x69 → 16 bits, padded to 24 bits for grouping
- 6-bit indexes select alphabet characters
- Standard output: SGk=
- URL-safe output: SGk
Alphabet
Base64 character set
Every 6-bit value maps to one of these 64 symbols. Padding uses = and is not part of the 64-character alphabet itself.
Standard alphabet · URL-safe swaps +/ for -_
| Index | Symbol | Notes |
|---|---|---|
| 0–25 | A–Z | Uppercase Latin |
| 26–51 | a–z | Lowercase Latin |
| 52–61 | 0–9 | Decimal digits |
| 62 | + (or -) | 62nd symbol (URL-safe uses -) |
| 63 | / (or _) | 63rd symbol (URL-safe uses _) |
| padding | = | Aligns output to a multiple of 4 chars |
Variants
Standard vs URL-safe Base64
Standard
Uses +, /, and = padding. Ideal for email (MIME), data URLs, and most APIs that expect classic Base64.
URL-safe
Swaps in - and _, and drops padding. Prefer this for query parameters, path segments, JWTs, and filenames.
Practice
When to use Base64
Data URLs & embeds
Inline small images or fonts in CSS/HTML with a data: URL that carries Base64 bytes.
API payloads
Ship binary fields inside JSON by encoding them as Base64 strings your client and server both understand.
Tokens & config
JWTs and many config formats store binary claims as Base64URL segments for safe transport.
Email & MIME
Attachments and non-ASCII content often travel as Base64 inside MIME parts so mail gateways do not alter the bytes.
Notes
Tips and common pitfalls
- Base64 is reversible and public — encode for transport, not secrecy.
- Whitespace in decode input is ignored by this tool, which helps when pasting wrapped MIME lines.
- Output grows by roughly one third; large files may be better sent as raw binary (multipart, blobs) instead.
- If decoding fails, check for truncated padding, the wrong alphabet toggle, or non-Base64 characters introduced by a rich-text editor.
FAQ
Frequently asked questions
- What is Base64?
- Base64 is a binary-to-text encoding that represents binary data using 64 printable ASCII characters (A–Z, a–z, 0–9, + and /). It lets you safely embed binary data — images, keys, file bytes — inside text formats such as JSON, HTML, XML, or email.
- Is Base64 encryption?
- No. Base64 is an encoding, not a cipher. Anyone can decode it. Never treat Base64 as a way to hide secrets; use real encryption when confidentiality matters.
- Is my data uploaded anywhere?
- No. Encoding and decoding run entirely in your browser with TextEncoder and btoa/atob. Nothing you type is sent to a server.
- What is the URL-safe alphabet?
- URL-safe Base64 (Base64URL) replaces + with - and / with _, and often omits = padding. That keeps the string usable inside URLs, filenames, and HTTP headers without extra escaping.
- Does it support Unicode and emoji?
- Yes. Text is encoded as UTF-8 bytes first, so accented characters, non-Latin scripts, and emoji round-trip correctly.
- Why does the output length grow?
- Base64 represents 3 bytes as 4 characters, so encoded text is about 33% larger than the raw bytes (plus optional padding). That size trade-off buys a safe ASCII-only representation.