Skip to content

Instantly share code, notes, and snippets.

Last active January 31, 2024 20:57
  • Star 53 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bzerangue/7bf6610079659e57b8d50ecb94928c31 to your computer and use it in GitHub Desktop.

NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.

  • Each line is a valid JSON value
  • Line separator is ‘\n’

1. Convert JSON to NDJSON?

cat test.json | jq -c '.[]' > testNDJSON.json

With this simple line of code, you can convert and save files in NDJSON format.

Note: jq is a lightweight and flexible command-line JSON processor.


Copy link

jq can choke on very large files, and be slow. For these situations I made json2nd.

Thanks for sharing @draxil !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment