{ }jsonkitOpen

JSON array of objects: syntax, examples and how to use it

7 min read · updated 2026-10-01

A JSON array of objects is a list of records: square brackets around a comma-separated list of objects, where each object holds key-value pairs. It is the most common shape for API responses, exports and fixtures, because it maps directly to rows in a table.

This guide shows the syntax, the mistakes that make it invalid, and how to read, filter and convert an array of objects in JavaScript, Python and a spreadsheet.

What a JSON array of objects looks like

An array starts with [ and ends with ]. Each item is an object in curly braces, and items are separated by commas. There is no comma after the last item.

users.json: an array of three user objectsjson
[
  { "id": 1, "name": "Ada", "email": "ada@example.com", "active": true },
  { "id": 2, "name": "Grace", "email": "grace@example.com", "active": false },
  { "id": 3, "name": "Linus", "email": "linus@example.com", "active": true }
]

A JSON document can be an array at the top level. RFC 8259 allows any value as the root, so the file above is valid on its own. Many APIs still wrap the array in an object, such as {"users": [...]}, so they can add paging fields like next or total later without breaking clients.

Rules and common mistakes

  • Keys and string values use double quotes. {'id': 1} is not JSON.
  • No trailing comma after the last object or the last key.
  • Objects in the same array do not have to share keys, but code is simpler when they do. A missing key is usually read as undefined or None.
  • Order is kept. An array is ordered, so the first object stays first. Key order inside each object carries no meaning.
  • Use null for an empty value, not an empty string, when the field has no value.

If an array refuses to parse, paste it into the JSON validator to find the line and column of the problem.

Loop, filter and find items in JavaScript

JSON.parse turns the text into a normal JavaScript array, so the usual array methods work.

Common operations on an array of objectsjs
const users = JSON.parse(text)

for (const user of users) console.log(user.name)

const active = users.filter((u) => u.active)          // two objects
const names = users.map((u) => u.name)                // ["Ada", "Grace", "Linus"]
const grace = users.find((u) => u.id === 2)           // the Grace object
const byId = Object.fromEntries(users.map((u) => [u.id, u]))

To turn an array back into JSON text, use JSON.stringify(users, null, 2). See JSON in JavaScript for parsing and stringifying in depth.

Read an array of objects in Python

json.load returns a list of dicts. List comprehensions handle most filtering.

Filtering a list of dicts in Pythonpython
import json

with open("users.json") as f:
    users = json.load(f)

active = [u for u in users if u["active"]]
names = [u["name"] for u in users]
grace = next(u for u in users if u["id"] == 2)
email = users[0].get("phone", "none")  # safe lookup for a missing key

JSON in Python covers reading files, writing them back and handling errors.

Query it without code

For a quick look, a query language is faster than a script. Each line below runs against users.json:

GoalJSONPathjq
All names$[*].name.[].name
Active users$[?(@.active == true)].[] | select(.active)
CountNot supportedlength
Pick two fieldsNot supportedmap({id, name})

Try JSONPath in the JSONPath tester and jq filters in the jq tester.

{⌄}JSON ViewerExplore a large array as a collapsible tree with item counts.→

Convert an array of objects to CSV or Excel

Because each object is a record, an array of objects converts cleanly to a table. Keys become column headers and each object becomes a row. Nested objects are flattened into dot-path columns such as plan.tier.

→csvJSON to CSVTurn the array into CSV with one row per object.→→xlsxJSON to ExcelDownload the array as an Excel .xlsx workbook.→

Going the other way, the CSV to JSON converter turns a spreadsheet export back into an array of objects.

Describe it with JSON Schema

To validate an array of objects, use type: "array" with an items schema that describes one object. Every element is checked against it.

A schema for users.jsonjson
{
  "type": "array",
  "items": {
    "type": "object",
    "required": ["id", "name"],
    "properties": {
      "id": { "type": "integer" },
      "name": { "type": "string" },
      "active": { "type": "boolean" }
    }
  }
}

Generate a starting schema from your data with the JSON Schema generator, then check other files against it with the JSON Schema validator.

Frequently asked questions

How do you write an array of objects in JSON?

Put the objects between square brackets and separate them with commas: [{"id": 1}, {"id": 2}]. Keys and strings need double quotes, and there is no comma after the last object.

Can a JSON file start with an array?

Yes. RFC 8259 allows any JSON value at the top level, including an array. Many APIs still wrap arrays in an object so they can add fields later.

Do all objects in a JSON array need the same keys?

No. JSON does not require it. Code and conversions are simpler when they match, because a missing key has to be handled as undefined or None.

How do I get one object from a JSON array by id?

In JavaScript, users.find((u) => u.id === 2). In Python, next(u for u in users if u["id"] == 2). In jq, .[] | select(.id == 2).

How do I convert a JSON array of objects to CSV?

Use a JSON to CSV converter. Each object becomes a row and each key becomes a column. Nested values are flattened into dot-path columns.