JSON String Escape
Convert strings to valid JSON format, handling double quotes and control characters
About JSON String Escaping
JSON (JavaScript Object Notation) is a lightweight data interchange format. JSON strings must use double quotes, and certain special characters need to be escaped for correct representation.
The JSON escape tool helps convert plain text to valid JSON string values, or restore JSON escape sequences to original text. This is very useful when working with API data, configuration files, and data serialization.
JSON Specification Requirements
- Strings must be surrounded by double quotes, not single quotes
- Double quote characters must be escaped as \"
- Backslashes must be escaped as \\
- Control characters (like newlines, tabs) must be escaped
- Unicode characters can be represented using \uXXXX format
Common Use Cases
API Data Processing
Properly handle string escaping when building JSON API requests or parsing responses.
Configuration File Editing
Ensure special characters are correctly escaped when editing JSON configuration files.
Database Storage
Ensure string values comply with JSON specification before storing JSON data in databases.
Log Analysis
Parse JSON log entries containing escape characters.
JSON Escape Rules
| Original Character | Escape Sequence | Description |
|---|---|---|
| " | \" | Double quote |
| \ | \\ | Backslash |
| / | \/ | Forward slash (optional) |
| LF | \n | Line Feed |
| CR | \r | Carriage Return |
| TAB | \t | Tab |
| BS | \b | Backspace |
| FF | \f | Form Feed |
| U+XXXX | \uXXXX | Unicode character |
Usage Tips
- JSON strings can only use double quotes; single quotes cause parsing errors
- Forward slash (/) can optionally be escaped as \/, but is not required
- Non-ASCII characters can be used directly or escaped as \uXXXX
- JSON does not support single quotes, comments, or trailing commas
- Use JSON.stringify() to automatically escape strings