JSON.stringify() online — JS, Python, Java snippets

Convert JSON to string
Escaped, quoted,
ready to embed.

Serialise any JSON object to an escaped string — the online equivalent of JSON.stringify(). Includes ready-to-copy code snippets for JavaScript, Python and Java.

Your data never leaves your browser
JSON.stringify() equivalent
json.dumps() Python snippet
Wrap in outer quotes option
Always free
JSON to String Converter   100% client-side
This tool is the reverse of JSON String to JSON. It converts a JSON object to its escaped string representation.
JSON input
  JSON string ready

 
        
        
How to do this in code
JSON to string in every language

The one-liner for each major language and environment.

JavaScript / Node.js

JSON.stringify(obj) — built-in, no import needed. Add a second argument for a replacer and a third for indentation: JSON.stringify(obj, null, 2). To embed in another JSON value, call JSON.stringify(JSON.stringify(obj)).

Python

import json; s = json.dumps(obj). Use json.dumps(obj, indent=2) for pretty output. For embedding: json.dumps(json.dumps(obj)). The ensure_ascii=False flag preserves Unicode characters.

Java

With Jackson: new ObjectMapper().writeValueAsString(obj). With Gson: new Gson().toJson(obj). Both produce a compact JSON string. Use ObjectMapper().writerWithDefaultPrettyPrinter() for indented output.

Other languages

PHP: json_encode($obj). Ruby: obj.to_json or JSON.generate(obj). Go: json.Marshal(obj). C#: JsonSerializer.Serialize(obj) or JsonConvert.SerializeObject(obj).

Popular searches
convert json to string json to string online json stringify online json to json string json object to string convert json to string javascript json to string converter json to string python json to escaped string online json to string java
Frequently asked questions
Common questions about converting JSON to a string.
How do I convert JSON to a string?
Paste your JSON object or array into the converter above and click Convert. The output is the escaped string equivalent — identical to what JSON.stringify() produces in JavaScript. Copy it directly into your code or use it to embed JSON inside another JSON value.
What is the difference between JSON and a JSON string?
JSON is a data format — {"name": "Alice"}. A JSON string is the serialised text representation — "{\"name\":\"Alice\"}" — produced by JSON.stringify() in JavaScript or json.dumps() in Python. The JSON string can be stored in a text field, passed as an HTTP body, or embedded inside another JSON value.
How do I convert JSON to a string in JavaScript?
Use JSON.stringify(obj) — built-in, no library needed. For pretty output: JSON.stringify(obj, null, 2). To embed inside another JSON string: JSON.stringify(JSON.stringify(obj)). The result is a string with backslash-escaped quotes.
How do I convert JSON to a string in Python?
Use json.dumps() from the built-in json module: import json; s = json.dumps({"name": "Alice"}). Use indent=2 for readable output. Add ensure_ascii=False to keep Unicode characters as-is instead of escaping them to \uXXXX sequences.
Go up