Coding / Chiefletter Workbench
JavaScript string escaper
Quote JavaScript string data as JSON-compatible text or decode a quoted string.
Encode text as a quoted JSON-compatible string literal or decode a valid double-quoted JSON string. JSON string escaping is compatible with common JavaScript string data, while avoiding evaluation of pasted code.
Use it here
JavaScript string escaper
Runs in your browser. Your input is not sent to Chiefletter.
How to use this tool
- Choose Escape or Decode.
- Paste plain text to escape, or a quoted JSON string to decode.
- Run the tool and copy the result into the correct data context.
Use cases
- Prepare a text value for a JSON fixture.
- Inspect newline and quote escapes in a log.
- Avoid hand-editing backslashes in a short string.
Notes and limits
This tool handles string data only. It does not make a value safe for every HTML, SQL, shell, or JavaScript code context. Use context-specific APIs and parameterized queries in applications.
Frequently asked questions
Does this evaluate JavaScript?
No. Decoding uses JSON.parse on a quoted string, not eval.
Why must decode input have quotes?
The decoder expects one valid JSON string literal, including its surrounding double quotes.
Does escaping prevent injection?
No. Escaping for one data format does not secure another output context.