jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON Stringify — Escape JSON for Code

JS · Python · Go · Java · shell · reverse mode

Take a JSON document and produce an escaped single-line string ready to paste into JavaScript, Python, Go, Java source, or a shell command. Pick the target language for correct escaping; toggle Copy with var = to wrap as const data = "...";. Reverse mode turns an escaped string back into the original JSON.

Ready.

How to stringify JSON

  1. Paste your JSON.
  2. Pick the Target languageJavaScript / JSON, Python, Go, Java, Shell single-quoted, Shell double-quoted. Each handles escapes differently.
  3. The output is the escaped string ready to assign to a variable. Copy copies just the string; Copy with var = wraps it as const data = "..."; (or the equivalent for the language).
  4. Use Reverse to go back — turn an escaped string into the original JSON.

When to use which target

FAQ

Why is the JS output the same as Python's?

For printable ASCII content they're identical. Differences only show with control characters, lone surrogates, or non-ASCII when you opt for \\u escapes.

Should I prefer single or double-quoted shell?

Single-quoted unless you actually need variable interpolation — single quotes prevent the shell from expanding $, backticks, and !, which is almost always what you want.

What does Reverse do?

It expects an escaped JSON string (one already wrapped in "..." or not) and decodes the escapes back to the original characters. If the result is itself JSON, it's pretty-printed.

Will it work offline?

Yes.