About JSON Stringify / Escape
Wrap any text or JSON in proper <code>JSON.stringify</code> output — escape quotes, newlines, control chars, and unicode. Useful for embedding payloads in shell scripts, environment variables, config files, or other JSON. Round-trip safe — what we produce can be safely <code>JSON.parse</code>'d back to the original.
Stringify in JavaScript, Python, and C#
JSON.stringify is one line in JavaScript, but you reach for this tool from a context where you cannot run JavaScript — bash, a config form, a CI YAML field, Postman. For reference, the equivalents:
JSON.stringify(value) // compact
JSON.stringify(value, null, 2) // pretty, 2-space indent
import json
json.dumps(value) # compact
json.dumps(value, indent=2) # pretty
JsonSerializer.Serialize(value); // System.Text.Json
JsonConvert.SerializeObject(value, Formatting.Indented); // Newtonsoft
Pretty vs compact: the indent argument (2 in JS/Python) turns one-line output into readable, nested text — this tool’s Pretty-print toggle does the same. Leave it off to get the single-line form you embed in a string.
Postman: to send a stringified body, set the raw body to your JSON directly — do not double-stringify. Use this tool only when you need the JSON as a string value inside another field.
Use case examples
Embed JSON in a shell script:
curl -X POST -d "$(cat <<EOF
{"key": "value", "nested": {"path": "ok"}}
EOF
)" https://example.com
vs. with stringified payload:
curl -X POST -d '{"key":"value","nested":{"path":"ok"}}' https://example.com
The latter is single-quote-safe — no shell expansion, no heredoc dance.
Embed JSON in a TS string:
const FIXTURE = "{\"key\":\"value\",\"items\":[1,2,3]}";
JSON.parse(FIXTURE);
Embed JSON in YAML:
config: '{"feature":"on","retries":3}'
Common workflows
Build a webhook payload by hand. Compose JSON, stringify it, paste into your test runner.
Move a fixture across formats. JSON in a .env value? Stringify before assignment.
Test escape edge cases. Paste content with quotes, backslashes, newlines. Confirm the result parses cleanly back.
Why local
The string you stringify is often meaningful payload — request body, fixture, config. Pasting into a remote tool exposes it. Local browser-side stringify with no logging, no transmission.
Frequently asked questions
What gets escaped?
") become \". Backslash becomes \\. Newline → \n. Tab → \t. Control chars → \uXXXX.What about non-ASCII?
café as café — useful for systems that mishandle UTF-8.Will it pretty-print before stringifying?
Is it round-trip safe?
Can I unescape too?
What does JSON.stringify do?
JSON.stringify converts a value (object, array, string, number) into a JSON-formatted string — escaping quotes, newlines, and control characters so the result is safe to store, log, or send over the wire. JSON.parse is the inverse: it turns that string back into a value. This tool runs the same operation without you opening a console.How do I stringify JSON in JavaScript, Python, and C#?
JSON.stringify(value, null, 2) — the third argument is the indent for pretty output. Python: json.dumps(value, indent=2). C#: JsonSerializer.Serialize(value) (System.Text.Json) or JsonConvert.SerializeObject(value, Formatting.Indented) (Newtonsoft). All three escape and serialise the same way this tool does.Why does JSON.stringify throw on circular references?
JSON.stringify throws TypeError: Converting circular structure to JSON when an object references itself. Fix it by removing the back-reference, using a replacer function to skip the offending key, or a library like flatted that encodes cycles. Paste the offending object here to spot the loop.Related tools
Last updated: 2026-07-04