Toolpuffin

    Loading...

    Up and down to choose, Enter to open, Esc to close.

    How to Learn JSON for Beginners: Syntax, Errors and Parsing

    Updated December 2026

    Written by the Toolpuffin team. Tools in this guide are tested in the browser.

    JSON is the text format that most websites and apps use to send data to each other. It looks like a small piece of JavaScript, but its rules are stricter, and that is where beginners get stuck. This guide explains what JSON is, lists the rules behind most errors, shows how to turn JSON text into a JavaScript value and back, and points to a free course. The facts come from MDN, json.org and the standards.

    Try the tool: Learn JSON

    What JSON is

    MDN describes JSON (JavaScript Object Notation) as a standard text-based format for representing structured data, based on JavaScript object syntax. json.org calls it a lightweight data-interchange format that is easy for people to read and write and easy for machines to parse. Because it is plain text, it can be saved in a file or sent over the internet.

    The standard RFC 8259 says JSON can represent four primitive types (strings, numbers, booleans and null) and two structured types (objects and arrays). An object is a set of name and value pairs in curly brackets. An array is an ordered list of values in square brackets, separated by commas.

    The rules behind most errors

    JSON looks like a JavaScript object, but a JSON parser is strict. A few small differences cause most error messages:

    • Names and text values need double quotation marks. Single quotes are not valid.
    • There is no trailing comma after the last item of an object or an array.
    • There are no comments in JSON.
    • Besides numbers, only the words true, false and null are written without quotes. Other words, such as undefined, are not JSON.

    These rules follow the grammar in RFC 8259. When a text breaks them, JSON.parse stops with an error that names the problem, so read the message instead of guessing.

    From text to value and back

    In JavaScript, JSON.parse() turns JSON text into a value you can work with, and JSON.stringify() turns a value back into JSON text. MDN points out that once the text is parsed, you work with it like any object that you wrote with the same object syntax.

    1. Get the JSON text, for example from a file or from a server.
    2. Call JSON.parse(text) to get a value.
    3. Read its properties with a dot or square brackets, and loop over arrays.
    4. When you want to save or send the data again, call JSON.stringify(value).

    MDN also advises to validate any data you are going to use. Data from outside your own code can be wrong, even when it is valid JSON.

    Practise with real error messages

    The free course has eight short lessons: objects, strings, numbers, arrays, nesting, booleans and null, finding the error in broken JSON, and reading a value with JSON.parse. In the lessons about JSON syntax the course uses the JSON.parse of your own browser, so the error messages you see are the real ones. The last lesson checks your JavaScript with simple rules and does not run it.

    Sources

    More guides