JSON Escape / Unescape

Escape any text as a JSON string, or unescape JSON string sequences back to real characters. Runs in the browser. Does not pretty-print objects.

Last updated: October 2, 2026

Tool

This tool will load here.

What JSON escaping does

JSON Escape turns ordinary text into a JSON string: surrounding quotes, escaped quotes, escaped backslashes, and \n for line breaks. Unescape does the reverse: it reads a JSON string (or a fragment of one) and returns the real characters. This is not a JSON formatter and not a JSON validator. Those pages parse a whole JSON value. This page is for the string encoding layer.

Developers hit this when a log field is "{\"ok\":true}", when a path like C:\temp\file.json must go inside JSON, or when a copy-paste still contains \" and \\n. Escape is for putting text into JSON. Unescape is for taking a JSON string back to readable text. If you paste a JSON object or array and choose Unescape, the tool refuses: that value is already structured JSON. Open the JSON Formatter instead.

Escape always treats the entire box as raw text. It does not parse the input as JSON first. A trailing comma in the box is just characters. After Escape you get a single JSON string that would be legal as a value inside a larger document.

How to use

  1. Paste either raw text (to Escape) or a JSON string such as "hello\\nworld" (to Unescape).
  2. Choose Escape or Unescape. Example loads text with quotes, a newline, and a Windows path.
  3. Copy output when the status confirms the action. Clear empties both boxes.

Unescape first tries JSON.parse on the trimmed input. If the result is a string, that string is the output. If the result is an object or array, you get an error pointing you at the formatter. If parse fails, Unescape tries wrapping the text in quotes and parsing that — useful for a fragment like Hello \"Ada\" that is missing the outer quotes. Raw line breaks that are not encoded as \n still fail, because JSON strings cannot contain unescaped newlines.

Example

Raw text before Escape:

He said "hello"
Path: C:\temp\file.json

Escape writes one JSON string (quotes included). Unescape on that output returns the original two lines. A second common case is a twice-encoded API field:

"{\"ok\":true,\"n\":2}"

Unescape once. The output is {"ok":true,"n":2} as text. That inner text is now JSON you can paste into the JSON Validator or the viewer. Unescape does not pretty-print it. Decode one layer at a time. The pretty-print-from-logs guide describes when a log line needs this extra step.

Escape vs format vs validate

Validate asks whether a string is JSON at all. Format asks for whitespace after a successful parse. JSON escape asks how a string is encoded inside JSON. Mixing those jobs on one control hides the intent. Use this page when the quotes and backslashes are the problem. Use validate when you do not know if the whole payload is legal. Use format when it is legal and you cannot read nesting.

Invalid JSON escapes such as \x41 fail Unescape the same way JSON.parse fails. That is expected. JSON allows a small escape set. The parse-error solution on this site lists that class of mistake. Do not expect Unescape to “fix” a trailing comma in an object.

Practical use cases

  • Embedding a file path or SQL fragment in a JSON body
  • Decoding a log field that was json_encoded twice in PHP
  • Turning \n sequences into real line breaks so you can read a message
  • Producing a quoted value to paste into a larger JSON document by hand

If you are converting a whole table of records, that is JSON to CSV, not escape. If you only need to see nested keys, use the JSON Viewer after the string is real JSON.

Privacy

Escape and unescape run in this browser with JSON.stringify and JSON.parse. Nothing is posted to YallaSolve for this tool. Clear the tab if you pasted secrets.

On this page

Related Articles

Related guides

Related solutions

Need another tool ?

Open the free tools — no signup.

FAQs

newsletter signup

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Innovative Solutions For Modern Needs
Copyright © 2026 Yallasolve. all rights reserved.