JSON String Escaper
Escape text for a JSON string, or unescape it, with shell-ready quoting.
Think a result is wrong? Report it on GitHub
About escaping JSON strings
Escape text for a JSON string or unescape it, with quotes, backslashes and line breaks handled, plus ready-quoted output for bash and PowerShell. Free.
Text inside a JSON string must not contain raw double quotes, backslashes or control characters such as line breaks. Each is replaced by an escape sequence: " becomes \", a backslash becomes \\, a line break becomes \n, and other control characters become \u0000-style codes. The rules are defined in RFC 8259.
How do I send JSON with curl from a terminal?
Pasting JSON into a command line adds a second layer of quoting. The bash / zsh option wraps the result in single quotes and handles any single quotes inside, so it can be pasted straight after curl --data. PowerShell 7.3 and later use a different rule, which the PowerShell option applies. Older Windows shells handle embedded quotes unreliably; with those, put the JSON in a file instead.
Unescaping and nested JSON
Logs and API responses often contain JSON that has itself been escaped into a string. Unescape it here, and if the result is JSON, format it for reading or minify it. Formatting only changes whitespace, so long numbers such as IDs are never rounded.