CSV vs JSON: Which Format Should You Use for Your Data?
How CSV and JSON differ, when each is the better choice, and how to convert between them without losing information.
CSV in a sentence
CSV stores data as rows of values separated by commas, with one header row. It is flat, small and opens directly in spreadsheet programs, so it is excellent for tables.
JSON in a sentence
JSON stores data as objects and arrays, which can be nested. It is the standard format for web APIs and configuration because it can represent structure, such as a student with a list of subjects.
When to choose CSV
Use CSV when the data is a simple table, when people will open it in a spreadsheet, or when you need to share a large flat dataset compactly.
When to choose JSON
Use JSON when fields can be nested, when different records have different fields, or when the data feeds a web or app program.
Converting between them
Converting CSV to JSON is straightforward because each row becomes an object. Converting JSON to CSV requires flattening nested fields into columns, so check the column names afterwards, and remember that numbers may arrive as text, so check the types.
This guide is general information. Rules differ between institutions, so confirm requirements with your college or the portal you are using.