JSON to CSV in C#

JSON (JavaScript Object Notation) and CSV (Comma-Separated Values) are popular formats for data storage and exchange. Often you need to transform JSON into CSV. This article shows how to convert JSON to CSV in C#.

C# Library to Convert JSON to CSV

Aspose.Cells for .NET is a feature‑rich library for working with Excel files in C#. It also supports other formats such as CSV and JSON. You can either download the API or install it using NuGet.

PM> Install-Package Aspose.Cells

Steps to Convert JSON to CSV

Aspose.Cells for .NET makes converting JSON files to CSV simple. Follow these steps:

  • Create a new Excel file.
  • Read data from a JSON file.
  • Import the JSON data into the Excel file and save it as CSV.

Below is the C# code that performs the conversion.

Convert JSON Data to CSV in C#

To convert JSON data to CSV in C#:

The sample below demonstrates exporting JSON data to CSV.

JSON Data

The JSON used in the example:

[{"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 resulting CSV file:

JSON to CSV

Convert JSON to CSV Online

Use our free online JSON to CSV converter to transform JSON data into comma‑separated values.

Image

Free JSON Data to CSV Converter

Get a free temporary license and export JSON files to CSV without evaluation limits.

You can also explore Aspose.Cells for .NET via the documentation or ask questions on our forum.

Conclusion

Converting JSON to CSV in C# with Aspose.Cells for .NET is straightforward thanks to the library’s powerful features. Aspose.Cells simplifies handling Excel, JSON, CSV, and other formats, making it a valuable tool for .NET data manipulation. Follow the steps in this guide to convert JSON data to CSV in your applications.

See Also