String Escape / Unescape

Use this string escaper to escape or unescape text with common JSON and code characters such as \n, \t, \", and \\.

⌘ Runs in browser ◴ No data stored ⌁ Free

Concept

Escape rules depend on where the string is used

String escape and unescape are used to convert special characters so text can be safely reused across JSON, JavaScript, HTML, and URL contexts.

In JSON and JavaScript, newline, tab, quote, and backslash characters must be represented as escape sequences to keep string literal syntax valid.

In HTML and URL contexts, the strategy changes by insertion point: HTML depends on markup/attribute boundaries, while URLs depend on whether you encode a whole URL or only a parameter value.

When to use this

Use it when preparing values for logs, request payloads, inline scripts, templates, or copied snippets so special characters keep their intended meaning.

Context checkpoints

Check quote style, backslash escaping, and newline handling per destination before applying output; a rule that works for JSON may not be correct for HTML or URL fragments.

Security note

This tool only converts characters. It does not replace input validation, sanitization, or XSS-protection logic.

Run this as a formatting step before your platform layer; enforce security controls and server-side filters separately.

String Escape / Unescape Workspace

Plain string
Converted result

How to use

  1. 1 Put a plain string or JSON-escaped string in the matching field.
  2. 2 Use Escape for plain text or Unescape for escaped text.
  3. 3 Auto detect chooses the direction by checking for quote, backslash, or Unicode escape notation.
  4. 4 Check how newlines, tabs, and quotes were converted.
  5. 5 Copy the result you need.

Common use cases

  • Prepare JSON string literals
  • Expose newlines and tabs
  • Restore escaped text

Frequently asked questions

Which characters are escaped?

Backslashes, double quotes, single quotes, newlines, carriage returns, and tabs are converted into escape sequences for JSON and code strings.

Can I restore an escaped string?

Yes. Put the escaped string in the escaped field and run Unescape to restore characters such as newlines and tabs.

How does auto detect work?

It unescapes when it finds clear quote, backslash, or Unicode escape notation. If those patterns are not present, it treats the input as plain text and escapes it.

Does it validate an entire JSON document?

No. It helps with string escape and unescape only; it does not validate JSON syntax or format objects.

Related workflow