Skip to main content

← Back to blog

How to Convert JSON to CSV and Excel (and Back)

Code speaks JSON, spreadsheets speak CSV and Excel, and sooner or later you need to move data from one to the other. The three formats hold the same rows and columns — the trick is converting without mangling them. Here is how.

What each format is for

  • JSON — structured data for code and APIs. Tabular data is usually an array of objects: [{"name":"Ann","age":30}, …], where each object is a row.
  • CSV — a plain-text table (comma-separated). Universal, tiny, and imported by almost everything.
  • Excel (.xlsx) — a binary spreadsheet with formatting, multiple sheets and formulas. What most colleagues actually open.

JSON to CSV

The cleanest JSON to convert is an array of flat objects. Each object becomes a row; the keys become the header row. Nested objects don’t map neatly to a flat table, so flatten them first (or expect only the top level to convert).

JSON to Excel

Same idea, but the output is an .xlsx file that opens directly in Excel, Numbers or Google Sheets — no import step. Ideal when you need to hand data to someone who lives in spreadsheets.

CSV or Excel back to JSON

Going the other way turns a spreadsheet into an array of objects your code can parse — great for seeding a database, feeding an API, or loading test data.

Do it in your browser — nothing uploaded

Data files often contain sensitive information, so a tool that uploads them is a risk. These run entirely on your device:

Tips for clean results

  • Make your JSON an array of objects with consistent keys — that maps 1:1 to columns.
  • Validate the JSON first (a stray comma breaks everything).
  • For Excel, remember the output is a real .xlsx — no need to rename a CSV.

Master the array-of-objects shape and moving between JSON, CSV and Excel becomes a two-click, no-upload task.