jq CLI Recipes/Convert API results to CSV

Build CSV rows from JSON array objects.

Section: cURL and API Recipes

Convert API results to CSV

bash
bash
curl -s https://api.github.com/orgs/github/repos?per_page=5 | jq -r '.[] | [.name, .stargazers_count] | @csv'
Explanation

Excellent for spreadsheet exports and ad hoc reports.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing cURL and API Recipes
Pretty-print JSON API response
Format a JSON HTTP response from curl.
OpenIn sheetbashsame section
Extract one field from API response
Print a single field like a repo name or count.
OpenIn sheetbashsame section
List names from API array
Extract one field from each array item in an API response.
OpenIn sheetbashsame section
Filter repos by language
Return only items matching a specific field value.
OpenIn sheetbashsame section
Get EC2 instance IDs
Extract instance IDs from AWS CLI JSON output.
OpenIn sheetbash1 tag match
Extract log levels
Read a field from each JSON log line.
OpenIn sheetbash1 tag match