DevToolsHub Free · Fast · 100% in your browser

String Escape / Unescape

Escape or unescape strings for C#, JSON, JavaScript and SQL literals.

About this string escape and unescape tool

Escape or unescape strings for JSON, C#, JavaScript, SQL, regex and more. When you paste a block of text, HTML or JSON into source code, every quote, backslash, newline and tab has to be escaped for that language or the compiler complains. This tool does it in one click and also reverses the process, turning an escaped literal copied from code or a log file back into readable text.

How to use the String Escape / Unescape

  1. Paste your text, or an escaped literal copied from code.
  2. Choose the target language: JSON, C#, JavaScript, SQL, regex and more.
  3. Click Escape or Unescape and copy the result.

Example

He said "hi"\path\to\file  →  JSON / C# / JS: "He said \"hi\"\\path\\to\\file"
It's 5 o'clock  →  SQL: 'It''s 5 o''clock'
1+1=2 (a.b)  →  regex: 1\+1=2 \(a\.b\)

Frequently asked questions

How do I escape a string for JSON?

Wrap it in double quotes and escape double quotes as \", backslashes as \\, newlines as \n, tabs as \t and control characters as \uXXXX. Single quotes do not need escaping in JSON. This is what you need when embedding JSON inside JSON (a stringified payload) or putting text into a JSON config by hand.

How do I escape quotes in a C# string?

In a normal literal use \" and \\. In a verbatim string (@"...") double the quote: "". In C# 11 raw string literals ("""...""") nothing needs escaping at all, which is the easiest option for multi-line JSON or SQL.

How do I escape a single quote in SQL?

Double it: 'O''Brien'. Backslashes are not escape characters in standard SQL (MySQL is the exception unless NO_BACKSLASH_ESCAPES is set). Prefer parameterised queries over manual escaping to avoid SQL injection.

Which characters must be escaped in a regular expression?

The metacharacters . * + ? ^ $ { } ( ) [ ] | \ and /. Escape each with a backslash, so 1.5 becomes 1\.5. Choose the regex option to escape a literal string so it matches itself exactly.

What is the difference between escaping and encoding?

Escaping makes text safe inside a source-code literal of a specific language. Encoding (Base64, URL encoding, HTML entities) transforms text for a transport or document format. Use the URL encoder or HTML entity tool for those cases.

How do I unescape a string from a log file or stack trace?

Paste the literal including its \n and \" sequences, choose the matching language and click Unescape. Multi-line JSON that was logged as a single escaped line becomes readable again.

Does it handle Unicode and emoji?

Yes. Characters outside ASCII can be kept as-is or written as \uXXXX escapes (and surrogate pairs for emoji), depending on the language selected.

Is my data safe?

Yes. The tool runs entirely in your browser using WebAssembly. Nothing you type or upload is sent to a server, logged or stored.

Is it free?

Yes, completely free with no sign-up, no limits and no watermarks. It also works offline once the page has loaded.

An unhandled error has occurred. Reload ✕