String escape

Escape and unescape JSON, JavaScript, and SQL strings.

Added 2026-10-31

What it does

String escape turns text into a JSON string, a JavaScript string, or a SQL string literal, and turns those literals back into text. JSON uses the language's own string rules. On the way back it accepts only a JSON string, so a number or an object stops. JavaScript escapes a backslash, quotes, and the usual controls. Other controls, including the line and paragraph separators, are written as four hex digits. The text is not evaluated. SQL only doubles a single quote and wraps the text in single quotes. A newline stays a newline inside that literal. The result is not a parameterized query, and the statement is not checked. HTML entities and URL encoding are separate tools. Nothing is uploaded.

How to use it

  1. Choose JSON, JavaScript, or SQL, then encode or decode.
  2. Paste the text or the literal. The page does not run it.
  3. SQL output is a quoted literal. It is not a parameterized query.

Common mistakes

  • SQL is not made safe. Only single quotes are doubled. The page does not bind parameters and does not check the statement.
  • JSON decode wants a string. A JSON number, object, or array is rejected. Encode produces a quoted JSON string.

Escaping stays in this tab. The text is not uploaded.

Related tools