Text to escape

Escaped text

Why escape text in JSON?

Escaping JSON is necessary when you want to include special characters in a JSON string. JSON has specific rules for how certain characters must be represented to maintain valid syntax. For example, double quotes (") must be escaped with a backslash (\") because unescaped double quotes are used to delimit strings in JSON.

Examples of JSON escaping

Original text

This is a "JSON string" with special characters:
Backslash: Newline: 
Tab:	
Quotes: "Hello" and 'World'
Control chars: 

	
Unicode: 😀 ñ € 你好

Escaped text

This is a \"JSON string\" with special characters:\nBackslash: Newline: \nTab:\t\nQuotes: \"Hello\" and 'World'\nControl chars: \b\f\n\r\t\nUnicode: 😀 ñ € 你好

Common JSON escape sequences

CharacterEscape SequenceDescription
"\"Double quote
\\\Backslash
/\/Forward slash
Backspace\bBackspace character
Form feed\fForm feed character
Newline\nLine feed character
Carriage return\rCarriage return character
Tab\tTab character
Unicode character\uXXXXUnicode character (where XXXX is the hex code)

When to use JSON escaping

  • When creating JSON strings programmatically
  • When manually constructing JSON data that includes special characters
  • When preparing user input to be included in JSON data
  • When working with APIs that require JSON-formatted data
  • When storing text that contains control characters or quotes in JSON format

This tool uses JavaScript's built-in JSON.stringify() function to properly escape text according to the JSON specification. The result can be safely included as a string value in a JSON document.

Tip:

When working with JSON, always validate your JSON after escaping to ensure it's properly formatted. Invalid JSON can cause errors in applications that try to parse it.

Related Tools

All Tools

See all available tools