JSON Escape / Unescape
Securely handle quotes and special characters for JSON strings
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
- 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.
- Click Escape for JSON to turn special characters into escape sequences, or Unescape JSON to convert them back.
- Read the outcome in the Result panel and press Copy Result.
- 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