</>
DevToolHub

Base64 Encode & Decode

Encode text to Base64 or decode Base64 back to plain text. Runs entirely in your browser — nothing is sent to a server.

Input

How Base64 Encoding Works

Base64 is a binary-to-text encoding scheme that represents binary data as a string of ASCII characters. It takes every 3 bytes (24 bits) of input and splits them into 4 groups of 6 bits, then maps each group to one of 64 printable characters (A-Z, a-z, 0-9, +, /).

The "64" in Base64 refers to this 64-character alphabet. If the input length isn't divisible by 3, padding characters (=) are added to the output to make the length a multiple of 4.

This tool handles Unicode text correctly by first converting it to UTF-8 bytes using the TextEncoder API before encoding, and using TextDecoder when decoding — so emojis, accented characters, and non-Latin scripts all work.

Common Use Cases

Use CaseWhy Base64?
Email attachments (MIME)SMTP only supports 7-bit ASCII; Base64 encodes binary files for safe transport
Data URIs in HTML/CSSEmbed small images or fonts directly in markup without extra HTTP requests
JWT tokensHeader and payload are Base64url-encoded JSON for URL-safe transport
Basic HTTP authenticationCredentials sent as Base64-encoded "user:password" string
Storing binary in JSON/XMLJSON has no binary type; Base64 lets you embed binary as a string field
API request bodiesSome APIs accept file uploads as Base64-encoded strings in JSON payloads

Base64 vs Base64url

Standard Base64 uses + and / as the 63rd and 64th characters, with = for padding. Base64url replaces + with - and / with _, and often omits padding. Base64url is used in JWTs and URLs where + and / would cause issues.

FAQ

Is Base64 encryption?

No. Base64 is encoding, not encryption. It provides zero security — anyone can decode a Base64 string. Never use it to "hide" passwords or sensitive data. Use proper encryption (AES, RSA) for security.

Why does Base64 make data ~33% larger?

Every 3 bytes of input become 4 characters of output (plus potential padding). The ratio is 4/3 = 1.33, meaning a 33% size increase. This is the tradeoff for using only printable ASCII characters.

Can I encode files with this tool?

This tool encodes text strings. For file encoding, you'd need to read the file as binary first. Most programming languages have built-in Base64 libraries that handle files directly (e.g., Python's base64 module, Node.js Buffer.toString('base64')).

Does this tool support Unicode?

Yes. We use TextEncoder/TextDecoder to properly handle multi-byte characters (emojis, CJK characters, accented letters). The standard btoa() function alone would fail on non-ASCII input.