b2KIT

Unicode Encoder / Decoder

Convert text to Unicode escape sequences (\uXXXX) and decode Unicode-escaped strings to readable text.

Tested tool guide Tested browser tools Checked August 16, 2026

What Unicode Encoder / Decoder does, with a checked example

This tool runs the same transformation in both directions. Encode: each character's code point is looked up, and every non-ASCII character is rewritten as \uXXXX, a backslash-u followed by four hex digits, while ordinary letters, digits, and punctuation pass through unchanged. Decode: each \uXXXX found in the text is converted back to the character it names, and everything else is left alone. The surprise is that four hex digits can name nothing above U+FFFF, so emoji come out as surrogate pairs, two escapes for one character, and decoding a lone half of a pair gives the replacement character, not an error.

Worked example

A concrete input and expected output from the current implementation.

Input

naïve café

Expected output

na\u00efve caf\u00e9

ï is code point U+00EF and é is U+00E9, so both become four-digit escapes; every other character in the input is printable ASCII and is copied through unchanged.

How the result is produced

1

Encoding

The encoder walks the input character by character. Printable ASCII - letters, digits, and common punctuation - is copied through unchanged, so most output stays readable. Everything else is written as \u plus four hex digits naming the code point: é becomes \u00e9. Characters above U+FFFF, like emoji, cannot fit in four digits, so they become a surrogate pair of two \uXXXX escapes that decode back to the one original character.

2

Decoding

The decoder scans the input for the pattern \u followed by exactly four hex digits. Each match converts to the code point it names and renders as that character; all surrounding text passes through unmodified. A matching pair of surrogate escapes is reassembled into the single astral character it represents, which is why an emoji encoded as two escapes decodes back to one character.

Good uses

  • Embedding names, quotes, and symbols in source code or config files that must remain pure ASCII, so a tool with a different encoding cannot corrupt them later.
  • Reading server logs, error dumps, or JSON payloads that show strings as \u00e9-style escapes instead of the characters they mean.
  • Moving text through channels that mangle UTF-8 - legacy databases, old email pipelines, cross-language scripts - where \uXXXX escapes survive byte for byte.

Limits and checks

  • Four hex digits name nothing above U+FFFF. Emoji and rare scripts therefore appear as surrogate pairs such as \uD83D\uDE00; count a pair as one character, and decoding only one half produces the replacement character U+FFFD, not an error.
  • Decode is not the exact inverse of encode for text that already contains a literal backslash. A backslash followed by hex-like letters can itself be mistaken for an escape on the way back in; whether the round trip preserves your original depends on how the encode side handles backslashes, so test a sample containing one before relying on reversibility.
  • Escapes are not canonical: \u00e9, \u00E9, and the character é itself are all the same thing, and hex digits may be upper or lower case. Comparing two escaped strings byte for byte will call identical text different whenever casing differs.

Common questions

Why does my emoji come out as two \uXXXX escapes?

Because \uXXXX holds one 16-bit code unit, and four hex digits can name nothing above U+FFFF. Emoji and other astral characters exceed that range, so they encode as a surrogate pair - two escapes like \uD83D\uDE00 that decode back to a single character. The two halves must stay together: decoding a lone half yields the replacement character U+FFFD, not an error.

Will encode then decode give me back exactly what I typed?

For ordinary text, yes: the encode step leaves printable ASCII untouched, and the decode step leaves anything that is not a \uXXXX escape untouched, so the two transformations cancel. The round trip fails only when your text contains literal backslashes or you hand-type a malformed escape, which is why a quick self-test with a sample is worth doing before you depend on it.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools