Skip to content

Instantly share code, notes, and snippets.

@arosenkranz
Created November 20, 2023 16:21
Show Gist options
  • Save arosenkranz/f129b75efc777bb1d22c1f4956866f36 to your computer and use it in GitHub Desktop.
Save arosenkranz/f129b75efc777bb1d22c1f4956866f36 to your computer and use it in GitHub Desktop.
Convert JSON to CSV
cat <file.json> | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' > <output.csv>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment