C# String Escaper

Paste any text to see it as a regular, verbatim, raw, or interpolated C# string literal side by side, with the recommended form explained — or paste a literal to reverse it back to plain text.

By Pankaj Kumar · DevToolsHub · Last updated Aug 2026

What this tool does

Paste any text — JSON, a file path, a regex, multi-line SQL — and this tool generates all five C# string literal representations of it at once, side by side, plus tells you which one is the best fit and why. Switch to Reverse to paste a C# string literal (in any of those five forms) and get the original text back. Everything runs in your Blazor Server session; nothing is sent to an external API.

All five forms are shown together, not one at a time — the point of this tool is to compare them, and the "why raw beats regular here" reasoning only makes sense next to the actual escaped output of each.

The four literal forms — when to use each

FormSyntaxBest for
Regular"..."Short text with few or no special characters — the default, most familiar form.
Verbatim@"..."Windows file paths and other backslash-heavy text with no quotes — avoids escaping every backslash.
Raw string (C# 11+)"""..."""Text with both quotes and backslashes, or multi-line content like JSON/SQL/XML — no escaping of anything, ever.
Interpolated (regular / raw)$"..." / $$"""..."""Only when you actually need {expression} interpolation holes — otherwise prefer the non-interpolated form.

Worked example

Input text containing a newline, a quote, and a backslash:

Path: C:\temp\"quoted".txt
Line two

as a raw string (recommended — no escaping needed for either the quote or the backslash):

"""
Path: C:\temp"quoted".txt
Line two
"""

Why raw string interpolation grows $ signs instead of doubling braces

Raw string literals — interpolated or not — never use escape sequences; that's their entire point. For a normal interpolated string ($"..."), a literal { must be written as {{. But in an interpolated raw string, doing the same thing would be wrong: with a two-$ prefix, {{ is the start of an interpolation hole, not an escaped brace. Instead, this tool raises the number of $ signs past the longest run of consecutive { or } in your content, so a run that long is guaranteed to stay literal — the correct C# 11 rule, not a doubling trick.

How to use this tool

  1. Escape: paste raw text, click Escape, compare all five forms and copy whichever fits.
  2. Reverse: switch mode, paste a C# string literal (any of the five forms — the tool auto-detects which), click Reverse.

Whether you searched "escape string for C#" looking to do it by hand, or you're really after a verbatim string converter for a Windows path full of backslashes, this covers both — the Verbatim column is exactly that converter, shown side by side with the other four forms so you can compare before picking one.

This tool is built with ASP.NET Core 8, Blazor Server, and a hand-written C# 11 string literal escaper/un-escaper (no Roslyn/compiler dependency). It runs securely on Microsoft Azure.
Input Section

Raw text

{"name": "test"}
Path: C:\temp\file.txt
Output Section
Recommended: Raw string — Contains both quotes and backslashes — a raw string needs no escaping for either.

Regular

C# output

"{\"name\": \"test\"}\nPath: C:\\temp\\file.txt"

Verbatim (@)

C# output

@"{""name"": ""test""}
Path: C:\temp\file.txt"

Raw string

C# output

"""
{"name": "test"}
Path: C:\temp\file.txt
"""

Interpolated ($)

C# output

$"{{\"name\": \"test\"}}\nPath: C:\\temp\\file.txt"
Contains { or } — each brace is doubled ({{ / }}) so it isn't read as an interpolation hole.

Interpolated raw ($$)

C# output

$$"""
{"name": "test"}
Path: C:\temp\file.txt
"""
Contains { or } — raw strings never escape, so the $ count was raised to 2 instead of doubling braces; a run of up to 1 literal brace(s) stays literal.