JSON Escape

Escapes a JSON string removing traces of offending characters that could prevent parsing.

The following characters are reserved in JSON and must be properly escaped to be used in strings:

  • Backspace is replaced with \b
  • Form feed is replaced with \f
  • Newline is replaced with \n
  • Carriage return is replaced with \r
  • Tab is replaced with \t
  • Double quote is replaced with \"
  • Backslash is replaced with \\

Mode - Minimal

When enabled, only a limited set of symbols in the output are escaped:

  • all the above
  • U+0000 -> \0
  • U+2028 -> \u2028
  • U+2029 -> \u2029
  • whatever symbol is being used for wrapping string literals (based on the Quotes option)
  • lone surrogates

Mode - Compact

When enabled, the output for arrays and objects is as compact as possible; it’s not formatted nicely.

Mode - Everything

When enabled, all the symbols in the output are escaped — even printable ASCII symbols.

Quotes

How to escape quotes:

  • "double" -> any occurrences of ' in the input string are escaped as \', so that the output can be used in a string literal wrapped in single quotes.
  • "single" -> any occurrences of " in the input string are escaped as \", so that the output can be used in a string literal wrapped in double quotes
  • "backtick" -> any occurrences of ` in the input string are escaped as \`, so that the output can be used in a string literal wrapped in backticks

Source:
[1] www.freeformatter.com/json-escape.html


Choose from 107 ops
Latest ops 0
Favorite ops 0
Calculations
0