Interested in sponsoring? Reach out to discuss placements.
Unicode Escaper — \uXXXX Escape Sequences
Unicode escape sequences.
Last updated: August 2026
Quick reference
- What this calculator does
- Convert non-ASCII characters to Unicode escape sequences — \uXXXX for BMP and \u{...} for astral code points.
- How it works
- Paste text containing Unicode; printable ASCII (space through tilde) stays literal while other characters become escape sequences.
- Example
- Café becomes Caf\u00e9; emoji may become \u{1f600} style escapes for astral planes.
- When to use it
- JavaScript source literals, JSON with ASCII-only policies, debugging encoding issues, or generating portable string constants.
Guide
Introduction
Source files constrained to ASCII still need to represent international text — legacy build pipelines, embedded systems string tables, and JavaScript before UTF-8 defaults. Developers manually hunt code points: é is U+00E9, but astral emoji need surrogate pairs or \u{1F600} ES6 syntax. Pasting raw Unicode into JSON sometimes works; sometimes CI lint rules demand explicit escapes.
Certoflow's Unicode Escaper walks input character by character. Printable ASCII range 0x20–0x7E passes through unchanged. All other code points become \uXXXX (four hex digits, zero-padded) for BMP characters, or \u{hex} braced form for code points above U+FFFF. Live transformation. Local only. Use with JSON String Escaper for full JSON compliance, HTML Entity Encoder for markup contexts, and Base64URL Encoder when transporting UTF-8 bytes instead of escapes.
What this tool does
| Input | Output behavior |
|---|---|
| ASCII printable | Unchanged (A, z, 0, space, punctuation through ~) |
| BMP non-ASCII | \u00e9 style (lowercase hex, four digits) |
| Astral (emoji, etc.) | \u{1f600} braced lowercase hex |
| Control chars | Escaped (outside printable ASCII range) |
No decode mode — escape only. No choice of uppercase hex or \U Python syntax.
How it works
export function escapeUnicode(input: string): string {
return input.replace(/[^\x20-\x7E]/g, (ch) => {
const code = ch.codePointAt(0)!;
return code > 0xffff
? `\\u{${code.toString(16)}}`
: `\\u${code.toString(16).padStart(4, "0")}`;
});
}
Regex targets characters outside printable ASCII — includes control characters below space and DEL. codePointAt handles surrogate pairs for emoji as single astral escapes.
Real-world examples
JavaScript bundle ASCII policy
Corporate lint requires \u escapes for non-English UI strings in legacy bundles. Escape translator-provided phrases, paste into .js string literals.
JSON transported through ASCII-only channels
Some mainframe bridges accept only ASCII. Escape customer names before embedding in JSON transmitted through restricted gateways — validate with JSON Validator.
Comparing with JSON.stringify
String Hello "world" needs quote escaping from JSON String Escaper; Hello 世界 needs this tool or combined pipeline.
Documentation code samples
Technical blog shows explicit code points for typography characters — em dash, non-breaking space — without pasting invisible Unicode into source repos.
Debugging mojibake
When corrupted text displays wrong, escape to see exact code points requested versus received bytes — follow with Hex Converter on UTF-8 bytes.
Common mistakes
Using Unicode escapes in HTML content. Browsers parse HTML as UTF-8 — prefer UTF-8 files or HTML Entity Encoder for &entity; forms.
Double-escaping backslashes. Output includes literal backslash-u sequences meant for source code — do not run through escaper twice.
Expecting ASCII letters to escape. A–Z remain literal by design — only non-printable-ASCII escapes.
Assuming \u escapes work in all JSON parsers. Modern parsers accept UTF-8 literally; escapes are optional compatibility.
Mixing with URL encoding. Percent-encoding is separate — use URL Encoder for URI components.
Emoji as two \u surrogates. This tool emits single \u{...} for astral code points — match your target language's string literal rules.
Use cases
Frontend developers satisfying ASCII-only lint rules.
Localization engineers preparing portable string exports.
Technical writers documenting explicit code points.
Students learning Unicode planes and escape syntax differences.
Legacy integrators bridging UTF-8 apps to ASCII-only middleware.
Security reviewers inspecting invisible homoglyph attacks via escaped output.
FAQ
What ASCII range stays literal?
Space (0x20) through tilde (0x7E).
How are emoji escaped?
\u{codepoint} with lowercase hex for code points above U+FFFF.
Decode support?
Not in this tool — paste escapes into JavaScript eval or custom decoder carefully.
JSON ready?
May still need quote escaping via JSON String Escaper for full JSON string embedding.
Case of hex digits?
Lowercase in output.
Live transform?
Yes, when input is non-empty.
Local processing?
Yes. No upload.
Control characters below space?
Escaped because outside printable ASCII range.
Difference from HTML entities?
Different syntax and consumption context — HTML Entity Encoder.
Offline?
Yes, after page load.
Planes, surrogates, and JavaScript literals
Unicode assigns code points in the Basic Multilingual Plane (BMP, U+0000–U+FFFF) and supplementary planes above U+FFFF for emoji and rare scripts. JavaScript strings are UTF-16 internally; astral characters like 😀 occupy surrogate pairs. Certoflow's escaper uses codePointAt to emit a single \u{1f600} style escape for astral code points rather than two separate \uD83D\uDE00 surrogate escapes — cleaner for modern ES6+ source files. BMP characters outside printable ASCII use four-digit \u00e9 form without braces.
When preparing strings for JSON, remember JSON allows literal UTF-8 in many deployments — escapes are optional for international text unless policy mandates ASCII. Pipeline order matters: escape Unicode here for JavaScript constants, then wrap in JSON quotes and escape structural characters via JSON String Escaper. For HTML output of the same text, neither tool replaces HTML Entity Encoder which targets < and friends for markup contexts rather than backslash-u sequences consumed by JavaScript parsers.
Frequently Asked Questions
- Is data uploaded?
- No. All processing runs locally in your browser.
- Does this work offline?
- Yes, after the page loads.
People also use
Related tools that complement this workflow.
Password Generator
Create secure random passwords instantly.
Developer ToolsUUID Generator
Generate UUID v4 identifiers securely in the browser.
Developer ToolsSHA256 Generator
Hash text with SHA-256.
Developer ToolsJSON Formatter & Validator
Format and validate JSON with one click.
Developer ToolsBase64 Encode
Encode text to Base64 with UTF-8 support.
Interested in sponsoring? Reach out to discuss placements.