Skip to content

JSON Parser Online

Paste JSON to check it, see exactly where and why it breaks, and browse it as a tree. Click any value to copy its path, or format and minify the whole document.

Checks as you type · tree view · paths · fixes common mistakes

Valid JSON · object with 5 keys · 3 levels deep · 278 bytes

Click a row to see its path and copy its value.

Everything runs in your browser; nothing is uploaded.

What is a JSON parser?

A JSON parser reads JSON text and turns it into data a program can use: objects, lists, text, numbers and true/false values. It reads the text one character at a time, checks it follows JSON’s rules, and builds the structure. If a single comma or quote is wrong, it stops and reports where.

An online parser does the same thing in your browser, then shows you the result. This is useful when an API response, a log line or a config file won’t load and you need to see why, or when you need to find one value inside a large document.

JSON has six kinds of value. Here is what each one becomes after parsing:

JSON value types and what they become when parsed in JavaScript and Python
JSONExampleJavaScriptPython
Object{"qty": 2}objectdict
Array[1, 2, 3]arraylist
String"Maya"stringstr
Number8.5numberint / float
BooleantruetrueTrue
NullnullnullNone

How to parse JSON online

  1. Paste your JSON into the box, or use Open file or drop a .json file onto it. It is checked as you type.
  2. Read the status line. Valid JSON shows its size and shape. Invalid JSON shows the line and column, what is wrong, and a pointer under the exact character.
  3. Fix it. Go to line jumps to the problem. For pasted JavaScript or Python, Fix common mistakes changes single quotes, unquoted names, trailing commas, comments and True/False/None in one go, and you can undo it.
  4. Explore the tree. Expand objects and arrays, search for a key or value, and click a row to copy its path or value.
  5. Copy or download the result from Formatted, indented with 2 or 4 spaces or tabs, or minified onto one line.

For a picture of the whole structure, paste the same JSON into the JSON data graph.

Example: find a value in an API response

An online shop’s API returns this order, and you need the price of the T-shirt for your code. It is the example loaded in the tool above.

{ "orderId": 1048, "customer": {…}, "items": [ { "sku": "MUG-01", … "price": 8.5 }, { "sku": "TEE-M", "name": "T-shirt", "qty": 1, "price": 15 } ], "paid": true, "coupon": null }

Step 1: Find it in the tree

Open items, then item 1 (counting starts at 0, so the T-shirt is the second item). Or type T-shirt in the search box.

Step 2: Click the price row

Path: items[1].price → 15

Step 3: Use the path in your code

const data = JSON.parse(text); data.items[1].price // 15

The answer is 15. In Python the same value is data["items"][1]["price"].

Common JSON parse errors and how to fix them

Browsers and languages word the same mistake differently. These are the messages people see most, from Chrome (JavaScript) and Python:

Common JSON parse error messages, what causes them and how to fix them
Error messageCauseFix
Unexpected token '<', "<!DOCTYPE "… is not valid JSONThe server sent an HTML page (an error or sign-in page), not JSONCheck the URL, status code and login
Expected property name or '}' · Expected double-quoted property name · Expecting property name enclosed in double quotesSingle quotes, a name without quotes, or a comma before }Use "double quotes" and remove the last comma
Expected ',' or '}' after property value · Expecting ',' delimiterA missing comma, usually at the end of the line aboveAdd the comma
Unexpected end of JSON input · Expecting value: line 1 column 1 (char 0)The text is empty or was cut offCheck that the response has a body; look for a missing } or ]
Bad control character in string literal · Invalid control characterA real line break or tab inside "text"Write \n or \t instead
Unexpected non-whitespace character after JSON · Extra dataTwo JSON values one after another, often JSON LinesWrap them in [ ] with commas, or read one line at a time

The position in an error is where the parser gave up, which is often just after the real mistake. A missing comma at the end of line 3 is reported at the start of line 4. The pointer in the tool shows the same spot, so look at the character it points to and the one just before it.

How to parse JSON in code

Every major language has a built-in JSON parser:

// JavaScript
const data = JSON.parse(text);
const data = await response.json();      // from fetch()

# Python
import json
data = json.loads(text)                  # from a string
with open("order.json") as f:
    data = json.load(f)                  # from a file

// PHP: true gives arrays instead of objects
$data = json_decode($text, true);

// C# (.NET)
using System.Text.Json;
var doc = JsonDocument.Parse(text);
var price = doc.RootElement.GetProperty("items")[1].GetProperty("price").GetDecimal();

// Java (Jackson)
JsonNode data = new ObjectMapper().readTree(text);
int price = data.get("items").get(1).get("price").asInt();

To turn data back into JSON text, use JSON.stringify() in JavaScript or json.dumps() in Python. See JSON Stringify Online.

Watch out for long numbers in JavaScript. JSON.parse stores every number as a double, which is only exact up to 9,007,199,254,740,991. An ID like 1585741526539010048 silently becomes 1585741526539010000. That is why APIs often send IDs as text as well ("id_str"). This tool keeps the digits exactly as written and warns you when JavaScript would change them. Load the long ID example to see it.

Frequently asked questions

What is the difference between parsing and formatting JSON?

Parsing reads JSON text and turns it into data, failing if the text breaks the rules. Formatting (beautifying) writes that data back out as text with indentation and line breaks so people can read it. This tool parses first, then shows the formatted or minified result.

Is my JSON uploaded anywhere?

No. Parsing, the tree and the fixes all run in your browser. Nothing you paste or open is sent to a server, so you can check responses that contain private data.

Can it read JSON with comments or single quotes?

Standard JSON allows neither, so they are reported as errors. Fix common mistakes rewrites comments, single quotes, unquoted names, trailing commas and Python True/False/None into valid JSON, and Undo puts your text back.

Why does a long number change after parsing?

JavaScript numbers are only exact up to 9,007,199,254,740,991 (2^53 − 1). Longer integers are rounded by JSON.parse. Send them as strings, or use a parser that supports big numbers. This tool keeps the original digits and flags them.

Sources