How to Convert JSON file to CSV in Node.js

Convert JSON file to CSV in Node.js

JSON (JavaScript Object Notation) is standard text-based format to store and transmit data between web clients and web servers. CSV (Comma Separated Values) is also a text file format to store the data in a table structured format. In certain cases, you may need to import dictionary objects to comma separated values within Node.js applications. For such cases, this article demonstrate how to convert JSON file to CSV in Node.js.

The following topics shall be covered in this article:

JSON to CSV Conversion REST API and Node.js SDK

Best way to convert JSON to CSV is using the Node.js SDK of GroupDocs.Conversion Cloud API. It is a platform-independent JSON to CSV library and document conversion solution. It allows you to seamlessly convert your documents and images of any supported file format to any format you need. You can easily convert between over 50 types of documents and images such as Word, PowerPoint, Excel, PDF, HTML, CAD, raster images, etc. It also provides .NET, Java, PHP, Ruby, Android, and Python SDKs as its document conversion family members for the Cloud API.

You can install GroupDocs.Conversion Cloud to your Node.js project using the following command in the console:

npm install groupdocs-conversion-cloud

Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Once you have your ID and secret, please add in the code as shown below:

How to Convert JSON to CSV file in Node.js using REST API

You can convert nested json to csv in nodejs programmatically on the cloud by following the steps given below:

  1. Upload the JSON file to the cloud
  2. Convert nodejs JSON to CSV file
  3. Download the converted CSV file

Upload the JSON File

Firstly, upload the JSON file to the cloud using the following code sample:

As a result, the uploaded JSON file will be available in the files section of your dashboard on the cloud.

Convert JSON to CSV format in Node.js

You can convert json to csv node programmatically by following the steps as given below:

  • Create an instance of the ConvertApi
  • Create an instance of the ConvertSettings
  • Set storage name and the input JSON file path
  • Assign “csv” to the format
  • Now, provide the output csv file path
  • Create ConvertDocumentRequest with ConvertSettings
  • Convert by calling the convertDocument() method with ConvertDocumentRequest

The following code example shows how to convert JSON to CSV in Nodejs using REST API :

Download the Converted File

The above code sample will save the converted CSV file on the cloud. Now you know how to convert JSON to CSV in node. Next, download csv file using the following code sample:

Free JSON to CSV Converter Online

How to convert JSON to CSV online free? Please try the following to convert large JSON to CSV online free, which is developed using the above API.


JSON and CSV files are widely used to store and transmit the data. In accordance with that, this article covered how to turn JSON into CSV in Node.js applications. Now you know:

  • how to convert json to csv using Node.js;
  • programmatically upload and download converted csv file;
  • free online json to csv converter;

Furthermore, you can learn more about GroupDocs.Conversion Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser.

Ask a question

You can ask your queries about how to convert JSON into CSV format, via our Free Support Forum

See Also