Advertisements

headerup to 320x100 / 728x90

C# Escape / Unescape

Escape or unescape C# string literals including \x, \u, and \U Unicode escape sequences

Mode:
Input
Loading editor...
Output

Output will appear here...

Advertisements

content bottomup to 300x250

What is C# Escape / Unescape

Last reviewed:

C# is a modern, statically typed language from Microsoft used to build .NET applications, games with Unity, and cross-platform services.

C# Escape / Unescape converts arbitrary text into a C#-safe string literal or decodes one back to raw text. It supports the full escape set (\0, \a, \b, \f, \n, \r, \t, \v, \", \\) plus \x1–4, \uNNNN and \UNNNNNNNN Unicode escapes.

It's widely used in .NET shops for generating SQL scripts, embedding JSON payloads, and reverse-engineering decompiled assemblies.

Why use it

  • Generate safe literals for .NET code generation.
  • Decode decompiled assembly strings.
  • Round-trip localisation resources (.resx).
  • Copy test fixtures between C# unit tests.
  • Teach the C# escape grammar to new developers.

Features

  • \x, \u, and \U Unicode support
  • Handles \0, \a, \b, \f, \n, \r, \t, \v
  • Escapes non-ASCII automatically
  • Processes C# locally in your browser, no upload required
  • Ideal for .NET code generation

How to use C# Escape / Unescape

  1. Choose mode. Pick Escape or Unescape in the control bar.
  2. Paste content. Drop plain text (escape) or a C# literal (unescape).
  3. Run. Copy the result into your C# file or resource.

Example (before/after)

Raw text

Path: C:\Temp
Café

C# escaped

Path: C:\\Temp\nCaf\u00e9

Common errors

Verbatim strings ignored

The tool targets regular string literals.

Fix: For verbatim strings (@"..."), duplicate "" manually.

\U expects 8 hex digits

Short \U sequences fail to parse.

Fix: Use \uNNNN for BMP chars and \UNNNNNNNN for astral code points.

FAQ

Does it support \U for astral characters?

Yes — \UNNNNNNNN maps to a full Unicode code point via String.fromCodePoint.

What about verbatim strings?

Use regular string literal escaping. For verbatim, only "" needs doubling.

Is non-ASCII encoded by default?

Yes, characters above 0x7E become \uNNNN.

Does it support PowerShell?

Not directly — PowerShell uses different escape rules.

Is data stored?

No — processing is entirely client-side.