JSON Stringify
Paste or drop your data here, or open a file.
New to Bracely?
Everything stays in your browser.
Output appears here
Paste or open your data in the input box. It never leaves your browser.
JSON Stringify
Turn JSON into one escaped string with quotes and backslashes in the right places, ready to paste into code, an environment variable or another JSON field. The JSON is minified first, so the string is as short as it can be. Unescape JSON turns it back.
Example: JSON to put inside a string
A small object with a single-quoted SQL value, a Windows path and a line break. Stringify minifies it and escapes the double quotes, the backslashes and the newline, so it can sit inside another JSON value, a string in code or an environment variable:
Input
{
"query": "SELECT * FROM t WHERE name = 'x'",
"path": "C:\\logs\\app.log",
"msg": "line 1\nline 2"
}Output
"{\"query\":\"SELECT * FROM t WHERE name = 'x'\",\"path\":\"C:\\\\logs\\\\app.log\",\"msg\":\"line 1\\nline 2\"}"
How do I use the JSON Stringify?
- Paste JSON.
- Copy the escaped string from the Output box.
- To reverse it, open Unescape JSON and paste the escaped string.
What does the JSON Stringify do?
- Minifies, then escapes quotes, backslashes, newlines and control characters
- The same result as JSON.stringify(JSON.stringify(value))
- Unescape JSON works with or without the outer quotes
- JSON Escape for any text, with optional \u codes
When to use the JSON Stringify
You need JSON as a string when it goes inside something else: a field of another JSON document (message queues and webhooks often do this), a string literal in code, an environment variable, a database column or a test fixture. Typing the backslashes by hand is slow and error-prone; Stringify does it exactly like JSON.stringify(JSON.stringify(value)).
The JSON is minified, then every double quote, backslash, newline, tab and control character is escaped, and the whole thing is wrapped in quotes, as in the example. Unstringify goes back the other way, with or without the outer quotes. For plain text rather than JSON, JSON Escape does the same job and can also write non-ASCII characters as \u codes.
Frequently asked questions
- Why are there so many backslashes?
- Each level of embedding adds a layer: a \ in a Windows path is already \\ in JSON, and becomes \\\\ once the JSON itself is put in a string. Unstringify removes one layer at a time.
- Is this the same as URL encoding?
- No. Escaping makes JSON safe inside a JSON or code string; URL encoding (%22, %7B) makes it safe inside a URL. Use URL encode for query parameters.
- What is the difference between stringify and escape?
- Stringify minifies a JSON document, then turns it into one JSON string. JSON Escape does the same for any text and keeps it exactly as written.
- Is my data uploaded?
- No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.
More JSON tools
Bracely has 108 JSON tools in one page. Related ones:
- Slug generator
- QR code generator
- Webhook signature
- JSON to Base64
- Protobuf decoder
- JWT Decoder
- JSON Escape
- Base64 to JSON
- Certificate decoder
- Unescape JSON
- URL encode / decode
- HTML entity encoder
- GZIP decompress
- Encrypt text
- Key pair generator
- JSON log viewer
- JSON stats
- JSON Formatter
- JSON Validator
- JSON Viewer
- JSON Repair
- JSON Diff
- JSON to YAML
- JSON to CSV
- jq Playground
Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.6 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram