DEV Community


Convert JSON to CSV using JSON path expressions with

moboudra profile image Mohamed Boudra ・1 min read

JSON paths are a very simple and intuitive way to reference elements in JSON documents, similar to CSS selectors, but for JSON.

This is how it works, if you had a document like this:

    "name": "Christopher",
    "age": "23",
    "name": "Michael",
    "age": "45",
Enter fullscreen mode Exit fullscreen mode

You could extract the names of all the person records with this expression:

Enter fullscreen mode Exit fullscreen mode


  • $ references the root element, in this case an array
  • * is to repeat the expression, so it will match on each object of the array
  • name is to get the name property of the object

So if you used this expression to convert to CSV, this would result in:

Enter fullscreen mode Exit fullscreen mode

This is very useful when you need to flatten very complex JSON documents, and you only want to extract a few fields.

Go ahead and try our custom JSON to CSV conversion tool. Any feedback is welcome!

Discussion (1)

Editor guide
thulasiram_ponnam_8d5e32b profile image
!2C RAM @

try & instantly validate and Beautify JSON using