ZeroTool Workbench

String Escape / Unescape

Escape and unescape strings for JavaScript, JSON, and HTML Entities. Supports \n \t \r \uXXXX \xHH and all common escape sequences. Real-time processing. 100% browser-based, no sign-up required.

100% Client-Side Your data never leaves your browser Free · No Sign-Up

How to Use

  1. Select a mode tab: JavaScript, JSON, or HTML Entities.
  2. Choose the direction: Escape or Unescape.
  3. Type or paste text in the left input — the output updates in real time.
  4. Click Copy to copy the result, or Swap to move the output back to the input.

JavaScript Escape Sequences

  • \n — newline (LF)
  • \r — carriage return (CR)
  • \t — horizontal tab
  • \ — literal backslash
  • — double quote
  • — single quote
  • \uXXXX — Unicode code point (4 hex digits)
  • \xHH — Latin-1 character (2 hex digits)
  • \0 — null character

JSON Escaping

JSON escaping follows RFC 8259. The tool strips the surrounding double-quotes that JSON.stringify adds, so the output is the raw escaped string content. To unescape, wrap the input in quotes and parse it as a JSON string value.

HTML Entity Reference

  • & → &
  • &lt; → <
  • &gt; → >
  • &quot; → ”
  • &#39; → ‘
  • &nbsp; → non-breaking space
  • &#233; → é (decimal numeric reference)
  • &#xE9; → é (hex numeric reference)

Related Tools

FAQ

What escape modes does this tool support?

Three modes: JavaScript (handles \n, \t, \r, \", \\, \uXXXX, \xHH), JSON (JSON.stringify semantics — the standard encoding used in JSON values), and HTML Entities (replaces &, <, >, ", ' and non-ASCII characters with named or numeric entities).

What is the difference between JavaScript and JSON escaping?

JSON escaping is a subset of JavaScript. JSON only requires escaping control characters, double-quotes, and backslashes. JavaScript escaping additionally handles single-quotes and allows \xHH hex escapes. Use JSON mode when preparing strings for JSON payloads; use JavaScript mode for string literals in JS/TS source code.

How does HTML entity escaping work?

HTML escaping converts special characters into safe entity representations. Ampersand becomes &amp;amp;, less-than becomes &amp;lt;, etc. Non-ASCII characters are encoded as decimal numeric references like &amp;#233;. This prevents XSS and ensures correct rendering in HTML contexts.

What happens with invalid input on unescape?

The tool shows an inline error message. For example, if you enter malformed JSON like a string containing an unescaped double-quote when using JSON Unescape, the error is displayed below the output. The tool never crashes — it surfaces the exception message directly.

Is this tool fully client-side?

Yes. All escape and unescape operations run entirely in your browser using JavaScript. No text is sent to any server.