Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to plain text — instantly, in your browser
Invalid Base64 string
What Is Base64?
Base64 is a binary-to-text encoding scheme that converts data into a string of 64 printable ASCII characters. It is used extensively in web development: embedding images in HTML/CSS as data URIs, encoding authentication credentials in HTTP headers, and transmitting binary data through JSON APIs.
The encoded output is always larger than the input — approximately 33% larger — because every 3 bytes of input become 4 characters of output. For URL-safe Base64, the + and / characters are replaced with - and _ so the string can appear in URLs without percent-encoding. This variant is used in JWT tokens and many OAuth implementations.
How Base64 Encoding Works
Base64 works in groups of 3 bytes (24 bits) at a time. Those 24 bits are split into four 6-bit chunks, and each 6-bit chunk (a value from 0–63) is mapped to one of 64 characters (A–Z, a–z, 0–9, + and /). That's where the name comes from. If the input isn't a multiple of 3 bytes, = padding characters are added at the end to fill out the last group.
Worked example: the text "Hi!" is 3 bytes (72, 105, 33 in ASCII). Encoded to Base64, it becomes SGkh — 4 characters for 3 bytes, matching the expected 33% size increase.
Where Base64 Is Used
- Data URIs — embedding small images directly in CSS or HTML (
data:image/png;base64,...) to avoid an extra HTTP request. - Email attachments (MIME) — email was designed for text, so binary attachments are Base64-encoded before sending.
- JWT tokens — the header and payload of a JSON Web Token are URL-safe Base64-encoded JSON.
- Basic HTTP authentication — the
Authorization: Basicheader encodes "username:password" as Base64 (not encrypted — only use over HTTPS).
Frequently Asked Questions
Advertisement