Developer Runs locally Ready to use Built-in examples No tracking

Encoding Converter

Bidirectional conversion between text and Base64, hexadecimal and binary. UTF-8 handled correctly so Chinese text never garbles. Runs locally in your browser.

Base64, HEX and binary are three notations for the same bytes: Base64 expresses arbitrary bytes with 64 printable characters, which is how binary travels through places that allow only text — email bodies, URL parameters, configuration files; HEX gives each byte two hexadecimal digits and is easy to compare by eye; binary groups bytes into 8 bits and suits inspecting individual bits.

Two things to stress. Base64 is not encryption — it has no key, anyone holding the string can reverse it, so it is for transport encoding and never for protecting sensitive data. And garbled non-ASCII text almost always comes from encoding as one legacy charset and decoding as UTF-8; keeping UTF-8 through the whole chain avoids it entirely.

How to use

  1. Choose the direction: text to Base64, HEX or binary, or back again.
  2. Paste the input and read the converted output.
  3. Keep UTF-8 throughout to avoid garbled non-ASCII text.
  4. Remember Base64 is an encoding, not encryption.

How it works

The encoding pipeline

Encoding: the text is first converted to UTF-8 bytes, then the bytes take the target form. So "Hello, world" in Base64 is SGVsbG8sIHdvcmxk, one word per group of bytes.

Base64, HEX and binary sizes

Base64 represents arbitrary bytes with 64 printable characters - 3 bytes become 4 characters, padded with = at the end; HEX writes each byte as 2 hex digits (Hi -> 48 69); binary writes each byte as 8 bits (Hi -> 01001000 01101001).

Decoding and error reporting

Decoding reverses the same steps to recover bytes, then interprets them as UTF-8. If the byte sequence is not valid UTF-8 (say, a truncated multi-byte character), the tool reports an error clearly instead of emitting mojibake.

Code example

JavaScript Encoding in the browser

// The right way: encode to UTF-8 bytes first, then to Base64
const text2b64 = (s) => btoa(String.fromCharCode(...new TextEncoder().encode(s)));
const b64ToText = (b) => new TextDecoder().decode(Uint8Array.from(atob(b), (c) => c.charCodeAt(0)));

text2b64("Hello, wörld!");              // "SGVsbG8sIHfDtnJsZCE="
b64ToText("SGVsbG8sIHfDtnJsZCE=");      // "Hello, wörld!"

Shell Command line and hexadecimal

# Text to Base64
echo -n "Hello" | base64              # SGVsbG8=

# Base64 to text
echo "SGVsbG8=" | base64 -d

# Hex dump of the bytes (xxd also works on macOS)
echo -n "Hello" | xxd -p | cut -c1-10  # 48656c6c6f

FAQ

Is Base64 encryption?

No. Base64 is only an encoding - anyone can decode it without a key, so it must never protect passwords or secrets. Its job is making arbitrary bytes text-safe, as in email attachments, Data URLs and HTTP Basic authentication transport.

Why do other Base64 tools produce mojibake for Chinese?

Many take each character's low byte, correct only for ASCII. Chinese is 3 bytes per character in UTF-8 and must be encoded as a whole. This tool always uses UTF-8, matching the browser's btoa(unescape(encodeURIComponent(s))).

Which HEX input formats are accepted?

Space-separated (48 69), continuous (4869), 0x-prefixed (0x4869) and comma-separated, any case. Odd digit counts or non-hex characters raise an error.

UTF-8 vs. GBK - what's the difference?

UTF-8 is the international standard - a Chinese character usually takes 3 bytes and all languages work; GBK is Chinese-specific at 2 bytes per character. This tool is UTF-8 throughout, so decoding GBK data shows mojibake - transcode at the source first.

How much does Base64 grow?

About 33%. Every 3 bytes of binary become 4 printable characters, padded with = as needed, so the result is roughly 4/3 of the original. It is the standard way to embed binary content safely in JSON, URLs or email.

Why must Chinese in URLs be encoded?

URLs allow ASCII only, so Chinese and special symbols become %XX percent-encoding. Spaces appear as %20 in paths and as + in query strings; servers should parse both.

Can the results be converted back?

Yes. Base64, HEX and binary are all reversible encodings - paste the output back and run the reverse direction, provided the same charset is used (UTF-8 here). Encoding changes representation, never content.