toolbench.onlineby Valkyron Labs

Encode / Decode

Base64 Encode / Decode

Encode text to standard Base64, or decode Base64 back to text, including padding. Characters outside Latin-1 are rejected. Copy the result locally.

Base64 Encode / Decode

Encode or decode Latin-1 text as standard Base64.

Ready to run.

Base64

—

Output actions

Ready to copy output once your result appears.

btoa encode and atob decode

Base64 Encode / Decode runs the browser helpers btoa and atob. Encode starts selected. btoa writes the standard alphabet, with plus, slash, and equals padding. atob reads that alphabet back. The page does not switch to the URL-safe alphabet, and it does not accept a character whose code point is above 255.

How to encode or decode

  1. 1Leave Encode selected, or press Decode. The field label switches between Text to encode and Base64 to decode. Changing the mode does not rerun the previous text.
  2. 2Type or paste into the field, then press Run. A success status reads Encoded successfully. or Decoded successfully. The result panel is labeled Base64 or Decoded text.
  3. 3Press Copy output for the latest result. This tool has no download control. An exception from btoa or atob replaces the result with one fixed error sentence.

What it is good for

  • • Turning a short ASCII or Latin-1 string into padded standard Base64.
  • • Reversing a standard Base64 blob, including one that omitted the trailing equals signs.
  • • Seeing the exact failure sentence when a character cannot be encoded or the alphabet is wrong.

Example

Input

hello world

Output

aGVsbG8gd29ybGQ=

Encode mode, then Run. The space is a single byte 0x20. The trailing equals sign is the padding btoa adds for this length.

Which alphabet btoa writes

btoa walks the JavaScript string one code unit at a time and emits the standard Base64 alphabet. Digits, letters, plus, and slash appear in the body. Padding is zero, one, or two equals signs so the length is a multiple of four. hello world is eleven bytes, so the result is aGVsbG8gd29ybGQ= with one padding character. An empty field encodes to an empty string and still counts as success. The button does not insert line breaks at 76 characters, and it does not add a data: prefix or a MIME type.

Decode is atob on the field as typed. The browser's forgiving decoder ignores ASCII whitespace, so aGVs bG8= and a broken line inside the blob still return hello. Missing padding can also succeed: aGVsbG8gd29ybGQ without the equals sign returns hello world. Characters outside the standard alphabet fail. Underscore is outside that alphabet, which is why a URL-safe blob is not silently repaired here.

The two mode buttons

The group is labeled Base64 mode and contains Encode and Decode. Encode is pressed when the page opens. The buttons only change which function Run will call and which labels you see. They do not clear the field and they do not clear a previous result. If you decode, then press Encode, the old decoded text stays in the result until you press Run again.

Copy output reads the string last published by a successful or failed Run. Before the first Run, the shell has nothing to copy and reports that no output exists yet. After a failure, the copied text is the error sentence, because that sentence is written into the result. There is no second button for download and no filename.

Where standard Base64 shows up

HTTP Basic credentials are the standard alphabet of the ASCII string user:password, including padding. You can encode that string here or decode a copied Authorization value after you strip the Basic prefix yourself. The page does not add or remove the word Basic. A query string is a different encoding: percent-escapes belong on the URL encode/decode page, where a space becomes %20. Bytes shown as spaced hexadecimal pairs belong on Hex encode/decode.

A JWT segment is Base64URL. Minus and underscore are not rewritten on this page. Use the JWT decoder when the job is to read header and payload JSON. That decoder calls atob only after it maps the URL-safe characters and only on the first two segments. The guide Turn a browser request into Python or JavaScript is the place to look when the Base64 sits inside a captured request you are about to turn into code.

Latin-1 limits and the shared error sentence

btoa accepts code points 0 through 255 and throws InvalidCharacterError above that. é is U+00E9, so it encodes (héllo becomes aOlsbG8=) and atob returns é again. 你, a check mark, and an emoji are above 255, so Run fails. The catch block does not show InvalidCharacterError. Encode and decode failures both replace the result with Invalid Base64 input. Please check the input and try again. The status line repeats that sentence.

That means a UTF-8 encode of 你 is not available here, and a failed encode looks like a failed decode. If the text you care about is not Latin-1, this page is the wrong tool. It also will not decode a hex digest, and it will not guess whether a string is Base64 or a hash. Paste one value, choose the mode, and press Run once per attempt.

Rules and limitations

Encode calls btoa. Decode calls atob. The alphabet is standard Base64 with plus, slash, and optional padding. Whitespace is ignored on decode. URL-safe minus and underscore are not mapped.

Code points above 255 fail to encode. Both failures surface as the same sentence. Mode changes do not rerun. There is no download control and no data-URI wrapper.

Common problems

If a JWT segment fails, it likely still contains minus or underscore. Decode it on the JWT page. This page will not translate that alphabet.

If a non-Latin character fails, the status text still says Invalid Base64 input even though you were encoding. The character is outside the 0–255 range btoa accepts.

Frequently asked questions

Does encode turn a space into a plus sign?

No. A space is byte 0x20 and btoa writes it as part of the standard alphabet, which is why hello world contains G8 in the middle of aGVsbG8gd29ybGQ=. Plus signs appear only when the bytes call for that character.

Do I have to include the equals padding?

Not for decode. atob accepts aGVsbG8gd29ybGQ without the final equals sign and returns hello world. Encode still writes the padding.

Why does a Chinese character fail while é works?

btoa allows code points 0 through 255. é is inside that range. 你 is not. The visible error is Invalid Base64 input. Please check the input and try again. for both encode and decode failures.

Will this decode a JWT?

Only if the segment is already standard Base64. JWT segments use minus and underscore, which this page does not rewrite. The JWT decoder does that rewrite and then parses JSON.

Is my input uploaded or saved?

This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.

About this tool

Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.

Guides

Next steps

Related tools

Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.

Trust

Policies, contact, and answers

Clear pages for how Toolbench works, what we collect, and how to reach us.