Developer ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Developer Tools

JSON String Escape and Unescape

Escape quotes, backslashes and line breaks to turn text into a valid JSON string, with optional \uXXXX and \/ output, or unescape a JSON string to plain text.

View all tools
ResultUpdates as you type
"She said \"hello\"\nPath C:\\temp\\new folder"

47 characters; quotes, backslashes and control characters such as line breaks are escaped.

How to use JSON String Escape and Unescape

Paste text and choose Escape or Unescape. Escaping returns a ready-to-paste JSON string, with options for the outer quotes, \uXXXX for non-ASCII characters and escaped slashes; unescaping points to the position of any invalid escape.

  1. Paste your textPaste a message, a Windows file path, an HTML snippet or an escaped JSON string copied from a log.
  2. Choose the directionPick Escape (text → JSON string) or Unescape (JSON string → text); the result updates as you type.
  3. Set options and copyUntick the outer double quotes to get bare content, escape non-ASCII or /, then copy the result.

Escaping rules

Escaping follows the JSON standard: a double quote becomes \", a backslash \\, line breaks and tabs \n and \t, and other control characters \u00XX. U+2028 and U+2029 are escaped too, so the string is also safe inside JavaScript. The default sample, She said "hello" with the path C:\temp\new folder on a second line, becomes "She said \"hello\"\nPath C:\\temp\\new folder". Tick Escape non-ASCII to write café as caf\u00e9 for ASCII-only systems, and Escape / to write every slash as \/ so a closing script tag inside the string cannot end an HTML script block early.

Unescaping rules

Unescape strips any surrounding double quotes and restores \n, \t, \", \\, \/ and \uXXXX sequences, including surrogate pairs for emoji. It also accepts \', \xXX and \u{…} from JavaScript source. An unknown sequence stops with its position, for example Unknown escape sequence \q at position 5, and a lone trailing backslash is reported. Unescaped double quotes are kept but counted in a warning, because strict JSON would reject them. If the result is itself a JSON object or array you are told so, which is handy for double-encoded API payloads.

Accuracy and data handling

Validate the result with your project's own tests and runtime rules before using it in production. The calculation runs in your current browser; the tool code does not send the input to a processing API.

Often Used Together

Next step

FAQ

Why can't a JSON string contain a real line break?

JSON forbids unescaped control characters inside strings, so a line break must be written as \n and a tab as \t. A raw newline makes JSON.parse and other parsers fail.

Do I need to escape accented letters or emoji?

No. JSON is normally UTF-8, so accented letters and emoji can appear as they are. Tick Escape non-ASCII as \uXXXX only when the receiving system accepts ASCII alone.

What does Unknown escape sequence mean?

The input has a backslash followed by a character JSON does not allow, such as \q. Usually the backslash itself should have been escaped: change it to \\ and try again.

More Developer Tools

Related tools