JSON String Escape
JSON String Escape calls JSON.stringify on the input and removes the first and last quote characters. The result escapes quotes, backslashes, control characters, and line breaks as required for a JSON string's interior, but it is not a complete quoted JSON value. It does not escape for HTML, JavaScript source embedded in HTML, shell commands, SQL, URLs, or regular expressions.
Runs locally — files stay on your deviceDoes output include surrounding double quotes?
No. Only the escaped string contents are returned.
Escaping is specific to a parser context
JSON string grammar protects delimiters and control characters. Other destination languages have different metacharacters and rules.
How it works
JSON.stringify produces a complete string literal; slice removes its outer quote pair.
Key concepts
Interior only
Add quotes when constructing a standalone JSON string.
Backslash sequences
Newlines become \n and quotes become \".
When to use it
- Insert text inside an existing JSON string template carefully.
- Inspect JSON escape sequences.
- Round-trip with the paired unescape page for supported input.
When not to use it
- Do not paste it as a complete JSON document without quotes.
- Do not use it for HTML or shell escaping.
- Do not assume escaping makes untrusted data semantically safe.
Worked examples
Quote
- Input
Ana said "hi"- Expected output
Ana said \"hi\"
Outer quotes are not included.
Line break
- Input
a then newline then b- Expected output
a\nb
Control character becomes an escape.
Backslash
- Input
C:\temp- Expected output
C:\\temp
Backslash is escaped.
Common mistakes
Expecting complete JSON
Outer quotes were removed. Correction: Wrap output in double quotes.
Using for another language
Context rules differ. Correction: Use a destination-specific encoder.
Double escaping
Already escaped text changes again. Correction: Track representation state.
Best practices
- Prefer JSON.stringify on complete structures.
- Escape only at serialization time.
- Never build mixed-language code with ad hoc concatenation.
Related operations and differences
JSON String Unescape
Choose JSON String Unescape when you need to decode JSON string escape sequences.; use JSON String Escape specifically for json escape.
CSV to JSON
Choose CSV to JSON when you need to convert a header-based CSV table to JSON.; use JSON String Escape specifically for json escape.
Extract JSON Values
Choose Extract JSON Values when you need to list every primitive value in a JSON document.; use JSON String Escape specifically for json escape.
JSON Beautifier
Choose JSON Beautifier when you need to format JSON with readable indentation.; use JSON String Escape specifically for json escape.
JSON Flattener
Choose JSON Flattener when you need to flatten nested objects into dot paths.; use JSON String Escape specifically for json escape.
JSON Key Sorter
Choose JSON Key Sorter when you need to sort object keys recursively.; use JSON String Escape specifically for json escape.
Limitations and privacy
- JSON string interior only.
- No surrounding quotes, object serialization, destination-context detection, HTML safety, or syntax validation after insertion.
Input is processed locally in this browser and is not uploaded by the tool.
Frequently asked questions
Are quotes included?
No.
Are newlines escaped?
Yes.
Can this escape an object?
It treats all entered content as text.
Is it safe for HTML?
Not as a general HTML-context guarantee.