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.
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
| Form | Syntax | Best 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
- Escape: paste raw text, click Escape, compare all five forms and copy whichever fits.
- 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.
Raw text
{"name": "test"}
Path: C:\temp\file.txtRegular
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"Interpolated raw ($$)
C# output
$$"""
{"name": "test"}
Path: C:\temp\file.txt
"""