JSONPath Extractor for LLM Output

Extract values from nested LLM JSON using JSONPath expressions.

Paste a JSON response from an LLM API call and run JSONPath expressions to pull out specific nested values. Supports dot and bracket notation, array indexes, and wildcard traversal, all in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Which JSONPath syntax is supported?

It supports the common subset — the $ root, dot and bracket property access, numeric array indexes, and the [*] wildcard to map over every element of an array or object. It does not support filters or recursive descent.

JSONPath extractor for LLM output

LLM API responses wrap the part you actually want in layers of envelope: choices, message, content, and so on. Clicking through that by hand is tedious. This tool lets you write a JSONPath expression and pull out exactly the values you need, with full wildcard support for flattening arrays — entirely in your browser.

How it works

Paste your JSON and a path expression. The tool parses the JSON, then walks your path segment by segment from the $ root. Property names use dot or bracket notation, array elements use numeric indexes, and a [*] wildcard fans out to every element of an array or every value of an object, so a single path can return many matches. Each match is listed with its resolved value; parse errors and empty result sets are reported distinctly so you know which one you hit.

Tips and notes

  • Start broad, then narrow. Try $ to confirm the JSON parsed, then add segments until you isolate the value you want.
  • Wildcards flatten structured output. $.results[*].label turns a list of objects into a clean list of labels you can copy straight out.
  • Mind array bounds. An index past the end of an array yields no match rather than an error, so an empty result often means the index is too high.
  • Combine with the schema inferrer. Infer the shape of a response first, then write paths against the keys it reveals.

Common JSONPath patterns for LLM API responses

Different model providers nest their output differently. Here are the paths you reach for most often:

OpenAI Chat Completions

The full assistant message text:

$.choices[0].message.content

All choices when n > 1:

$.choices[*].message.content

The finish reason (e.g. "stop" or "tool_calls"):

$.choices[0].finish_reason

Tool call arguments (as a JSON string):

$.choices[0].message.tool_calls[0].function.arguments

Anthropic Messages API

The text of the first content block:

$.content[0].text

All content blocks when the response has multiple:

$.content[*].text

Input token count:

$.usage.input_tokens

Embeddings (OpenAI)

Extract the embedding vector for the first input:

$.data[0].embedding

Extract all vectors when batching:

$.data[*].embedding

Wildcard chaining across nested arrays

Wildcards can be chained. If a structured output returns an array of objects that each contain a sub-array:

{
  "sections": [
    { "items": [{"id": 1}, {"id": 2}] },
    { "items": [{"id": 3}] }
  ]
}

The path $.sections[*].items[*].id fans out through both levels, returning [1, 2, 3] — every id across every nested items array in one expression.

When to use JSONPath vs JSON Pointer (RFC 6901)

Both address values inside a JSON document, but they serve different purposes:

  • JSONPath is expressive and can return multiple matches through wildcards. Use it when you want to fan out across an array or collect all values matching a pattern.
  • JSON Pointer (RFC 6901) resolves to exactly one node — no wildcards, no fanout. It is the standard used by JSON Patch, OpenAPI discriminators, and other specs that need a precise, deterministic reference.

For extracting a single known field from a structured LLM response, either works. For collecting all elements of an array in one expression, JSONPath is the right tool.

Troubleshooting no-match results

An empty result does not always mean the field is absent — it might mean the expression did not parse correctly. Things to check:

  • Missing $ at the start. JSONPath expressions must begin with $ (the root). choices[0].message.content with no leading $ will not match.
  • Wrong key name. JSON is case-sensitive. Message and message are different keys.
  • Index out of range. An index past the last array element returns no match silently. If you are unsure of the array length, try [*] to see all elements, then refine to a specific index.