This is a Node.js CLI utility to convert a file containing one JSON object per line into a CSV file.
The CSV file is written to stdout so that the output can be redirected or piped anywhere you want.
node json2csv.js records.txt > records.csv
where each line in records.txt is a JSON object.
The JSON object in the first line is used to define the structure of the CSV. The header row will be generated from its keys. Additional fields in subsequent records will be ignored.