Base64 Encoder/Decoder

Encode and decode Base64 strings

Base64 re-expresses arbitrary content using only A–Z, a–z, 0–9, +, / and =, so it can travel through channels that only accept plain text — HTTP headers, email, YAML, environment variables. This tool converts text to Base64 and back using the browser's own btoa and atob with a UTF-8 round trip, so non-Latin text and emoji survive intact. Nothing you paste is transmitted, which matters here: the strings people bring to a Base64 tool are usually Basic Auth credentials, JWT payloads, or the contents of a Kubernetes Secret.

How to use it

  1. Choose a direction with the two buttons at the top — Text → Base64, or Base64 → Text. Switching direction clears both boxes, so copy the current result first if you want to feed it back in.
  2. Paste your content into the input box on the left; its label changes with the direction (raw text, or a Base64 string).
  3. Press the Encode / Decode button underneath the input. Conversion is not live: after you edit the input, the right-hand box still shows the previous result until you press the button again.
  4. The result appears in the read-only box on the right. Take it with the copy button above it — that button is disabled while the output is empty.
  5. When decoding fails, the output box is cleared and a red error line appears beneath it. The encode direction never reports an error.

When it comes in handy

Read the values inside a Kubernetes Secret or CI variable

Every value in kubectl get secret -o yaml comes out Base64-encoded, so you cannot tell at a glance whether that connection string points at staging or production. Decode it here to check — and encode new values before writing them back. Values wrapped across several YAML lines can be pasted whole; the line breaks are ignored.

Build or unpack a Basic Auth credential

The blob after Authorization: Basic is just user:password in Base64. Encode one here to test an endpoint with curl, or decode the one you pulled out of a log or a capture — it usually makes the problem obvious, whether that is a typo in the username or a trailing space in the password.

Inspect a JWT payload

Split the token on . and paste the middle segment to read the claims — sub, exp, scope — and confirm whether the token really is expired or simply missing a scope. That segment uses the base64url variant; see the notes for the one substitution you need.

Decode a MIME encoded-word from an email header

Non-ASCII subject lines in raw headers look like =?UTF-8?B?SGVsbG8=?=. Paste whatever sits between ?B? and ?= to read the original text — handy when tracing a bounce or matching up subjects while debugging your own outbound mail.

Limits and behavior

  • Encoding runs btoa(unescape(encodeURIComponent(text))): the text is converted to UTF-8 bytes first, then encoded, which is why CJK text and emoji round-trip correctly. Calling btoa directly on such text throws InvalidCharacterError — the reason so many hand-rolled web converters break on anything outside English.
  • Output uses the standard Base64 alphabet (+, /, and trailing = padding) on a single line, with no 76-character MIME wrapping. For a URL query or a filename, convert it to base64url yourself: + to -, / to _, and drop the =.
  • The decoder does not accept base64url — a - or _ anywhere in the string makes it invalid. Padding is optional (SGVsbG8 and SGVsbG8= both decode), but a string whose length leaves a remainder of 1 when divided by 4 (say SGVsb) always fails. Interior spaces and line breaks are ignored, so wrapped MIME blocks and multi-line YAML values paste in fine.
  • This tool handles text only. There is no file picker and no binary output, so Base64 of a PNG, a PDF, or a PEM certificate decodes to bytes that are not valid UTF-8 and is reported as invalid — your Base64 is fine, this tool just cannot show you bytes. Use the Image to Base64 tool for data URIs. Note also that the decode error string is currently hardcoded in Chinese and appears that way in the English UI, and that it covers two different situations: illegal characters or a bad length, and valid Base64 whose bytes are not UTF-8.
  • Line endings get normalized: CRLF pasted into the input becomes LF in the browser. Encoding a Windows text file here therefore produces a different string than the command-line base64 would — one 0D byte per line. For byte-exact output, use a command-line tool.
  • Base64 is not encryption. It is a reversible re-spelling that anyone can undo, and it inflates the payload by about 33%. Its job is safe transport through text-only channels, not confidentiality.

Frequently asked questions

Why does non-English text come out garbled in other converters but not here?

The browser's btoa only accepts Latin-1 — one byte per character — so it throws or mangles anything above U+00FF. This tool converts the text to UTF-8 bytes with encodeURIComponent before encoding and reverses that on the way back, so UTF-8 holds end to end. The flip side: if someone else produced the Base64 from Latin-1 or Big5 bytes, it will usually be rejected here, because those byte sequences are not valid UTF-8.

Is anything I paste uploaded?

No. Encoding and decoding use the browser's built-in btoa and atob, which run on your device and finish there; no request carries your input anywhere. Disconnect from the network and try again to verify — the tool still works. The page itself loads third-party resources such as ads, but those requests contain none of your input or output.

Why does a whole JWT fail to decode?

Two reasons. A JWT is three segments joined by ., and . is not a legal Base64 character, so the full token fails immediately — paste only the middle payload segment. And JWTs use base64url, so replace - with + and _ with / first. You do not need to restore the padding unless the segment length leaves a remainder of 1 when divided by 4.

Can I encode an image or a file?

No — the page offers text boxes only, with no file upload. Pasting binary content into a textarea will not work either, because copying already destroyed the original bytes. For images, use the Image to Base64 tool, which reads the file directly and produces a data URI you can drop into CSS or an <img> tag.

I changed the input but the result stayed the same. Why?

Conversion is button-driven, not live. Press Encode or Decode again after every edit; until you do, the right-hand box shows the previous result. Also remember that switching direction wipes both boxes, so copy an encoded result before switching over to decode it.

It decoded, but the output is gibberish. What now?

The bytes were valid UTF-8, but they were never meant to be read — typically compressed, encrypted, or a serialized binary structure. The other possibility is that the original text used a non-UTF-8 encoding such as Big5 or Shift-JIS; that is usually rejected outright, but occasionally the bytes happen to form valid UTF-8 and you get nonsense instead. Decoding here is always UTF-8; there is no encoding selector.