Tool description

Paste JSON into the JSON array editor, and Elements shows how many items the array holds, ready to copy. Only the top level is counted, so [[1, 2], [3]] has 2 elements.

When the JSON is an object, such as an API response with its list under data, the tool looks for arrays inside it and counts the one nearest the top. The field label then names that array, as in Elements in $.data. When there's more than one array, a table lists each one with its path and length. Arrays nested inside other arrays aren't searched.

Paths are written the JSONPath way: $ is the whole document, $.data.items is the items array inside data, and a key with spaces or symbols goes in brackets, like $["my list"].

Features

  • Counts the elements of a JSON array as you type
  • Finds the arrays inside an object and lists each one with its path and length
  • Explains what's wrong when the JSON isn't valid or has no array

Example

For this API response:

{
  "page": 1,
  "data": [{ "id": 1 }, { "id": 2 }, { "id": 3 }],
  "meta": { "tags": ["new", "sale"] }
}
JSON

Elements in $.data shows 3, and the table lists $.data with 3 elements and $.meta.tags with 2.

Tips

  • The JSON has to be valid, so comments, single quotes and a comma after the last item give an error. The JSON repairer fixes those.
  • An empty array counts as 0 elements, and it's still listed in the table.