JSON ↔ CSV Converter

Convert arrays of JSON objects and correctly quoted CSV data locally.

  • Free
  • No signup
  • Runs in your browser
Direction

Nested JSON values are serialized as JSON strings. CSV values remain strings; headers must be non-empty and unique.

How it works

How to use

Choose a direction, enter JSON or CSV, and select Convert.

Method

A local parser handles flat JSON objects and correctly quoted CSV fields.

Example

Convert a JSON array of records into a header row and CSV rows.

JSON records have to become rows before they can become CSV

JSON can represent objects, arrays, numbers, booleans, nulls and nested structures. CSV has a flatter model: a header row names columns and each following row supplies cells for those columns. Conversion therefore starts by deciding which JSON values form the table.

SnakTool's JSON-to-CSV direction expects the top level to be an array of objects. A single object, an array of primitive values, or an array of arrays is not treated as a CSV table by this converter.

Supported JSON table shape
[
  { "name": "Sara", "age": 24 },
  { "name": "Adam", "city": "Rabat" }
]

Columns come from every key the records introduce

The first JSON object does not have to contain every future column. SnakTool walks the records and builds a union of their keys in encounter order, so a property first seen in a later object still becomes a CSV column.

When a record does not contain one of those properties, its position in that row is left as an empty cell. This lets uneven API-style records share one table without silently dropping fields that appear after the first object.

Different keys become one header
JSON:
[{"id":1,"name":"Sara"},{"id":2,"email":"a@example.com"}]

CSV:
id,name,email
1,Sara,
2,,a@example.com

Nested JSON stays inside a cell instead of becoming more columns

This converter does not flatten nested objects into headings such as user.name or user.city. When a JSON value is itself an object or array, SnakTool serializes that value with JSON.stringify and places the resulting JSON text in one CSV cell.

That preserves a textual representation of the nested value during export, but it does not turn the CSV into a relational model. If the CSV is later imported again, that cell comes back as a string rather than being parsed automatically into the original nested object or array.

Nested value remains one field
JSON value: {"tags":["dev","api"]}
CSV cell:   ["dev","api"]
Imported:   "[\"dev\",\"api\"]"

CSV quoting protects column boundaries, not the meaning of a value

A comma inside a field cannot be written as an unquoted comma because it would look like a column separator. SnakTool surrounds fields containing commas, double quotes or line breaks with double quotes and doubles any quote characters inside the field.

Quoted fields can therefore contain punctuation and newlines without being split into extra columns. These are CSV syntax rules only: quoting a value does not change its semantic type and does not make arbitrary spreadsheet content safe.

Field valueCSV representation
Rabat, Morocco"Rabat, Morocco"
She said "hello""She said ""hello"""
A value with a line breakOne quoted field containing the line break

On import, the first row becomes the object contract

CSV-to-JSON assigns a different role to the first row: every cell there becomes a property name for the objects produced from later rows. SnakTool requires those headers to be nonempty and unique.

A header such as name,,city is rejected because one property name is empty. name,name,city is also rejected because two columns would compete for the same JSON key. This converter does not provide a no-header mode that invents property names for you.

Header row maps cells to keys
name,age,city
Sara,24,Rabat

↓

{ "name": "Sara", "age": "24", "city": "Rabat" }

A short row can be completed; a wide row has nowhere to go

If a data row has fewer cells than the header, SnakTool fills the missing trailing properties with empty strings. The header still defines the complete object shape, so a short row can be represented without inventing new keys.

The opposite case is rejected. If a row contains more cells than there are headers, the extra values have no property names to map to. Blank single-cell rows are filtered rather than emitted as ordinary data objects.

Uneven rows
Header: name,age,city
Short:  Sara,24       → city = ""
Wide:   Sara,24,Rabat,extra → rejected

CSV cells return as strings, even when they look typed

CSV does not carry JSON type annotations in each cell, and SnakTool deliberately does not infer them on import. The text 42 becomes "42", true becomes "true", and 007 remains "007" rather than being converted to the number 7.

Keeping cells as strings avoids guessing whether a numeric-looking value is really a quantity, an identifier, a postal code or something else. If the destination API requires numbers, booleans or nulls, apply that schema after conversion.

CSV cellJSON value produced
42"42"
true"true"
007"007"
empty cell""

A round trip exposes what the flat table cannot remember

JSON-to-CSV-to-JSON is not a lossless serialization cycle. On export, null, undefined and missing properties can become empty cells, while nested objects and arrays become JSON text. On import, every cell becomes a string.

The important question is therefore not only whether the CSV looks correct, but whether the distinctions needed by the receiving system survived the flat representation. If type fidelity or nested structure is essential, keep the original JSON or restore those semantics from a known schema.

Original JSON valueAfter CSV round trip
7"7"
true"true"
null""
Missing property""
["dev", "api"]"[\"dev\",\"api\"]"

Comma is the delimiter here, not a value to auto-detect

SnakTool's parser uses commas as field delimiters and supports quoted fields, doubled quotes, and CR, LF or CRLF line endings. It does not auto-detect semicolon, tab or pipe delimiters.

A semicolon-separated file can therefore look like one large field per row instead of several columns. If the source is TSV or another delimited format, convert its delimiter intentionally before treating it as CSV here.

Spreadsheet formulas are a separate boundary from CSV escaping

Correct CSV escaping prevents commas, quotes and line breaks inside a value from corrupting the row structure. It does not neutralize a value that a spreadsheet application may interpret as a formula when the exported file is opened.

SnakTool does not add spreadsheet-specific prefixes or sanitization for values beginning with characters such as =, +, - or @. If untrusted data will be opened in spreadsheet software, handle formula-injection risk according to that spreadsheet workflow rather than treating CSV quoting as a security control.

Frequently asked questions about JSON ↔ CSV Converter

Can a field include a comma, quote, or line break?

Yes. SnakTool quotes fields containing commas, double quotes or CR/LF characters and doubles embedded quote characters so the value remains one CSV field.

Is JSON to CSV to JSON a lossless round trip?

No. CSV import produces string values, null or missing values can collapse into empty cells, and nested JSON exported into a cell returns as text rather than being reconstructed automatically.

What JSON format does the CSV converter accept?

JSON-to-CSV requires a top-level array whose items are non-null JSON objects. A single object, primitive array or array of arrays is not accepted as the table shape.

What happens when JSON objects have different keys?

All encountered keys can become columns. A record that lacks one of those properties receives an empty cell at that column.

Does SnakTool flatten nested JSON objects?

No. Nested objects and arrays are serialized as JSON text inside a single CSV cell rather than expanded into dot-notation or multiple columns.

Can a CSV field contain a newline?

Yes. The parser supports line breaks inside properly quoted fields, and JSON-to-CSV quotes values containing CR or LF characters.

Can CSV contain duplicate header names?

Not here. Duplicate header names are rejected instead of allowing later columns to overwrite the same JSON property.

Are blank CSV rows ignored?

The parser filters blank single-cell rows from the data rows rather than converting them into ordinary JSON objects.

Why does 007 stay a string?

CSV-to-JSON preserves cells as text instead of guessing numeric types. This retains the leading zeros in identifiers such as 007.

Does SnakTool support TSV?

Not as a separate tab-delimited mode. The current CSV parser expects comma delimiters.

Does CSV quoting prevent spreadsheet formula injection?

No. CSV quoting protects field boundaries and escaping syntax. SnakTool does not perform spreadsheet-specific formula sanitization, so untrusted exported values require separate handling before spreadsheet use.

What is the maximum input size for JSON and CSV conversion?

The developer-text limit is 1,048,576 UTF-16 code units. JSON parsing and CSV parsing reject input above that limit.

Browse all Developer Tools