consolelog.tools

Unicode Converter

Convert text to Unicode escapes in 8 notations (JS \uXXXX, ES6 \u{}, U+, HTML, code points) and decode any of them back — surrogate-correct for emoji. Live, with a per-character code-point inspector.

About this ToolHow it works, benefits & use cases

This converter turns text into Unicode escape sequences in eight different notations and decodes any of them back to characters. Encode to JS/JSON \uXXXX (valid JavaScript and JSON, astral characters emitted as surrogate pairs so they round-trip exactly), ES6 \u{X} one-escape-per-code-point, CSS-style \XXXX, the standard U+ notation, HTML hex (&#xXXXX;) or decimal (&#NNNN;) references, or bare hex (0xXXXX) and decimal code-point lists. Crucially it is surrogate-correct: emoji and other characters outside the basic plane are handled by code point, not split incorrectly the way a naive charCodeAt approach would. The decoder auto-detects mixed input — \uXXXX, \u{}, \xXX, U+, &#x;, &#;, and bare code-point lists — and reassembles the text without throwing. A live code-point inspector table breaks down each character into its code point, decimal value, UTF-8 bytes, and UTF-16 units. It runs entirely in your browser.

How to Use

  1. 1Choose "Encode (text → Unicode)" or "Decode (Unicode → text)" with the toggle.
  2. 2When encoding, pick a notation from the Output format dropdown (JS \uXXXX, ES6 \u{}, CSS, U+, HTML hex/decimal, or code points).
  3. 3Type or paste your text — when encoding, the result and a per-character code-point inspector update live.
  4. 4When decoding, paste any mix of escape formats; the tool auto-detects and converts them to text.
  5. 5Click Convert to confirm, then copy, download, swap input ↔ output, or share the link.

Key Benefits

  • Eight output notations: JS \uXXXX, ES6 \u{}, CSS, U+, HTML hex/decimal, and code-point lists
  • Surrogate-correct — emoji and astral characters encode and decode without breaking
  • JS/JSON output round-trips exactly as valid JavaScript escapes
  • Decoder auto-detects mixed \uXXXX, \u{}, \xXX, U+, &#x;, &#; and bare code points
  • Never-throws decoding leaves unrecognized fragments intact
  • Live code-point inspector showing decimal, UTF-8 bytes, and UTF-16 units per character
  • Two-way conversion with swap and a shareable URL

Common Use Cases

  • Generating \uXXXX escapes to embed non-ASCII text safely in source or JSON
  • Reading the exact code point and UTF-8 bytes of an emoji or unfamiliar glyph
  • Producing HTML numeric character references for portable markup
  • Decoding escaped strings copied from logs, JSON, or another language’s source
  • Debugging encoding issues by inspecting UTF-16 surrogate pairs of a character

Output format

Valid JavaScript/JSON escapes; astral chars emit a surrogate pair. Round-trips exactly.

0 code points · live

Valid JavaScript/JSON escapes; astral chars emit a surrogate pair. Round-trips exactly.

Enter text above to see its Unicode escapes.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools