C# Escape / Unescape

Enter the String

Size : 0 , 0 Characters

The Result String:

Size : 0 , 0 Characters

How C# Escapes Special Characters and Control Characters

C# escape tool converts C# to string online by escaping special reserved characters. Additionally, it also unescapes string to reverse the transformation. Generally, escape characters replace existing characters with new & provided characters, which works best without throwing any error at runtime. Escapes characters of a UTF-8 encoded Unicode string using C#-style escape sequences. The utility escape plain C# to escaped html which helps to show html text in C# in <pre> tag.

How does C# Escape Work?

  • Type, paste, or upload your text data into the input box.
  • Click 'Escape' or 'Unescape' your code.
    C# Escape or C# Unescape converter
  • After you have converted your data, you can "Download" or "Copy to Clipboard".
  • You can paste the code into your source code or text file.

What Characters are Replaced?

When you have a C# string and need to work with it you will need to encode the string to allow parsing.
The following characters are reserved in Csharp and need to be correctly escaped for use in strings:

  • Tab is replaced with \t
  • Backspace is replaced with \b
  • Form feed is replaced with \f
  • Newline is replaced with \n
  • Carriage return is replaced with \r
  • Double quote is replaced with \"
  • Backslash is replaced with \\

All other characters passes through unchanged. Generally, alphanumeric characters 'a' through 'z, '0' through '9' remain the same.

C# Escape Example

Plain C# Before:

using System;    namespace CSharpTutorials  {    class Program    {      static void Main(string[] args)      {        string message = "Hello World!!";        Console.WriteLine(message);      }    }  }  

Escape C# After:

using System;\n\nnamespace CSharpTutorials\n{\n  class Program\n  {\n    static void Main(string[] args)\n      {\n      string message = \"Hello World!!\";\n      Console.WriteLine(message);\n    }\n  }\n}