C/C++ String Escape & Unescape
Escape ordinary Unicode text for a C or C++ quoted string literal, or decode standard simple, hexadecimal, octal, and universal character escapes with strict malformed-input reporting.
C/C++ String Escape & Unescape workspace
Press Ctrl/Cmd + Enter to convert. Processing stays in this tab and input is limited to 500,000 characters.
C/C++ String Escape & Unescape example
Escape mode with ordinary quoted output and readable Unicode enabled.
Example input
Line one
Path: C:\tools
Quote: "hello"Expected output
"Line one\nPath: C:\\tools\nQuote: \"hello\""How to use C/C++ String Escape & Unescape
- 1
Choose Escape or Unescape.
- 2
Paste source text, escaped contents, or one quoted literal.
- 3
For escaping, choose literal wrapping and whether non-ASCII code points should use universal escapes.
- 4
Run the conversion with the button or Ctrl/Cmd + Enter.
- 5
Review the exact output, then copy or download it.
What this tool does
Escape mode protects quotation marks, backslashes, line breaks, tabs, nulls, and other controls so the result can be used as ordinary string-literal content. You can keep readable Unicode characters or emit non-ASCII code points as four- or eight-digit universal character names.
Unescape mode accepts raw escaped contents or a single quoted literal with an optional u8, u, U, or L prefix. It decodes standard simple escapes, up to three octal digits, hexadecimal escapes, and fixed-width universal escapes.
The converter is deterministic and never evaluates C or C++ source. Incomplete numeric sequences, a trailing backslash, and unsupported markers are reported inline rather than silently altered.
Features and options
- Ordinary quoted-string output
- Optional unquoted contents
- Readable Unicode by default
- Optional \uXXXX and \UXXXXXXXX output
- C/C++ simple escape decoding
- Octal and hexadecimal decoding
- u8, u, U, and L wrapper recognition
- Strict incomplete-escape errors
- 500,000-character browser-safe limit
Technical information
Ordinary C and C++ literals cannot contain an unescaped double quote, reverse solidus, or physical newline. Simple escapes cover common control characters; numeric and universal character escapes cover other values.
A C/C++ \x escape consumes hexadecimal digits until a non-hexadecimal character. The decoder follows that rule up to a safety bound, so generated hexadecimal control escapes should be reviewed when immediately followed by a hexadecimal digit.
Universal escape output is based on Unicode code points in the browser string. The actual code units placed in a narrow, wide, UTF-8, UTF-16, or UTF-32 literal still depend on the literal prefix, source encoding, compiler, and language standard.
Common use cases
- Embedding multiline text in C or C++ source
- Decoding logged literal contents
- Preparing unit-test fixtures
- Inspecting octal or hexadecimal escapes
- Making control characters visible
- Producing ASCII-oriented source for review
Limitations
- Raw string literals and custom raw delimiters are not generated or parsed.
- Adjacent literal concatenation and preprocessor behavior are not evaluated.
- The tool does not choose an encoding prefix or validate representability in a compiler's literal encoding.
- C++23 delimited and named escape forms are not currently decoded.
- A decoded null character can be present in the browser result even though C library functions may treat it as a terminator.
Related tools
References & Sources
Defines simple, numeric, conditional, and universal escape syntax used by C++ literals.
Verified 2026-08-13 ↗eel.is · SpecificationC++ Draft — String LiteralsDefines ordinary and raw string-literal forms, prefixes, character restrictions, and code-unit initialization.
Verified 2026-08-13 ↗learn.microsoft.com · Official DocumentationMicrosoft C++ String and Character LiteralsPractical compiler documentation for C++ simple, numeric, universal, and newer delimited escapes.
Verified 2026-08-13 ↗open-std.org · Standards BodyC23 Working Draft N3096Working draft used to verify the corresponding C string-literal and escape rules.
Verified 2026-08-13 ↗C/C++ String Escape & Unescape FAQ
Does the tool produce C or C++ source code?
It produces one ordinary quoted literal or its escaped contents. It does not add a variable declaration, encoding prefix, semicolon, or surrounding program.
What is the difference between \x, \u, and \U escapes?
A hexadecimal numeric escape begins with \x and consumes hex digits; \u uses exactly four hex digits and \U uses exactly eight for a universal character name.
Why can a hexadecimal escape be ambiguous?
C and C++ \x escapes continue through every following hexadecimal digit. If ordinary text immediately starts with A–F or 0–9, separate literals or another escape form may be safer.
Are UTF-8 string prefixes added automatically?
No. Choose u8, u, U, L, or no prefix based on the target program and standard. The converter only handles contents and recognizes a prefix while decoding.
Does unescaping execute the string in a compiler?
No. A local deterministic decoder interprets supported escape syntax without compiling or evaluating source.
Are raw string literals supported?
Not in this version. Raw delimiters have separate termination rules and are intentionally outside this ordinary-literal converter.