JSON Stringify Text Generator

Turn any text into a valid JSON string literal, with quotes, backslashes, line breaks and tabs escaped correctly, or reverse the process to read an escaped string. It is free, instant and runs entirely in your browser.

JSON Stringify Text GeneratorPrivate · runs on your device
Input
Words 0Characters 0Lines 0
JSON string

Example: He said "hi" → "He said \"hi\""

How to use the JSON stringify text generator

The tool has one input box, one output box called JSON string and two controls. The output updates as you type, so there is no convert button.

  1. Paste or type your text into the Input box. Line breaks are allowed, and a final line break at the end of the text is escaped as well.
  2. Leave Mode on Text to JSON string to produce a quoted literal. Choose JSON string to text when you want to read a string that is already escaped.
  3. Tick Escape non-ASCII as \uXXXX if the receiving system only accepts plain ASCII. Leave it off for normal UTF-8 JSON.
  4. Use the Copy or Download button under the output.

The result includes the surrounding double quotes, so paste it as a complete value and do not add a second pair.

Which characters are escaped, with a worked example

JSON strings may not contain a raw double quote, a raw backslash or any raw control character below U+0020. The tool uses the same rules as JSON.stringify in JavaScript.

CharacterWritten as
Double quote\"
Backslash\\
Line feed\n
Carriage return\r
Tab\t
Backspace and form feed\b and \f
Other control characters\u0001 style

The text He said "hi" becomes "He said \"hi\"". A Windows path such as C:\temp\new becomes "C:\\temp\\new", which is why pasted paths so often break JSON files. With the non-ASCII option ticked, café becomes caf\u00e9, and an emoji becomes two escapes, a surrogate pair such as \ud83d\ude00. The forward slash is never escaped.

Multi-line text shows the main benefit. The two lines Line one and Line two become "Line one\nLine two", a single-line value that can sit in a configuration file, an API request body or a test fixture. Typical cases are a SQL query or an HTML email template stored in one JSON field, a prompt with several paragraphs, or an error message copied from a log. An apostrophe is never escaped, because JSON does not need it. Characters such as DEL (U+007F) and the line separator U+2028 are legal inside a JSON string, so they are left alone unless the non-ASCII option is ticked, when U+2028 is written as an escape.

Reading escaped strings and avoiding double escaping

In JSON string to text mode the tool trims the input and parses it as JSON, so the quotes around it are required. Single quotes are not valid JSON and give the message "Not a valid JSON string". If the pasted value is valid JSON of another kind, such as an object or an array, the tool shows it re-indented with two spaces instead, which is handy for a quick look at a logged payload.

The commonest mistake is escaping twice. If text already contains \n as two visible characters, stringifying it again turns the backslash into \\, and the receiver sees a literal backslash and the letter n instead of a line break. Run unstringify once to check what the text really holds.

This tool handles one string at a time. To validate or indent a whole document, use the JSON formatter. To move rows between formats, try the CSV to JSON converter, and for configuration files the YAML to JSON converter. A stringified value can be wrapped further with the Base64 encoder or the URL encoder. The work happens in your browser, so private configuration values are not uploaded.

Stringifying is not encryption or compression: it only changes how characters are written, and the result is a little longer than the original. Binary data such as an image should be encoded with Base64 before it goes into a JSON string. A simple way to check your work is to stringify, copy the result, switch Mode to JSON string to text and paste it back. You should see your original text exactly, line breaks included.

Quick answers

Frequently asked questions

The questions people ask most, answered in plain words.

What does JSON stringify mean?

Stringify means turning a value into JSON text. For plain text that means wrapping it in double quotes and escaping anything that would break the string: quotes, backslashes, line breaks, tabs and other control characters. The result can go straight into a JSON file, an API request body or a JavaScript source file.

How do I escape quotes in a JSON string?

Put a backslash before each double quote, so He said "hi" becomes "He said \"hi\"". Paste the text into the Input box with Mode set to Text to JSON string and the tool adds every needed backslash for you, including those for existing backslashes and line breaks.

Does it escape accented letters and emoji?

Not by default, because JSON is Unicode and accents and emoji can stay as typed. Tick Escape non-ASCII as \uXXXX and every character above code 127 becomes an escape. An emoji becomes two escapes, a surrogate pair, which any JSON parser reads back as one character.

How do I turn an escaped JSON string back into plain text?

Set Mode to JSON string to text and paste the literal including its surrounding double quotes. The tool parses it and shows real line breaks, tabs and quotes. If the input is not valid JSON, it reports Not a valid JSON string instead of guessing.

Is my text uploaded anywhere?

No. Escaping and parsing run in your browser using JavaScript, and nothing you type is sent to a server. That makes it reasonable for internal configuration values, prompts and log lines, although you should still avoid pasting secrets such as live API keys into any web page.