Back to Tools

JSON Escape / Unescape

Securely handle quotes and special characters for JSON strings

Data Input

Safely embed text inside a JSON string

Double quotes, backslashes and line breaks are not allowed to appear raw inside a JSON string value. If you paste a paragraph, a code snippet or an HTML fragment straight into a JSON file, the parser will fail. This tool converts plain text into its escaped form so it can be dropped between the quotes of a JSON value, and it can also reverse the process when you meet an escaped blob and want to read it.

Escaping and unescaping

  1. Type or paste your content into the Data Input field. Load Sample inserts a JSON-like string containing escaped line breaks, a tab and quotes, which suits testing the unescape direction.
  2. Click Escape for JSON to turn special characters into escape sequences, or Unescape JSON to convert them back.
  3. Read the outcome in the Result panel and press Copy Result.
  4. Use Clear to empty the field and start over.

What each direction does

  • Escape converts double quotes to backslash-quote, backslashes to double backslashes, real line breaks to the two-character sequence for newline, tabs likewise, and other control characters to unicode escapes. The result has no surrounding quotation marks, so you add those yourself when placing it in a JSON value.
  • Unescape reads your text as the inside of a JSON string, so sequences like backslash-n become real line breaks and backslash-quote becomes a plain quote. If the text is not a valid string body, a simpler fallback only restores escaped quotes and doubled backslashes.

Ordinary letters, digits and accented or emoji characters are left as they are.

Situations where it pays off

  • Placing a multi-line SQL query or an HTML template into a JSON configuration value.
  • Building a request body by hand that includes a message with quotation marks.
  • Reading a log entry where a whole JSON document was stored as an escaped string inside another field.
  • Cleaning up a string copied from a terminal that shows newlines as visible backslash sequences.

Careful with these cases

Escaping is not the same as encoding the whole document; escape only the text you intend to place inside a string value, not an entire JSON object, or you will get an escaped object that is no longer usable as structure. Running Unescape on text that contains an actual raw line break, or a stray unescaped quote, falls back to the simple replacement mode, so you may need to tidy edge cases yourself. Slashes are left as they are, which is valid. The conversion is done in your browser with standard JavaScript string handling, and empty input does nothing.

Related Tools


Frequently Asked Questions

Does Escape add quotation marks around the result?
No. The output is just the escaped contents, without the opening and closing quotes. Wrap it in double quotes yourself when placing it into a JSON value, for example after a key and a colon in an object.
What characters get escaped?
Double quotes, backslashes, line breaks, carriage returns, tabs and other control characters. Normal letters, digits, spaces and non-English characters are left unchanged, and forward slashes are not escaped by this tool.
What if I unescape a string that is not properly escaped?
The tool first tries to parse it as a JSON string. If that fails, it falls back to replacing escaped quotes and doubled backslashes only, so other sequences such as backslash-n stay as typed.
Should I escape a whole JSON object with this?
Only if you want to store that object as a string inside another JSON value. For normal use, escape just the text of a single value. Escaping an entire object turns its quotes into backslash-quotes and breaks the structure.
Is my text sent anywhere?
The escape and unescape operations are performed by JavaScript in your browser page, using built-in string functions. Nothing in the tool's own code posts your input to a server, and the result appears immediately below the buttons.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.