What Is JSON? A Practical Guide to JSON Syntax, Objects and Arrays

JSON is one of the most common formats used to exchange structured data between applications. You see it in web APIs, configuration files, browser applications, automation workflows and many developer tools.

In this guide, you will learn what JSON is, how its structure works, which syntax rules matter most, and how to troubleshoot common errors with the IceNex JSON Formatter.

What does JSON mean?

JSON stands for JavaScript Object Notation. Despite its name, JSON is not limited to JavaScript. It is a text-based format that can be generated and read by many programming languages.

The format represents structured data using objects, arrays, strings, numbers, Boolean values and null. Its syntax is intentionally compact and readable, which makes it practical for communication between a browser, an application and a server.

A simple JSON object

The following example describes a technology tool using a JSON object:

{
  "name": "JSON Formatter",
  "category": "Developer Tools",
  "free": true,
  "features": [
    "Format JSON",
    "Validate JSON",
    "Minify JSON"
  ]
}

An object begins with { and ends with }. Inside the object, each property has a string name followed by a colon and a value. Properties are separated by commas.

Objects and arrays

A JSON object stores named properties. It is useful when each value has a meaningful key, such as name, category or free.

A JSON array stores an ordered collection of values. It begins with [ and ends with ]. The values inside an array are separated by commas.

{
  "tools": [
    "JSON Formatter",
    "Base64 Encoder",
    "UUID Generator"
  ]
}

Arrays may contain strings, numbers, Boolean values, objects or other arrays. This makes it possible to represent simple lists as well as more complex data structures.

The six valid JSON value types

JSON supports the following values:

  • String: text enclosed in double quotation marks, such as "IceNex Tools".
  • Number: an integer or decimal number, such as 42 or 3.14.
  • Object: a collection of name-and-value pairs enclosed in curly brackets.
  • Array: an ordered collection enclosed in square brackets.
  • Boolean: either true or false.
  • Null: the literal value null, used to represent the absence of a value.

JSON syntax rules that commonly cause errors

Property names require double quotes

JSON property names must use double quotation marks. This is valid:

{
  "name": "IceNex"
}

This is not valid standard JSON:

{
  name: "IceNex"
}

Trailing commas are not allowed

A comma may separate two values, but the final property or array item must not be followed by a comma.

{
  "name": "IceNex",
  "type": "Technology"
}

Use JSON literals in lowercase

The valid Boolean and null literals are true, false and null. Variations such as True, FALSE or None are not valid JSON literals.

Strings must use double quotation marks

JSON strings use double quotation marks. Single quotation marks may be accepted by some programming languages, but they are not valid for standard JSON strings.

How to validate and format JSON

When JSON comes from an API response or a configuration file, it may be compressed into a single line. Formatting adds indentation and line breaks, making the structure easier to inspect.

  1. Open the IceNex JSON Formatter.
  2. Paste the JSON into the input area.
  3. Choose Format JSON to make the structure easier to read.
  4. Choose Validate JSON to check whether the syntax is valid.
  5. Review the error location if the input is invalid.

Formatting does not change the meaning of valid data. It changes the presentation so that objects, arrays and nested values are easier to understand.

Formatting is different from validation

Formatting organizes valid JSON with indentation and line breaks. Validation checks whether the text follows the JSON syntax rules.

A formatter cannot repair every possible problem automatically. If a property is missing a quotation mark or a comma is placed incorrectly, the input must be corrected before it can be formatted reliably.

JSON and JavaScript are related but not identical

JSON was derived from JavaScript object syntax, but JSON has stricter rules. For example, standard JSON requires double-quoted property names and does not support JavaScript comments, functions or values such as undefined.

In JavaScript, a JSON string can be converted into an object with JSON.parse(). An object can be converted back into a JSON string with JSON.stringify().

const text = '{"name":"IceNex"}';
const data = JSON.parse(text);

const output = JSON.stringify(data);

Privacy and sensitive data

Before pasting information into an online utility, remove passwords, private keys, access tokens and confidential business data. The IceNex JSON Formatter is designed to process formatting and validation in the browser, but visitors should still review the type of information they enter into any online tool.

Final thoughts

JSON is simple enough to read manually and structured enough to support communication between different applications. Understanding its objects, arrays and syntax rules makes it easier to work with APIs, configuration files and developer tools.

When a JSON document is difficult to read or produces a syntax error, the IceNex JSON Formatter can help you format the structure, validate the syntax and identify common mistakes.

References

  1. RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format.
  2. MDN Web Docs — Working with JSON.