Codepackr / converters / JSON to CSV / CSV to JSON

JSON to CSV / CSV to JSON

Convert JSON arrays to tabular CSV or transform CSV rows into JSON objects.

Client-Side Execution & Privacy Guarantee

This utility executes 100% locally in your web browser. Your inputs, tokens, queries, and data payloads are never transmitted to any external server or backend.

Many systems exchange data as JSON arrays of records while spreadsheets and legacy importers still expect CSV. Converting between the two formats is straightforward for flat data but quickly becomes error-prone once nested objects, missing fields, or quoted commas appear. This tool performs both directions locally so you can verify the mapping before the data leaves your machine.

The converter assumes the JSON input is an array of objects that share a common set of keys. Those keys become the CSV header row. On the reverse path each CSV row becomes a JSON object whose properties match the header. Nested values are flattened or stringified so the result remains a pure two-dimensional table.

Header derivation and column order

When converting from JSON the first object supplies the initial column list. Subsequent objects may add extra keys that appear as additional columns; missing keys become empty cells. You can lock the column order by supplying an explicit header if the default discovery order is inconvenient.

CSV-to-JSON uses the first row as property names. Duplicate headers are disambiguated by appending a numeric suffix. Empty header cells are skipped so the resulting objects stay clean.

Quoting, escaping, and special characters

Fields that contain commas, quotes, or newlines are automatically wrapped in double quotes and internal quotes are doubled, following the most common CSV dialect. The reverse parser respects the same rules so round-trips preserve the original text.

Line endings are normalized to the platform convention on output. Unicode characters pass through unchanged; the tool does not apply any encoding other than the UTF-8 already used by the browser.

Nested data and type handling

Nested objects and arrays are converted to JSON strings inside the CSV cell so no information is silently dropped. When reading CSV back, those cells remain strings; a second pass through a JSON parser can restore structure if needed.

Boolean and numeric values are written without quotes. On the way back, pure numeric strings become numbers and the tokens true/false become booleans, matching typical spreadsheet export behavior.

When to use this tool

  • Exporting an API response array for opening in a spreadsheet
  • Importing a CSV export into a JSON-based configuration or database seed
  • Quickly checking that every record contains the expected fields
  • Generating a header row from a sample object before writing a larger file
  • Cleaning quoted fields that a previous export mishandled

How to use the JSON to CSV / CSV to JSON

  1. Paste a JSON array of objects or a CSV block into the input area.
  2. Choose the conversion direction.
  3. If converting to CSV, optionally edit or lock the detected header.
  4. Click Convert and examine the table or the resulting JSON.
  5. Correct any parse errors reported at the top of the output.
  6. Copy the result or download it as .csv or .json.
  7. Clear the input if the data contains personal information.

Worked examples

Array of objects to CSV

Input
[{"id":1,"name":"Ada"},{"id":2,"name":"Grace"}]
Output
id,name
1,Ada
2,Grace

Keys from the objects become the header; each object becomes one row.

CSV with quoted field to JSON

Input
name,note
Ada,"Hello, world"
Output
[{"name":"Ada","note":"Hello, world"}]

The comma inside the quoted field is preserved as part of the value.

Common mistakes and tips

  • Ensure every object in a JSON array uses consistent key names; extra keys simply add columns.
  • A trailing comma or missing closing bracket is the most common JSON parse failure.
  • CSV files exported from Excel may contain a UTF-8 BOM; the parser ignores it.
  • Very wide tables (hundreds of columns) remain usable but horizontal scrolling becomes necessary.
  • If a field must stay a string even when it looks numeric, wrap it in quotes in the CSV.

Frequently asked questions

Does the tool support semicolon or tab delimiters?

The primary mode uses commas. A delimiter selector lets you switch to semicolon or tab for regional exports.

What happens to null values?

Null becomes an empty cell in CSV and is restored as null when the cell is empty on the way back.

Can I convert a single object instead of an array?

Wrap the object in an array first. A bare object is rejected so the header logic stays unambiguous.

Are date strings parsed into Date objects?

No. All values remain strings or numbers; date interpretation is left to the consuming application.

How are multi-line fields handled?

Newlines inside quoted CSV fields are preserved. The JSON output contains the literal newline character.