What Is JSON Parse? What a JSON Parser Does and What It Changes
JSON parse means turning JSON text into data a program can use. Learn what a JSON parser changes, what it discards, and when to keep plain text instead.
"JSON parse" means reading JSON text and turning it into data structures a program can work with. The phrase most often refers to the JavaScript method JSON.parse(), but every major language has an equivalent. A JSON parser checks text against JSON syntax. If the text is valid, the parser builds objects, arrays, strings, numbers, booleans and null values. If it is not valid, the parser reports an error. This review covers what parsing changes, what it leaves behind, and when you need it rather than simply formatting the text or keeping it as it is.
Is parsing the right step for your use?
Parse JSON when code needs to read, compare or modify individual values, such as a field in an API response or a setting in a configuration file. You get two benefits: structured values you can access by name or position, and an immediate check that the syntax is valid. The main tradeoff is that the result is no longer the original text. Whitespace, escape spelling and number formatting are discarded. Depending on the language, duplicate keys and the precision of very large numbers may also be lost. Keep the plain text when the exact characters matter: verifying a signature or hash, storing an audit record of what was received, or comparing payloads byte for byte. If a person only needs to read the JSON, formatting it (pretty-printing) is usually enough, and no parsing is required on your side.
What parsing actually changes
Parsing is not a visual effect. Reversed text, mirrored glyphs and Unicode "fonts" all produce new text. Parsing produces something else: values held in a program's memory. The input is a string of characters, and the output is a data structure. The reverse operation is called serialization. In JavaScript that is JSON.stringify(), which turns the data back into JSON text.
const text = '{"name": "Ada", "tags": ["math", "code"], "active": true}';
const data = JSON.parse(text);
data.name; // "Ada"
data.tags[1]; // "code"
data.active; // true (a boolean, not the text "true")
JSON.parse('{"name": "Ada",}'); // throws SyntaxError: trailing comma is not valid JSON
In this example, the parsed value no longer holds quotation marks, commas or spaces. It holds a name, a list and a boolean. Strict JSON also rejects some things people often expect to work: comments, trailing commas, single-quoted strings and unquoted keys. Text that uses these may be valid JavaScript or a looser format such as JSON5, but a standard JSON parser will refuse it.
Parse, format, validate, stringify: clearing up the terms
| Operation | Input | Output | Changes the data? |
| Parse (decode, deserialize) | JSON text | In-memory values | Converts text into values |
| Stringify (encode, serialize) | In-memory values | JSON text | Converts values into text |
| Format (pretty-print, beautify) | JSON text | Indented JSON text | No; whitespace only, though most tools parse internally to do it |
| Minify | JSON text | Compact JSON text | No; whitespace removed |
| Validate (syntax) | JSON text | Pass or error | No |
| Validate (schema) | Parsed values plus a schema | Pass or list of violations | No |
Online tools labeled "JSON parser" often format the text, check its syntax and display it as a collapsible tree. That is useful for reading, but it is not the same as parsing in your own program. When choosing a tool, check which of these operations it actually performs.
What may not survive a parse and re-serialize round trip
- Whitespace and indentation: discarded during parsing. Re-serializing produces whatever spacing the serializer chooses.
- Escape spelling: "\u00e9" and "é" parse to the same character. JSON.stringify writes it back as "é", so the text differs while the meaning stays the same.
- Number spelling: 1.0 becomes 1, and 1e3 becomes 1000.
- Large integers in JavaScript: numbers are stored as 64-bit floating point values, so integers beyond 9007199254740991 can silently change.
- Duplicate keys: the JSON standard (RFC 8259) says object names should be unique and notes that implementations handle duplicates differently. JSON.parse and Python's json.loads both keep the last value.
- Key order in JavaScript: keys that look like integers are moved ahead of other keys when the object is serialized again.
- Dates: JSON has no date type, so dates stay as strings unless you convert them yourself. In JavaScript you can do this with JSON.parse's optional reviver argument.
- NaN and Infinity: these are not valid JSON. JSON.parse rejects them, while Python's json.loads accepts them by default, which can cause problems when data moves between systems.
JSON.parse('{"id": 9007199254740993}').id;
// 9007199254740992 (precision lost)
JSON.parse('{"a": 1, "a": 2}');
// { a: 2 } (first value dropped)
JSON.stringify(JSON.parse('{"b": 1, "2": 0, "a": 1}'));
// '{"2":0,"b":1,"a":1}' (integer-like key moved first)
These results are specific to JavaScript. Python's json module, for example, keeps large integers exact. If precision, key order or duplicate detection matters for your data, check your language's documentation. A common safeguard for identifiers is to send them as strings rather than numbers.
Readability and usability after copying or sharing
A parsed value cannot be copied or shared directly. What gets shared is always serialized text. Pretty-printed JSON is easier for people to scan and review. Minified JSON is smaller but hard to read, search line by line or compare in a diff. If you copy from a tool's tree view, you may get display text rather than valid JSON, depending on the tool. This was not tested for any specific tool. To confirm a copy is still valid, paste it back into a parser.
Deeply nested JSON is difficult to follow when read in a straight line. How brackets, quotes and indentation are announced depends on the assistive technology and its settings. No scoped test was done for this review, so no claim is made about any particular screen reader. When JSON is shared with non-technical readers, or with anyone who may rely on assistive technology, include a plain-language summary or a simple table of the key values alongside it.
Safety and privacy notes
JSON.parse does not execute code. Evaluating JSON as JavaScript, for example with eval(), can execute code and should not be used. Parsed data is still untrusted input, though. Check that it has the shape and types your code expects before using it, and consider schema validation for data from outside sources. Before pasting sensitive data into an online parser, find out from the tool's documentation whether processing happens in your browser or on a server. A tool's appearance or marketing does not tell you how it handles your data. For secrets such as tokens, passwords or personal records, a local parser is the safer default.
Where to find a JSON parser
- JavaScript: JSON.parse() is built into browsers and Node.js.
- Python: json.loads() for strings and json.load() for files, both in the standard library.
- Go: json.Unmarshal in the standard encoding/json package.
- PHP: json_decode(), built in.
- Command line: jq is a widely used, separately installed tool for parsing, querying and formatting JSON.
When searching for documentation or tools, use terms like "JSON parse," "JSON decode," "JSON deserialize" or "JSON to object" together with your language name. Use "JSON formatter" or "JSON validator" if you only need to read or check the text. This review did not evaluate specific online JSON tools, so no particular site is recommended.