JSON Stringify Online
Convert JSON into an escaped one-line string literal ready to embed in code, and back again.
Input
Output
Ready
Drop a file to load it
About this tool
Turn a JSON document into a single escaped string literal you can paste directly into source code, or reverse the process to recover JSON from an escaped string.
When you would use it
- Embedding a JSON fixture inside a test file
- Putting a payload into an environment variable
- Recovering readable JSON from an escaped log line
Worked example
{"path":"C:\\tmp","note":"line1\nline2"}
"{\"path\":\"C:\\\\tmp\",\"note\":\"line1\\nline2\"}"
Things worth knowing
- Escaping is reversible: converting back returns the original document byte for byte.
- Backslashes are handled in a single pass, so a Windows path like
C:\nextsurvives intact.
Questions
Frequently asked
Why are there so many backslashes?
Each level of embedding doubles them. A backslash in your data is
\\ in JSON, and that becomes \\\\ once the JSON itself is embedded in a string literal. The round trip is exact, so you can always convert back.Is my data uploaded anywhere?
No. Every tool on JSONWorks runs entirely in your browser using JavaScript. Your input is never sent to a server, never logged and never stored. The simplest proof is to disconnect from the internet — the tools keep working. The site does load Google Fonts and a Google Analytics page-view tag, so you will see those two requests in your network tab, but neither receives anything you type or paste.
Does it work offline?
Yes. JSONWorks is installable as a progressive web app and caches itself on first visit, so every tool keeps working without a connection.
Related