Base64 Encoder / Decoder
Encode text or files to Base64 and decode Base64 strings instantly in your browser. Free, private, and no upload required.
Encode text or files to Base64 and decode Base64 strings instantly in your browser. Free, private, and no upload required.
Base64 is an encoding scheme that represents binary data as ASCII text using 64 printable characters: A-Z, a-z, 0-9, plus (+), and slash (/), with equals (=) used for padding. The format was originally designed to make binary attachments survive 7-bit-clean email transports, but it has expanded to dozens of uses today: data URLs in HTML, JSON containing image data, JWT payloads, basic authentication headers, and any text-based protocol that needs to carry bytes.
Encoding takes 3 bytes of input and produces 4 ASCII characters of output. The output is therefore 33% longer than the input — which is the cost of fitting binary into a text-safe format. Decoding reverses the process exactly, recovering the original bytes from the encoded text.
This tool handles both directions. Encode mode takes text input (or a binary file via upload) and produces base64 text. Decode mode takes base64 text and produces the original text or downloadable binary. URL-safe variant (using - and _ in place of + and /) is supported for tokens and identifiers.
Base64 is the standard way to embed binary data in text-only contexts. Inline images in HTML use data URLs (data:image/png;base64,...) so a small icon can ship with the page without a separate request. JSON payloads carrying images, certificates, or signatures encode them as base64 strings. JWT tokens are three base64-encoded segments separated by dots.
Base64 also normalizes character handling for protocols that mishandle 8-bit binary. Authentication headers (Basic auth uses base64), email attachments, configuration files containing keys, and many APIs require base64 because binary cannot pass through their pipelines reliably.
Paste data, choose direction.
Base64 maps every 6 bits of input to one of 64 output characters. Three input bytes (24 bits) produce four output characters. When the input length is not a multiple of 3, the encoder appends one or two equals signs to pad the output to a multiple of 4 characters.
URL-safe base64 (defined in RFC 4648 section 5) replaces + with - and / with _ to produce strings safe to use in URLs and filenames without further escaping. The padding equals signs are sometimes omitted in URL-safe contexts; decoders typically accept both forms.
JavaScript's btoa and atob handle ASCII directly but fail on non-ASCII strings. For UTF-8 text, the converter uses TextEncoder/TextDecoder to convert between text and binary, then base64-encodes the binary. This handles emoji, accented characters, and non-Latin scripts correctly.