input.txt
output.json
Encode any text as a JSON string literal, or decode one back.

Related

Guides for Stringify

All guides →

What is JSON Stringify?

JSON.stringify() converts a value into a JSON string. When applied to a string that already contains JSON, it produces a JSON string literal — the original JSON wrapped in double quotes with internal quotes and special characters escaped. This is commonly needed when embedding JSON inside another JSON document, storing JSON in a database field, or passing JSON as a URL parameter.

Other languages call the same operation by different names: Python's json.dumps (sometimes searched as json dumps python,* json dumps in python*, python json dump, python dict to json,* python pretty print dict*, python pretty print json,* python print nice json*, or via python pprint / pprint python), Ruby's JSON.generate, Go's json.Marshal, Java's org.json and Jackson, .NET's Newtonsoft JSON (Newtonsoft.Json), and PHP's json_encode all produce the same kind of output — turning a json object as string (also searched as** json to json string** or stringify json). Reversing it goes byJSON.parse, json.loads, and so on — covered on the JSON Validator and JSON Fix tools when the input might be malformed.

Example

Input:

{"name": "Ada", "active": true}

Output after Stringify:

"{\"name\": \"Ada\", \"active\": true}"

Click Unstringify to reverse the process — useful when you receive a double-encoded JSON string and need to extract the inner value.

FAQ

How do I undo stringify (decode a JSON string literal)?

Click Unstringify, or run JSON.parse on the value. If you receive a double-encoded string that starts with an escaped quote, parse it once to recover the inner JSON string, then parse again to get the actual value.

Is this the same as "json to string" / "json unescape"?

Yes. json to string means convert a JSON value to its string-literal form, which is exactly what Stringify does. json unescape /** unescape json** is the reverse — click Unstringify to remove the escape sequences and recover the original JSON.