C# / .NET String Escape & Unescape
Convert text to a regular or verbatim C# string literal and decode supported .NET/C# escape sequences locally, with Unicode options and precise errors for malformed quoted input.
C# / .NET String Escape & Unescape workspace
Press Ctrl/Cmd + Enter to convert. Processing stays in this tab and input is limited to 500,000 characters.
C# / .NET String Escape & Unescape example
Verbatim style keeps path backslashes and doubles embedded double quotes.
Example input
Path: C:\logs\today.txt
Status: "ready"Expected output
@"Path: C:\logs\today.txt
Status: ""ready"""How to use C# / .NET String Escape & Unescape
- 1
Choose Escape or Unescape.
- 2
In Escape mode, select Regular or Verbatim literal style.
- 3
For a regular literal, choose wrapping and optional non-ASCII Unicode escaping.
- 4
Paste text and run the conversion with the button or keyboard shortcut.
- 5
Inspect, copy, or download the converted value.
What this tool does
Regular mode escapes backslashes, double quotes, common controls, hexadecimal control values, and optionally non-ASCII Unicode code points. The output can include or omit its surrounding double quotes.
Verbatim mode emits an @-prefixed literal, leaves backslashes and physical line breaks intact, and doubles embedded quotation marks as required by C# syntax.
Unescape mode detects verbatim literals or decodes regular quoted and unquoted content. It handles C# simple escapes and fixed or variable-width numeric forms without compiling or executing the result.
Features and options
- Regular C# literal output
- Verbatim @-string output
- Optional literal delimiters
- Simple control escapes including null and alert
- \x, \u, and \U decoding
- Optional non-ASCII escaping
- Quoted or raw-content input
- Inline malformed-escape errors
- Local processing with no account
Technical information
C# regular string literals use backslash escape sequences. The \x form accepts one to four hexadecimal digits, \u accepts exactly four, and \U accepts exactly eight representing a valid Unicode scalar value.
A verbatim literal starts with @" and treats backslashes as ordinary characters. Its only quote escape is a doubled double quote, and physical newlines remain part of the string.
C# also supports raw and interpolated literals, but those forms have delimiter and interpolation rules beyond this focused converter. The browser result represents text, not a System.String instance running inside the CLR.
Common use cases
- Embedding Windows paths
- Preparing multiline test data
- Converting JSON or regex text for C# source
- Decoding debugger output
- Comparing regular and verbatim representations
- Making control characters explicit
Limitations
- C# raw triple-quoted strings are not generated or parsed.
- Interpolated strings and brace escaping are outside this tool.
- The converter does not evaluate compile-time Unicode, normalization, or runtime encoding behavior.
- A result is not checked in the context of a complete C# program.
- Verbatim output may span lines and should be reviewed against the target language version and code style.
Related tools
References & Sources
Explains regular, verbatim, and raw C# literals and lists the language's string escape sequences.
Verified 2026-08-13 ↗learn.microsoft.com · SpecificationC# Language Specification — Lexical StructureDefines regular, verbatim, and raw string-literal grammar and escape processing.
Verified 2026-08-13 ↗learn.microsoft.com · Official DocumentationC# Built-in Types and LiteralsDocuments C# character and string literal forms in the language type system.
Verified 2026-08-13 ↗learn.microsoft.com · Official DocumentationSystem.String ClassDocuments the immutable UTF-16 System.String values represented by C# string literals at runtime.
Verified 2026-08-13 ↗C# / .NET String Escape & Unescape FAQ
When should I use a regular or verbatim C# string?
Regular literals are compact when escapes are useful. Verbatim literals are often clearer for Windows paths and multiline text because backslashes remain literal and quotes are doubled.
Does @ make every character completely raw?
Almost: backslashes are not escape introducers, but a double quote inside a verbatim literal must be written twice.
Are C# raw string literals supported?
No. Triple-quote delimiter sizing and indentation rules are separate from regular and verbatim literals and are not handled here.
Can this decode \x with fewer than four digits?
Yes. C# hexadecimal escapes accept one to four hex digits; \u and \U remain fixed-width.
Does the tool support interpolated strings?
No. It does not interpret $ prefixes, interpolation holes, or doubled braces.
Is the result uploaded to a .NET service?
No. Conversion is performed by local browser code and is not sent to a compiler or remote API.