JSON Stringify

Turn JSON or plain text into one escaped string that you can put inside code, a config file or another JSON document, and turn an escaped string back into the original. It checks your JSON first and points to the exact place of a mistake, can minify it, accepts JavaScript-style objects, and writes the result as a JSON string, a JavaScript string or plain escaped text. Long numbers keep every digit, and everything runs in your browser.

✓ Runs in your browser By New Wiz Tech team Last reviewed November 2026

How to use it

  1. Choose the action: Stringify turns JSON or text into an escaped string; Unstringify turns an escaped string back into the original.
  2. Add your input: type or paste it, press Open a file (or drop a file onto the box), or press Example. The result updates as you type.
  3. Stringify options:
    • The input is: JSON is checked first and an error is shown with its line and column; Plain text is escaped as it is.
    • Write the result as: a JSON string (double quotes), a JavaScript string (single quotes) or just the escaped text without outer quotes.
    • Minify JSON first removes spaces and line breaks so the string is short; untick it to keep the text exactly as typed.
    • Accept JavaScript-style objects converts single quotes, keys without quotes, comments and trailing commas into strict JSON.
    • Escape non-English characters writes them as \uXXXX so the result is plain ASCII, and Safe inside an HTML script tag also escapes <, >, & and /.
  4. Unstringify options: paste a quoted string ("..." or '...') or just the escaped text. If the result is JSON, choose to pretty-print it (2 spaces, 4 spaces or tabs) or leave it as it is.
  5. Use the result: Copy result or Download it. Use result as input feeds it back in (for example to decode a string that was stringified twice) and the last button switches direction, so you can check that the result decodes back to what you started with.

How it works

“Stringifying” here means turning text into a string literal: the text is wrapped in quotes and every character that cannot appear as it is gets a backslash escape, so the result can be placed inside code or inside another JSON value. It is what you get from JSON.stringify(text) in JavaScript, and when the text is itself JSON it is the “second” stringify, JSON.stringify(JSON.stringify(object)).

  • Checking: JSON input is validated by the browser’s own parser. If it is invalid, the tool finds the first mistake and shows its line and column with a short explanation.
  • Minifying without touching numbers: the tool does not parse and re-write your data. It removes whitespace that sits outside strings and leaves everything else as typed, so a number such as 12345678901234567890 keeps every digit (parsing it in JavaScript would turn it into 12345678901234567000).
  • JavaScript-style objects are read by a small built-in reader, never run as code. Single and double quoted strings, keys without quotes, // and /* */ comments, trailing commas and numbers such as .5, +3 or 0xFF are converted to strict JSON. Values that JSON does not have (undefined, NaN, Infinity) are reported as errors.
  • Escaping: " becomes \" (or ' becomes \' in a single-quoted string), \ becomes \\, and line breaks, tabs, backspace and form feed become \n, \t, \b, \f and \r. Other control characters, the delete character and the two JavaScript line separators (U+2028 and U+2029) are written as \uXXXX, and a lone half of a surrogate pair is escaped too, so the result is always valid. Characters above 127 are written as \uXXXX only if you ask for ASCII output.
  • Unstringifying reads the escapes back: \" \' \\ \/ \b \f \n \r \t \v \0 \xHH \uHHHH \u{H...}, and joins surrogate pairs. An unknown escape (for example the \U in "C:\Users") is reported with its position instead of being guessed.

Nothing you enter is sent anywhere or saved; the page works offline once loaded.

Worked example

1. JSON to a string. The JSON {"name":"Ann","tags":["a","b"]} becomes the JSON string
"{\"name\":\"Ann\",\"tags\":[\"a\",\"b\"]}"
Each inner quote now has a backslash. Pretty-printed input gives the same result with “Minify JSON first” ticked; unticked, the line breaks and spaces are kept and written as \n and spaces.

2. A JavaScript-style object. {name: 'Ann', tags: ['a','b',], /* note */ } is converted to {"name":"Ann","tags":["a","b"]} and gives the same string as in example 1.

3. Plain text. The two lines He said "hi" and bye become "He said \"hi\"\nbye": the quotes are escaped and the line break is written as \n.

4. A long number. {"id": 12345678901234567890, "ok": true} becomes "{\"id\":12345678901234567890,\"ok\":true}", with every digit of the id kept.

5. ASCII output. The text café € 😀 with “Escape non-English characters” becomes "caf\u00e9 \u20ac \ud83d\ude00"; the emoji is written as a surrogate pair.

6. A JavaScript string. The text It's "ok" written as a JavaScript string is 'It\'s "ok"'; only the single quote needs a backslash.

7. Back again. Unstringify turns "{\"a\":[1,2]}" into the JSON text {"a":[1,2]} and, with pretty-printing, into four indented lines. A Windows path written as "C:\Users" is reported as an error at the \U; written "C:\\Users" it decodes to C:\Users.

Quick reference

You seeIt stands for
\"a double quote
\'a single quote (needed only inside a single-quoted string)
\\a backslash
\/a forward slash (optional; used for HTML safety)
\n, \r, \tline feed, carriage return, tab
\b, \fbackspace, form feed
\v, \0vertical tab, null (read when unstringifying; JSON itself does not use them)
\u00e9the character with that 4-digit hexadecimal code (here é)
\ud83d\ude00a character above U+FFFF written as two halves (here a smiling face)
\xE9, \u{1F600}JavaScript forms, read when unstringifying
Output formatExample for It's "ok"
JSON string (double quotes)"It's \"ok\""
JavaScript string (single quotes)'It\'s "ok"'
Escaped text onlyIt's \"ok\"
LimitValue
Input sizeUp to 20 million characters (file or typed)
Nesting depth1,000 levels
Result boxShows the first 400,000 characters; Copy and Download always include everything

When you need this

  • JSON inside JSON: put a JSON document into a string field of another document, as many APIs and message queues expect.
  • Code and tests: paste a payload into a JavaScript, Java or other source file as a string constant, without escaping every quote by hand.
  • Config and environment values: store a JSON value on a single line in a .env file, a CI setting or a YAML value.
  • Reading logs: unstringify an escaped payload copied from a log or a database field to see the real text.
  • HTML pages: embed data in a script tag with the HTML-safe option so it cannot close the tag early.
  • Cleaning up JavaScript objects: turn a pasted object literal into strict JSON first.

Frequently asked questions

No. Everything is done in your browser and nothing you paste or open is uploaded, stored or tracked by X2X Converter. Your input is also never run as code: JavaScript-style objects are read by a small built-in reader, not evaluated.

"Stringify" turns a value into a string. In JavaScript, JSON.stringify(object) turns an object into JSON text. This tool turns that JSON text (or any text) into an escaped string literal, as if you ran JSON.stringify on the text itself: quotes and backslashes get backslashes, line breaks become \n, and the whole is wrapped in quotes. That is what you need to put JSON inside code or inside another JSON value.

Because every double quote inside the text has to be escaped as \" so that it does not end the string, and every backslash has to be doubled. JSON that was stringified twice gets another level of backslashes on top of these. Use Unstringify, once for each level, to get back to the original.

Yes. The tool does not parse your JSON into numbers and write it out again; it only removes whitespace outside strings and escapes the text. So 12345678901234567890 stays exactly as written. (JavaScript itself would round that number to 12345678901234567000, so be careful with tools that parse and re-write your data.) The one exception is a JavaScript-style number in a form JSON does not allow, such as 0xFF or .5, which is rewritten as 255 or 0.5.

Text that is valid in JavaScript but not in JSON: single-quoted strings, keys without quotes, comments and trailing commas. The tool converts them to strict JSON before escaping. It does not accept values that JSON has no way to express (undefined, NaN, Infinity), functions, or code: those show an error with the position.

Escape non-English characters (\uXXXX) when the place you will paste the string cannot handle non-ASCII text, for example some older systems, or when you want output that survives any copy and paste. Use the HTML-safe option when the string goes inside an HTML script tag: it escapes <, > and & (so a "" inside the data cannot end the tag) and the forward slash.

In a string literal a backslash starts an escape, so "C:\Users" contains \U, which is not a valid escape. The error shows the exact position. Write the backslashes doubled ("C:\\Users") or, if the text is not a string literal at all, stringify it first. The tool never guesses what an unknown escape was meant to be.

Built and reviewed by the New Wiz Tech team. Spotted an error or have a suggestion? Contact us and we will update the tool.