A product feed lands on your desk with four hundred items in it, and someone asks for every image URL: for a migration, a CDN audit, a spreadsheet of assets. The URLs are in there, but each one sits inside its own item object, mixed in with prices, descriptions and links you do not want. Copying them out by hand means an afternoon of scrolling and a near-certain mistake somewhere in the middle.

JSONPath exists for exactly this shape of problem. It treats a JSON document as an addressable structure, and one expression can walk every item and collect one named field from each. This guide shows how to pull every image URL out of a feed with the free JSONPath Tester on Ovatly, which runs entirely in your browser, and it is honest about the one thing the tool will not do: filter by value.

Contents

  • Quick answer
  • Why image URLs repeat under one key
  • The two paths that collect a repeated field
  • How to extract every image URL, step by step
  • Worked example: from book titles to image URLs
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Find the key the feed uses for its image field, then collect that key from every item with one expression. If the items sit in one array at a known depth, use a wildcard path such as $.items[*].image. If the key appears at several depths, use recursive descent, ..image, which finds that key everywhere in the document. Paste the feed and the expression into the JSONPath Tester and the result is the full list of values, in document order. You cannot filter by value, so collect the field and read the list.

Why image URLs repeat under one key

A feed is generated by code, and code is repetitive. Whatever program produced the document wrote the same object shape hundreds of times: a title field, a price field, and an image field with a name like image, image_url or thumbnail. The name varies between feeds, but inside one feed it is consistent, because it came from one template.

That consistency is what makes extraction a one-expression job instead of a scripting job. You are not hunting for URLs as text. You are asking a structural question: give me the value of this key wherever an item carries it. Spot the key name in the first item or two, and the rest of the document follows.

The two paths that collect a repeated field

The tester supports a documented subset of JSONPath, and two parts of that subset do the collecting. The wildcard [*] steps into every element of an array, and it works over objects too, visiting every value. Follow it with a key and you get that key's value from every element: $.store.book[*].title walks every book in the store and returns each title.

Recursive descent, written ..key, searches the whole document at every depth and returns every value stored under that key name, wherever it appears. It is the right tool when a feed nests its data unevenly: images on the item, images inside a gallery object, a thumbnail on a variant. One descent collects all of them.

The two compose with the rest of the subset: $ for the root, .key for a child, [index] for one array position, and bracket keys such as ['image url'] when a key contains spaces or punctuation that dot notation cannot handle.

How to extract every image URL, step by step

  1. Open the JSONPath Tester and paste in your feed. If the feed is huge, a trimmed sample with the same shape works for building the expression, but run the final query against the full document.
  2. Read the first item and find the image key. Note its exact name and whether items sit in one array or are nested at different depths.
  3. Choose your path. Known array, known depth: build from the root, such as $.products[*].image_url. Unknown or mixed depths: use descent, such as ..image_url.
  4. Run the expression and read the result list. Count it against the number of items you expect to have images, and skim for values that are obviously not image URLs.
  5. Copy the list out. If a few items contributed nothing, that is expected: an item without the key adds nothing and does not break the run.

Worked example: from book titles to image URLs

Start with the tester's own example document, a small store. The expression $.store.book[*].title returns exactly two values, Dune and Emma, because the wildcard visits both books and collects the title key from each. That is the whole mechanism: one pass, one field, every item.

Now give the same store a feed shape. Each book carries an image key alongside its title, and the catalogue also nests a featured image inside a banner object at a shallower depth. The wildcard path $.store.book[*].image returns the two book covers, in order. Switching to ..image returns three values: the banner image plus both covers, because descent does not care which level each one lives at. Same document, same key, two expressions: the difference is precisely whether you wanted the nested one or not.

Limitations and honest tradeoffs

The hard limit is filtering. Full JSONPath dialects offer filter expressions such as [?(...)] to select items by a condition, and this tester does not support them, nor slices, scripts or unions. Type one and you get a clear error naming the unsupported part, not a silent wrong answer. In practice that means you cannot ask for only the items whose image is missing, or only the URLs containing a certain word. You collect the field from everything and read the list yourself.

A related honesty point: a path that returns 0 matches has not failed. It means nothing in the document sits at that address, which is useful information. Usually the key name differs from your guess, or the field lives deeper than your path reaches, and both are fixable once the empty result tells you so.

Finally, the result is a list of values, not a table. You get the URLs in document order, but not paired with the item names they came from. If you need the pairing, run a second query for the name field and line the two lists up, or accept that this job is collection, not reporting.

Common mistakes

  • Searching the raw text for URLs instead. You collect documentation links, author pages and every URL-shaped string in the descriptions. Query the field, not the text.
  • Guessing the key name. Feeds differ: image, image_url, img and thumbnail are all common. Read one item first and copy the name exactly, including its case.
  • Writing a filter and expecting it to work. [?(...)] is not supported and returns an error. Collect the field and filter the short result list by eye.
  • Reading 0 matches as a crash. It is a valid result that tells you the key or the depth is wrong. Try recursive descent before concluding the data is absent.
  • Forgetting nested copies. A wildcard at one depth misses images nested elsewhere. If the feed has galleries or variants, descent is the safer first attempt.

FAQs

Why not just search the raw JSON for links? A text search finds every URL-shaped string, including links inside descriptions, author pages and documentation fields. A JSONPath query collects one named field, so you get the image URLs and only the image URLs, in document order.

Can I extract only the items that have an image? Not with a filter. The tester does not support filter expressions such as [?(...)], and it says so with an error that names the unsupported part. The workflow is to collect the image field from every item and read the resulting list; items without that key simply contribute nothing.

What does it mean when a path returns 0 matches? It means the path is valid but nothing in the document sits at that address. Zero matches is a result, not an error: it usually means the key name is different in this feed, or the field lives at another depth, which recursive descent can check.

What is the difference between the wildcard and recursive descent? The wildcard [*] steps into every element of one array or object, so it works when you know exactly where the items sit. Recursive descent ..key searches every depth, so it works when the same key appears in nested places and you do not want to spell out each level.

Is my JSON uploaded anywhere? No. The tester runs fully in your browser, so the feed you paste never leaves your device. That matters when a feed contains internal URLs or unreleased product data.

Conclusion

Extracting image URLs from a feed is a structural job, not a reading job: find the repeated key, then let a wildcard or recursive descent expression collect it from every item in one pass. The JSONPath Tester does that in your browser, with the stated limit that it collects fields rather than filtering by value. If your images then need words pulled out of them instead, our companion guide on extracting text from an image with OCR covers the opposite direction. For more in this series, see the Data and JSON Tools guides.

References