Base64 Encode / Decode
Base64 encode text or files (image → data URI) and decode. Binary-aware with previews.
This free Base64 encoder and decoder runs entirely in your browser. Text, files, and images are converted locally and never uploaded, so it is safe for API keys, tokens, and private documents. It handles full UTF-8 (emoji, accents, any script), encodes whole files into data URIs, decodes binary payloads to downloadable files with image previews, and supports the URL-safe alphabet used by JWTs.
How to use
- Pick Encode or Decode with the mode toggle.
- When encoding, choose a source: Text for the editor, or File for the drop zone (any file type, up to 10 MB).
- Type or paste your input (the Paste, Sample, and Clear buttons sit above the editor), or drop a file.
-
Toggle URL-safe if you need the
-/_alphabet without padding. - Copy or download the live output. The Swap button moves a valid result back to the input and flips the mode, so you can round-trip in one click.
Worked example
Encoding Hello, World! produces
SGVsbG8sIFdvcmxkIQ==. The trailing
== is padding, added so the output length is a
multiple of four. With URL-safe enabled, an input like
>>> becomes Pj4- instead of
Pj4+: + turns into -,
/ into _, and padding is dropped.
That is exactly the variant JWTs use: paste either segment of a
token into Decode mode with URL-safe on and you'll see the JSON
header or payload.
Files, data URIs, and images
File mode reads your file locally and shows two outputs: the
raw Base64 string and a complete data URI such as
data:image/png;base64,iVBORw0…. A data URI embeds
the whole file in a single string, so you can drop a small icon
straight into HTML
(<img src="data:image/png;base64,…">) or a
CSS background-image: url(…) with no extra HTTP
request. The file's name, size, and MIME type are shown so you
can sanity-check what you encoded.
Decoding is binary-aware. If the decoded bytes are valid UTF-8, you get plain text. If not, the tool reports Decoded data is binary (N bytes) and offers a "Download decoded file" button instead of printing garbage. If the bytes look like a PNG, JPEG, GIF, or WebP, it renders an inline image preview too.
Notes: decoding tolerates whitespace and line breaks, so Base64 wrapped at 64 or 76 columns, such as PEM certificates and MIME email attachments, decodes without manual cleanup. Missing padding is repaired automatically, and invalid input shows a clear error (with Swap disabled) rather than corrupting your text.
FAQ
More questions? Browse the full FAQ.
Working with web data in other shapes? Percent-encode query strings with the URL encoder and decoder, or fingerprint a file's contents with the SHA-256 and MD5 hash generator.