JSON Selector Cheatsheet

A simple, student-friendly guide to working with JSON selectors. Learn how to extract data from JSON using JavaScript, JSONPath, JMESPath, and jq with clear examples.

JavaScript Property Access

The most common way to get values out of JSON in JavaScript is by using dot notation or bracket notation. Think of JSON as an object with keys and values — you can “walk down” the keys to reach what you want.

Dot notation is simpler when keys are valid variable names. Brackets are needed if keys have spaces, special characters, or if you want to use a variable.

const obj = { person: { name: "Alice" } };
obj.person.name; // Alice
obj["person"]["name"]; // Alice

JSONPath

JSONPath is like giving directions inside a JSON object. You start with $ (the root), and then follow paths to reach the values you want. It’s like telling someone “go to the store, then look at books, then take their titles.”

It supports wildcards, array indexes, and recursive searches. Beginners can think of JSONPath like CSS selectors but for JSON.

  • $.store.book[*].author — selects all authors of books in the store.
  • $..price — finds all price fields anywhere in the JSON.
  • $.store..book[0] — first book in the store, wherever it appears.

JMESPath

JMESPath is another query language for JSON, often used in tools like AWS CLI. It lets you write clear, expressive queries to fetch exactly what you need.

Unlike JSONPath, it feels more like a filter or database query, making it handy when working with structured JSON data from APIs.

people[?age > `20`].name

Above query means: “from people, select the names where age is greater than 20.”

jq

jq is a command-line tool to process JSON. You can think of it as a Swiss Army knife for JSON in the terminal. It lets you filter, transform, and pretty-print JSON with simple commands.

If you use Linux, macOS, or WSL, jq is very popular for quickly exploring JSON files or API responses without writing code.

jq '.store.book[0].title' data.json

Try it Yourself

Use the box below to paste JSON and test selectors. You can write JSONPath queries in the input field and see the result instantly.

Result:

null

How to use this page

  1. Start with JavaScript selectors to get the basics.
  2. Learn JSONPath for advanced navigation through objects and arrays.
  3. Explore JMESPath if you use AWS or structured queries often.
  4. Try jq in your terminal if you need quick JSON exploration.
  5. Use the interactive tester here to practice your selectors on live JSON.

🚀 Explore More Free Developer Tools

Don’t stop here! Supercharge your workflow with our other powerful converters & formatters.

💡 New tools are added regularly — bookmark DevUtilsX and stay ahead!

Want to support my work?

Buy me a coffee