How to use the Base64 encoder / decoder
- 1Choose Mode: Text for strings, File for images, PDFs and other files.
- 2In Text mode, set Action to Encode or Decode and type or paste into Text or Base64. The result updates as you type. For encoding, pick the Alphabet (standard or URL-safe) and optionally Wrap at 76 characters.
- 3In File mode, choose a file under File → Base64, then press Copy Base64, Copy data URI or Download.
- 4To turn Base64 back into a file, paste it (or a
data:URI) into Base64 → file and press Decode to file. The file type is detected from its first bytes.
Example
Hello, Wörld!
SGVsbG8sIFfDtnJsZCE=
13 characters but 14 bytes of UTF-8, because ö takes two bytes. 14 bytes need 19 Base64 characters, rounded up to 20 with one = of padding.
Encoding text to Base64
Base64 (RFC 4648) writes binary data using 64 safe characters: A–Z, a–z, 0–9, + and /. Every 3 bytes become 4 characters: Man is the bytes 77, 97, 110, whose 24 bits split into four 6-bit values (19, 22, 5, 46), which are T, W, F, u. When the input isn't a multiple of 3 bytes, = pads the end.
Text is first converted to bytes. This tool uses UTF-8, the encoding of the web, so any character works. The browser's built-in btoa() only accepts Latin-1 and throws an error on € or emoji, a common surprise when encoding in JavaScript. Wrap at 76 characters splits the output into lines, as MIME email (RFC 2045) requires.
Decoding Base64
Paste Base64 with Action set to Decode. Spaces and line breaks are ignored, so wrapped email bodies and PEM blocks decode directly. Missing = padding is accepted, and the URL-safe alphabet is recognized automatically. A data:image/png;base64, prefix is stripped, and its type is shown.
The decoder reports problems precisely: a character that isn't Base64 (with its position), = in the middle, or a length that can't be valid. If the decoded bytes aren't valid UTF-8 text, it tells you what kind of file they look like (PNG, PDF, ZIP…) and suggests Decode to file in File mode.
Files and images (data URIs)
In File mode any file up to 25 MB can be encoded. Images get a preview, and Copy data URI gives you a string like data:image/png;base64,iVBORw0KGgo… that works directly in HTML or CSS:
<img src="data:image/png;base64,iVBORw0KGgo…" alt="…">
background-image: url("data:image/svg+xml;base64,…");Inlining saves a request, but Base64 is about 33% larger than the file and can't be cached separately, so it suits small icons rather than photos. For SVG, URL-encoding the markup is usually smaller than Base64.
URL-safe Base64
+ and / have meanings in URLs and file names, so RFC 4648 §5 defines a URL-safe alphabet that uses - and _ instead and usually drops the = padding. JSON Web Tokens, many API keys and some cloud storage signatures use it. Choose Alphabet: URL-safe to encode that way. Decoding accepts either alphabet, with or without padding, and the footer says when the URL-safe form was detected.
Example: Hi?> is SGk/Pg== in standard Base64 and SGk_Pg in URL-safe Base64.
Base64 is encoding, not encryption
Anyone can decode Base64: there is no key. It exists so binary data can travel through systems built for text, such as email, JSON, XML and URLs. Credentials sent with HTTP Basic authentication are only Base64-encoded, which is why that scheme is safe only over HTTPS. To protect data, encrypt it (for example with AES, using a key from the encryption key generator); to fingerprint it, use the hash generator.
Is my text private?
This tool runs entirely in your browser. Your text is not uploaded to our servers.
