.NET Escape

Escape special characters in .NET strings.

Local Your input is processed locally in your browser. Found a problem? Report an issue

What .NET Escape does

.NET Escape writes text as the contents of a regular C# string literal ("…"). The double quote and backslash are escaped, control characters get C#'s short escapes (\0 \a \b \f \n \r \t \v) and any other control character becomes \uXXXX.

Other characters, including accents and emoji, are kept as typed: C# source files are UTF-8 by default. Visual Basic is different: its strings have no backslash escapes at all, and a quote is written by doubling it ("").

.NET Escape examples

The built-in sample

Input

say "hello" & <b>bye</b>

Output

say \"hello\" & <b>bye</b>

This is the input that the Load sample button fills in.

Quotes, a path and a null character

Input

Path "C:\Temp"␀end

Output

Path \"C:\\Temp\"\0end

The quotes and the backslash are escaped and U+0000 becomes \0.

Bell, vertical tab and escape

Input

ding␇␋next␛[0m

Output

ding\a\vnext\u001B[0m

C# has \a and \v; U+001B (escape) has no short form and becomes \u001B.

Each output was produced by running this tool on the input above it. Invisible control characters are shown as symbols, for example ␁ for U+0001 and ␀ for U+0000.

How it works

Each character is checked against the rules below; all other characters are copied unchanged.

CharacterWritten as
"\"
\\\
U+0000\0
bell (U+0007)\a
backspace, form feed\b \f
line break, carriage return, tab\n \r \t
vertical tab\v
other control characters\u001B

Details and limits

  • For a verbatim string (@"…"), backslashes are not escapes: only the quote needs doubling.
  • The \x escape is not used in the output, because C# reads up to four hex digits after it (\x1Bc is one character), which makes it easy to get wrong.

Questions

Is my data uploaded when I use .NET Escape?

No. The tool runs in your browser, so what you paste or open is processed on your own device and is not sent to a server.

Are there any limits I should know about?

For a verbatim string (@"…"), backslashes are not escapes: only the quote needs doubling. The \x escape is not used in the output, because C# reads up to four hex digits after it (\x1Bc is one character), which makes it easy to get wrong.

Is there a size limit?

There is no fixed size limit. Everything happens on your device, so very large inputs depend on its memory and can take longer on a phone than on a computer.

Does it work on phones, and is it free?

Yes. It works in any current browser on Android phones, iPhones, tablets and computers. It is free and needs no account or sign-up.