Escape and Unescape Online — JSON, XML, HTML, SQL

A single browser-based tool for escaping and unescaping strings across the four formats developers handle every day: JSON, HTML, XML and SQL. Paste a value, pick the target format, and the conversion happens live in your browser. Nothing leaves the page.

Open the Escape / Unescape tool

What it does

The escape/unescape tool takes any input string and either encodes its special characters into the syntax required by a target format, or decodes a previously-escaped string back to its raw form. It supports four formats in one interface:

You can switch direction with one button: the same panel encodes or decodes. A live mode applies the transform as you type, and a per-line mode treats each line of input as an independent string — useful when you have a list of values and want to escape every one of them at once.

Who it's for

When to use it

Some concrete situations where this tool saves time:

Features

  • Auto-detect target format. If your input already looks like escaped JSON or contains HTML entities, the tool offers an educated guess for unescape mode.
  • All four formats in one place. No tab-hopping between separate single-purpose tools.
  • Both directions. Encode and decode use the same UI; a single toggle flips the direction.
  • Per-line mode. Treat input as a list of independent strings — each line is escaped on its own and emitted on the same line in the output, so a 500-row paste survives the round trip.
  • Live mode. Output updates as you type, with a debounce so paste-and-edit feels instant even on long inputs.
  • Configurable Unicode handling for JSON. Switch between ASCII-only output (every non-ASCII character emitted as \uXXXX) and UTF-8 passthrough.
  • Copy and download. One click puts the result on the clipboard or saves it as a .txt file.
  • No network calls. The transformations run entirely in your browser — nothing about your input is sent anywhere.

How escaping works, conceptually

Each format defines its own grammar for representing characters that would otherwise be ambiguous or illegal. Here is a brief walk through with examples.

JSON

JSON strings are delimited by double quotes, so a literal double-quote inside the string must be escaped. The same applies to the backslash itself, and to control characters which are forbidden in raw form.

Input:  She said "hello\world"
Output: "She said \"hello\\world\""

Unicode characters outside ASCII may be left as UTF-8 bytes or written as \uXXXX. For characters above U+FFFF, JSON uses a UTF-16 surrogate pair — for example, the emoji U+1F600 becomes 😀.

HTML

In HTML, the characters <, > and & have special meaning. Inside attribute values, " and ' are also dangerous depending on which quote you used as a delimiter.

Input:  Tom & Jerry <3 cheese
Output: Tom &amp; Jerry &lt;3 cheese

The tool can also emit named entities (&nbsp;) or numeric ones (&#160;) depending on the option you pick.

XML

XML has only five predefined entities. If you need anything else as an entity reference, you have to declare it in a DTD — which most people do not want to do. The pragmatic rule: encode the five, and emit everything else as raw Unicode (assuming the document is UTF-8).

SQL

SQL escaping is dialect-dependent. The ANSI rule is simple: double the single quote ('O''Brien'). MySQL and SQLite also accept backslash escapes ('O\'Brien'). PostgreSQL distinguishes ordinary strings (ANSI rules) from escape strings prefixed with E (C-style backslash escapes). The tool offers a dialect selector so you can match your target database.

Common pitfalls

FAQ

Should I use this for security?

For learning, testing and ad-hoc fixes, yes. For production output encoding, no — use a context-aware library in your framework (Django's autoescape, React's JSX, Spring's HtmlUtils, etc.). The right escape depends on the context the data lands in, and a one-shot tool cannot know that for you.

What about \xHH escapes?

JSON does not support \xHH — only \uXXXX. JavaScript string literals do support it, and so do C, Python and several other languages. The tool's JSON mode rejects \xHH on decode by default; switch to "JS string" mode to accept it.

How are Unicode surrogates handled?

On encode, characters above U+FFFF are written as a pair of \uXXXX escapes (the standard JSON behaviour). On decode, the tool reassembles surrogate pairs into single code points before returning the result, and warns about unpaired or invalid surrogates rather than silently passing them through.

Does it support custom HTML entities?

On decode, yes — the full HTML5 named entity set is supported. On encode, the tool emits named entities only for a small core (&amp;, &lt;, &gt;, &quot;, &#39;, &nbsp;) and uses numeric entities for everything else. Numeric entities are more portable and avoid the obscure-name problem.


Related tools

Related reading