How to use jq to output JSONL (one independent JSON object per line)

The answer to the original question is to use the filter .[] together with the -c command-line option:

$ jq -c '.[]'

If the input file is very large (notably, if it is too large to fit into memory), it may be better to use jq’s --stream command-line option, or a companion tool. If the preservation of numerical precision is important, then you may wish to consider jm, which is particularly easy to use: invoking jm without any parameters suffices. See the jq Cookbook: https://github.com/stedolan/jq/wiki/Cookbook

Leave a Comment