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.
Why this is its own tool
JSON.stringify is one line in JavaScript, but you reach for it from a context where you cannot run JavaScript — bash, a config form, a CI YAML field. A web tool replaces the awkward in-shell escaping dance.
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
When do I need this?
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?
Related tools
Last updated: 2025-01-15