How to use the json stringify / parse
- Paste your text into the Input text field.
- Choose Parse to convert a string to JSON, or Stringify to serialize a value.
- Set the number of Indent spaces for the output formatting.
- The result appears immediately below as you type.
How json parse works
The built-in JSON.parse() method reads a text string and constructs the corresponding JavaScript value. The input must follow strict JSON syntax: double quotes around keys and string values, no trailing commas, and no comments. For example, parsing the string {"count":42} produces an object with a numeric property. If the text violates the grammar, the parser throws a SyntaxError that this tool catches and displays.
When you select the parse direction, the tool first parses the raw string into a value, then immediately re-serializes it using JSON.stringify with your chosen indentation. This round-trip normalizes whitespace and confirms the input was valid JSON.
Using json stringify
The JSON.stringify() method converts a value into a JSON text string. It accepts three arguments: the value, an optional replacer, and an optional space parameter for indentation. In this tool, the space parameter is controlled by the indent field. Setting it to 0 produces a minified single-line string, while 2 or 4 adds line breaks and leading spaces.
Because browsers cannot safely evaluate arbitrary JavaScript objects from user input, the stringify mode here also expects valid JSON text. It parses the input first, then re-stringifies it with the requested formatting. To convert actual JavaScript object literals (with unquoted keys or single quotes), use a dedicated code formatter or wrap your data in valid JSON first.
Common conversion examples
| Input | Mode | Indent | Output |
|---|---|---|---|
{"a":1} | Parse | 2 | Pretty-printed object |
[1,2] | Stringify | 0 | [1,2] |
"text" | Parse | 2 | "text" |
null | Parse | 2 | null |
true | Stringify | 0 | true |
Primitive values like strings, numbers, booleans, and null are valid JSON on their own. You can parse or stringify them without wrapping them in an object or array.
Edge cases and common mistakes
Several patterns cause a string to JSON conversion to fail. Single quotes ('key') are not valid JSON; all strings must use double quotes. Trailing commas after the last element in an object or array will throw an error. Comments, both // and /* */, are not part of the JSON specification and must be removed before parsing.
Special numeric values like NaN and Infinity are not representable in JSON. When JSON.stringify encounters them inside an object, it converts them to null. If they appear at the top level, the result is undefined. Keep this in mind when serializing data from mathematical computations.
For validating complex payloads before sharing them with an API, consider pairing this tool with a json validator to check structure and schema compliance.
Worked examples
Each result below was produced by the same code the tool runs, so you can check your own numbers against them.
| Example | Input | Result |
|---|---|---|
| Parse a compact string | Input text: {"name":"Ada","year":1815}; Direction: parse; Indent spaces: 2 | { / "name": "Ada", / "year": 1815 / } |
| Stringify with 4 spaces | Input text: {"a":1,"b":[2,3]}; Direction: stringify; Indent spaces: 4 | { / "a": 1, / "b": [ / 2, / 3 / ] / } |
| Minify (zero indent) | Input text: { "x" : true , "y" : null }; Direction: stringify; Indent spaces: 0 | {"x":true,"y":null} |
FAQ
What does json parse do?
It reads a JSON-formatted text string and converts it into a usable data structure, such as an object, array, string, number, boolean, or null value.
How do I convert a string to JSON?
Paste the string into the input field and select the Parse mode. The tool will validate the text and display the formatted result.
What is json stringify used for?
It serializes a data value into a JSON text string, which is necessary for sending data over networks or storing it in text-based formats.
Why does my input throw a SyntaxError?
JSON requires double quotes for keys and strings, no trailing commas, and no comments. Check your input for single quotes or missing brackets.
Can I minify JSON with this tool?
Yes. Select the Stringify mode and set the indent spaces to 0. The output will be a single-line string with no extra whitespace.
Is my data sent to a server?
No. All parsing and stringifying happens locally in your browser. Nothing is uploaded anywhere.
Does it handle large JSON files?
It works well for typical configuration and API payloads. Extremely large files may cause the browser tab to slow down due to memory limits.