Base64 turns any data (text, an image, a file) into a string made of 64 safe characters: A–Z, a–z, 0–9, + and /. It exists because many systems were built for text only. Email, JSON, URLs and HTML attributes can't carry raw bytes safely, but they can carry Base64. You'll find it in data URIs (data:image/png;base64,…), email attachments, HTTP Basic authentication, JSON Web Tokens and API payloads that include files.
How it works
Base64 takes the input 3 bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit number (0–63) picks one character from the alphabet. The word Man shows it clearly:
Text M a n
Bytes 77 97 110
Bits 01001101 01100001 01101110
6-bit 010011 010110 000101 101110
Index 19 22 5 46
Base64 T W F u → "TWFu"Because 3 bytes always become 4 characters, Base64 output is about 33% larger than the input: 300 bytes encode to 400 characters.
What the = padding means
When the input length isn't a multiple of 3, the last group is short and is filled out with =:
"Man" → TWFu (3 bytes, no padding)
"Ma" → TWE= (2 bytes, one =)
"M" → TQ== (1 byte, two =)Many decoders, including the one on this site, also accept Base64 with the padding left off.
URL-safe Base64
+ and / have special meanings in URLs and file names, so a variant called Base64URL replaces them with - and _ and usually drops the padding. The same three bytes encode as +/+/ in standard Base64 and -_-_ in Base64URL. JWTs use Base64URL, which is why you can read a token's contents with the JWT Decoder.
Encoding and decoding in JavaScript
Browsers have btoa and atob, but they only handle characters up to code 255. An emoji throws an InvalidCharacterError, and é is silently encoded as Latin-1 (6Q==) instead of UTF-8 (w6k=). Convert to UTF-8 bytes first:
// Text → Base64, safe for any Unicode text
const encode = (text) => btoa(String.fromCharCode(...new TextEncoder().encode(text)));
// Base64 → text
const decode = (b64) => new TextDecoder().decode(Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)));
encode("Hello 😀"); // "SGVsbG8g8J+YgA=="
// Node.js
Buffer.from("Hello 😀").toString("base64"); // standard
Buffer.from("Hello 😀").toString("base64url"); // URL-safe
Buffer.from("SGVsbG8=", "base64").toString("utf8"); // "Hello"Encoding and decoding in Python
import base64
base64.b64encode("Hello 😀".encode()).decode() # "SGVsbG8g8J+YgA=="
base64.b64decode("SGVsbG8=").decode() # "Hello"
base64.urlsafe_b64encode(data) # URL-safe variantEncoding and decoding online
The Base64 Converter encodes text or any file and decodes Base64 back, as you type. It handles UTF-8 and emoji correctly, accepts standard and URL-safe Base64 with or without padding, strips data: prefixes, and shows decoded data as formatted JSON, text, an image preview or a hex dump. Nothing is uploaded: encoding and decoding happen in your browser.
Remember that Base64 is not encryption. Anyone can decode it, so it only makes data transportable, never secret. For special characters in URLs, use URL encoding instead.