100% local — your data never leaves your browser

C# Escape — A Literal That Compiles as Is

Escape text for a regular C# string literal, including the \a, \v and \0 sequences specific to .NET, so the line compiles where you paste it.

Instant Private Zero cookies

Text input

.NET Escaped output

What this tool does

It escapes text for a regular C# string literal — the "..." form, not the verbatim @"..." form:

  • backslashes are doubled;
  • " is escaped; ' is left alone, since it delimits a char, not a string;
  • \a (bell), \v (vertical tab) and \0 (NUL) are emitted as named sequences — these three are what distinguish the C# escape set from the JavaScript one;
  • newline, carriage return, tab, backspace and form feed get their usual named forms;
  • remaining control characters become \uXXXX.

Non-ASCII characters are left as they are: C# sources are UTF-8, and an escaped accent would only hurt readability.

When you need it

Hard-coding a connection fragment, a regex, a file path or a log template into a .cs file. Paths are the common case: \\server\share has to be doubled in a regular literal, and getting it wrong produces a tab or a form feed instead of a directory separator.

What it does not do

It does not choose the literal form for you. If your text is mostly backslashes — a Windows path, a regex — a verbatim @"..." literal is usually more readable than the escaped form this tool produces, and it follows a different rule.

Private by design

Everything runs locally in your browser with JavaScript. Your data is never uploaded, which makes the tool safe for sensitive content, and it keeps working offline.

Frequently asked questions

Does this work for verbatim strings (@"...")?
No, and the difference matters. In a verbatim string a backslash is literal and a double quote is escaped by doubling it (""). This tool produces a regular literal; pasting its output after @ would turn every \n into two visible characters.
What makes it different from the JavaScript escaper?
C# recognises \a (bell) and \0 (NUL) as named sequences, and has no backtick or single-quoted string. So only the double quote is escaped, and \a is produced where JavaScript would emit \u0007.
Are accented characters escaped?
No. C# source files are UTF-8 by default and "café" is perfectly valid, so non-ASCII text stays readable.

Related converters