
JSON files are widely used to store and transmit structured data between applications. On the other hand, CSV is also utilized to store the data, such as datasets, as comma-separated values. In this article, you will learn how to export data from JSON files to CSV programmatically. More specifically, the article will cover how to convert JSON to CSV in Java.
- Java JSON to CSV Converter - Free Download
- Steps to Convert JSON Data to CSV
- Convert JSON Data to CSV in Java
- Convert JSON to CSV Online
Java JSON to CSV Converter
Aspose.Cells for Java is a powerful API to create and manipulate spreadsheet documents from within Java applications. We will use this API to convert the JSON data to CSV format. You can either download Aspose.Cells for Java or install it using the following Maven configurations.
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>23.4</version>
</dependency>
Convert JSON to CSV in Java
Aspose.Cells provides a high-speed and high-fidelity conversion of JSON files to CSV format in Java. The following are the steps to save the JSON data in CSV format using the API.
- Create a new Excel workbook and select the desired worksheet.
- Import Data from JSON to Excel worksheet.
- Save Excel workbook in CSV format.
Now, let’s write the Java code to convert a JSON file to CSV format.
Java Code to Convert JSON to CSV
The following are the steps to convert JSON data to CSV in Java.
- Create a new Workbook object.
- Get a reference of the first worksheet using Workbook.getWorksheets().get(0) method.
- Create an object of JsonLayoutOptions class to set additional options.
- Import data from JSON to CSV using JsonUtility.importData() method.
- Save the CSV file using Workbook.save(string, SaveFormat.CSV) method.
The following code sample shows how to convert JSON data to CSV format.
JSON Data
The following is the JSON data that we used in the above code sample.
[{"nodeId":1,"reputation":1134},{"nodeId":2,"reputation":547},{"nodeId":3,"reputation":1703},{"nodeId":4,"reputation":-199},{"nodeId":5,"reputation":-306},{"nodeId":6,"reputation":-49},{"nodeId":7,"reputation":1527},{"nodeId":8,"reputation":1223}]'
Converted CSV
The following is the screenshot of the data converted to CSV format.

Convert JSON to CSV Online
Use our free online JSON to CSV converter and transform your JSON data into comma separated values.

Free Export JSON to CSV
You can get a free temporary license and export JSON data to CSV format without evaluation limitations.
You can also explore more about Aspose.Cells for Java using the documentation. In addition, you can ask your questions via our forum.
Conclusion
JSON and CSV files are immensely used to keep and exchange data. Often, you need to export data from JSON files to CSV programmatically. For such cases, this article covered how to convert JSON files to CSV in Java. You can simply install Aspose.Cells and easily integrate the provided code into your applications. Apart from that, you have also come to know how to convert JSON data to CSV online from within your web browser.