How to use the JSON array tools
- Paste your data into JSON array.
- Optionally type a Filter, such as
score >= 80orname contains an. Leave it empty to keep every item. - Type a Sort by field and choose the Sort direction. Leave the field empty to keep the original order.
- List fields under Keep only fields (comma separated) to drop the rest.
- Set a Page size (0 shows all) and the Page to view, then copy or download the Result.
The counters show Matched, Total items, Page (for example 2 of 5) and Shown.
What it does and when to use it
This is a small, visual stand-in for the filter, sort, map and slice chain you would otherwise write in JavaScript or jq. Use it to trim a large API response to the records and fields a bug report needs, to make a compact fixture for a unit test, to find the top ten items by some value, or to check how a paginated endpoint should split a list.
The filter understands ==, !=, >, >=, <, <=, contains, startsWith, endsWith, matches (a regular expression), in and !in (comma-separated lists), and exists / !exists. Field names can be paths such as meta.w or tags[0].
For filters written one per line with an “any” option and a table view, see JSON query. To view the result as rows and columns, paste it into JSON to table, or turn it into lines for streaming with the JSON Lines converter.
How it works
Everything runs in your browser on the parsed array. Text comparisons in contains, startsWith and endsWith ignore case. Sorting uses the English locale compare with numeric ordering for text, and plain subtraction for numbers. Keep only fields reads each path and stores it under that exact name, so meta.w becomes a key literally called meta.w rather than a nested object. Paging is applied last, and a page number past the end shows the last page.
Worked examples
Files inside {"data": [...]}, filtered with file endsWith .png, sorted by file ascending, keeping file, meta.w:
[{"file":"img1.png","meta.w":400},{"file":"img2.png","meta.w":1600},{"file":"img10.png","meta.w":800}]
Three of four items match, and natural order puts img10.png last.
Same data, no filter, sorted by kb descending, keeping file,kb: the list ends with {"file":"notes.txt","kb":3},{"file":"img1.png","kb":null}, because the null value goes to the end.
[1,2,3,4,5,6,7] with page size 3 and page 3 shows [7] and Page: 3 of 3.
Limits and tips
- The word “and” only splits conditions when the part after it is a condition, so
title == Salt and Pepperstays one condition. Quote a value, as intitle == "A and x > 1", if it looks like a condition itself. matchesuses a JavaScript regular expression and ignores case.
Frequently asked questions
In what order are the steps applied?
How are text values sorted?
My data is inside an object like {"data":[...]}. Does that work?
How do I combine several filter conditions?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.