JSON Filter

Filters a JSON array of objects with a simple key OP value expression (==, !=, >, <, >=, <=, or contains for substring matches), keeping only the items where the comparison holds. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-24

Overview

Introduction

Not every JSON filtering task needs the full power of JSONPath. Often you just want "keep the items where this one field matches this one condition," a SQL-style WHERE clause over a JSON array.

This tool parses that simple expression and filters accordingly, without requiring you to learn JSONPath's filter syntax for a single-condition check.

What Is JSON Filter?

A lightweight query tool that filters a JSON array of objects using one condition expressed as key OP value, where OP is one of ==, !=, >, <, >=, <=, or contains.

It's meant as a fast, readable alternative to writing a one-line Array.filter() by hand or reaching for full JSONPath syntax when you only need a single flat comparison.

How JSON Filter Works

The expression is parsed with a regular expression that splits it into a key, an operator, and a raw value. The raw value is coerced to a number if it looks like one (matching -?\d+(\.\d+)? optionally), otherwise kept as a string with any surrounding quotes stripped.

Each item in the input array is then tested: for ==/!=, a loose equality comparison is used; for the four numeric operators, both sides are coerced with Number() before comparing; for contains, both sides are coerced to strings and checked with String.includes(). Only items where the test passes are kept, in their original order.

When To Use JSON Filter

Use it for a quick single-condition filter, orders where status == "paid", products where price < 50, without setting up a script.

It's also useful as a fast sanity check while exploring an unfamiliar JSON array, to quickly isolate items matching one property you're investigating.

Features

Advantages

  • Simple, readable expression syntax that doesn't require learning JSONPath.
  • Automatically infers whether the comparison value is a number or a string.
  • Supports a substring contains operator that JSONPath's filter syntax doesn't offer directly.

Limitations

  • Only supports a single condition; there's no AND/OR combination of multiple conditions in one expression.
  • Only filters on a top-level key of each item; it can't reach into nested objects (like address.city) without flattening the data first.

Examples

Numeric comparison

Input

expr: price >= 100
data: [{"name":"A","price":80},{"name":"B","price":150}]

Output

[
  { "name": "B", "price": 150 }
]

Only the item whose price is at least 100 is kept.

Invalid expression

Invalid input

expr: price

Parser error

Filter expression must look like: key == value (operators: ==, !=, >, <, >=, <=, contains).

An expression missing an operator and value doesn't match the expected pattern, so the tool reports the required shape instead of guessing.

Corrected version

expr: price > 0

Best Practices & Notes

Best Practices

  • Quote string comparison values that could otherwise look numeric, like status == "007", if you specifically need string comparison rather than numeric coercion.
  • For multi-condition filtering (AND/OR), run this tool once per condition and manually intersect results, or switch to JSONPath Tester for a single combined expression.
  • Flatten nested objects first with JSON Object Flattener if you need to filter on a nested field like address.city.

Developer Notes

Equality uses JavaScript's loose == rather than strict === specifically so a numeric field compared against a string-looking expression value (or vice versa) still matches sensibly; this trades a small amount of type strictness for the expression parser not having to separately guess the target field's actual JSON type ahead of time.

JSON Filter Use Cases

  • Filtering an array of orders or records down to those matching one condition
  • Quickly isolating items with a price, score, or count above/below a threshold
  • Substring-matching a text field like a name or description across an array

Common Mistakes

  • Writing multiple conditions in one expression (like status == active AND price > 10); only a single condition is supported per filter.
  • Expecting nested paths like user.name to work; only a direct top-level key on each item is read.

Tips

  • For a full-featured query language with filters, wildcards, and nested paths, use JSONPath Tester instead.
  • Combine with Group JSON Array: filter down to a subset first, then group the result by another field.

References

Frequently Asked Questions