What is Base64?
Base64 is an encoding scheme that converts any data — text, images, files — into a string made of just 64 “safe” characters: uppercase and lowercase letters, digits, + and /. Many systems were built to carry plain text and can break when they meet raw binary data or unusual characters. Base64 wraps the data in a format these systems can carry without corrupting it.
You see Base64 every day without noticing: in email attachments, in images embedded directly in web pages, in the middle section of JSON Web Tokens (JWTs) and in HTTP Basic Authentication headers.
How to Use the Base64 Tool
- Choose Encode to Base64 or Decode from Base64.
- Type or paste your input. Use Paste to insert from the clipboard.
- The result appears immediately on the right. Copy it with one click.
- If you try to decode something that isn’t valid Base64, you’ll see a clear error instead of garbage output.
Examples
| Text | Base64 |
|---|---|
Hello | SGVsbG8= |
Hello, India! | SGVsbG8sIEluZGlhIQ== |
नमस्ते | 4KSo4KSu4KS44KWN4KSk4KWH |
Notice that the Hindi word produces a longer string: each Devanagari character takes 3 bytes in UTF-8, and Base64 then adds about a third on top.
How Base64 Works
- The text is converted to bytes (using UTF-8).
- The bytes are split into groups of 3 (24 bits).
- Each 24-bit group is split into four 6-bit pieces.
- Each 6-bit value (0–63) is mapped to one character of the Base64 alphabet.
- If the last group has fewer than 3 bytes,
=padding is added.
For “Man”, the bytes 77, 97, 110 become the bits 010011 010110 000101 101110, which map to TWFu.
Common Uses
- Data URIs: embedding small images or icons directly in HTML or CSS, e.g.
data:image/png;base64,iVBOR.... - Email attachments: the MIME standard uses Base64 to send files through mail servers.
- APIs: sending files or binary data inside JSON.
- Authentication headers: HTTP Basic Auth sends
username:passwordin Base64 — which is why it must only be used over HTTPS. - JWTs: the header and payload of a token are Base64URL-encoded and can be read by anyone.
Base64 vs Base64URL
Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe variant replaces them with - and _ and often drops the = padding. If a string from a URL or JWT fails to decode here, replace - with + and _ with /, then try again.
Related Tools
- URL Encoder / Decoder — percent-encode text for links.
- Text to Binary — see the raw bits behind each character.
- SHA-256 Generator — for one-way hashing rather than encoding.