Skip to content
HandyKit

JSON Converter: CSV, YAML and XML

Turn JSON into CSV for spreadsheets, YAML for configuration or XML for older systems. Nested data is handled sensibly and big numbers are never rounded.

Runs in your browser. Your input is never uploaded or stored.

Each object becomes a row. Nested objects become columns like address.city; arrays are kept as JSON text.

This is example JSON. Paste yours to replace it.

Which format to choose

Choose the format by what will read the output.

  • CSV suits spreadsheets, database imports and anything that expects flat rows and columns. It works best for arrays of similar objects.
  • YAML suits configuration files and anything people will read and edit by hand. It keeps nesting and arrays intact.
  • XML suits older systems, feeds and tools that expect a root element and tags. This converter writes elements only, never attributes.

How to use the tool

  1. Open the JSON to CSV, JSON to YAML or JSON to XML tab.
  2. Paste your JSON into the input. The page opens with an example array, and pasting replaces it.
  3. Read the output, which updates as you type. If the JSON has a syntax error, the tool shows the line and column.
  4. Set any option you need: the separator for CSV (comma, semicolon or tab), or the root element name for XML.
  5. Select Copy or Download.

Everything runs in your browser. Nothing is uploaded.

How nested data is handled in CSV

An array of objects becomes one row per object. The header is the union of all keys, in the order each first appears. Nested objects are flattened into dotted columns such as address.city. Arrays inside objects are written as JSON text in a single cell, and null becomes an empty cell.

[
  { "name": "Ada", "address": { "city": "London" }, "tags": ["a", "b"] },
  { "name": "Grace", "address": { "city": "New York" }, "tags": null }
]
name,address.city,tags
Ada,London,"[""a"",""b""]"
Grace,New York,

A top-level array of arrays is written as rows directly, and a single object becomes one row. Quoting follows RFC 4180: a cell containing the separator, a quote or a line break is wrapped in double quotes, and inner quotes are doubled. Lines end with CRLF.

If Excel in your locale uses a decimal comma, choose the semicolon separator.

YAML quoting and the Norway problem

A string stays unquoted only when YAML would read it back as the same string. Otherwise it is double-quoted. This matters because YAML 1.1 parsers read yes, no, on and off as booleans. The best-known case is the country code NO, which such parsers turn into false. That is the "Norway problem".

{ "answer": "yes", "switch": "on", "nothing": "null", "version": "1.0", "note": "a: b", "empty": "" }
answer: "yes"
switch: "on"
nothing: "null"
version: "1.0"
note: "a: b"
empty: ""

Empty objects and arrays are written as {} and []. The output is tested to read back as the same data in a YAML parser.

How XML elements are named

Each key becomes an element. Array items repeat the element, so "roles": ["admin", "editor"] gives two <roles> elements. A top-level array is wrapped in a root element, named root by default, with <item> children. A null value becomes an empty element such as <x/>.

Keys that are not valid XML names are adjusted:

  • Spaces become _.
  • A leading digit gets a _ prefix.
  • A name starting with xml gets a _ prefix.
<first_name>Ada</first_name>
<roles>admin</roles>
<roles>editor</roles>
<_1st/>

Text is escaped, so &, <, > and " become &amp;, &lt;, &gt; and &quot;.

Large numbers

Numbers are copied exactly as written. An integer such as 12345678901234567890 is not rounded, although JSON.parse would round it.

Converting in code

For CSV from an array of objects with jq, the header comes from the first object's keys, so this suits flat objects that share the same keys:

jq -r '(.[0] | keys_unsorted) as $k | $k, (.[] | [.[$k[]]]) | @csv' data.json

For YAML with Python (this needs PyYAML):

python -c 'import sys, json, yaml; print(yaml.safe_dump(json.load(sys.stdin), sort_keys=False))' < data.json

Or with mikefarah's yq v4:

yq -P data.json

Frequently asked questions

Why are some YAML strings in quotes?

The converter only leaves a string unquoted when YAML would read it back as the same string. Values such as yes, on, null, 1.0, a: b and the empty string would otherwise be read as booleans, null, numbers, mappings or nothing at all, so they are written in double quotes. This avoids the Norway problem, where YAML 1.1 parsers turn the country code NO into false.

What happens to nested arrays and objects in CSV?

Nested objects are flattened into dotted columns, for example address.city. An array inside an object is written as JSON text in a single cell, and the cell is quoted according to RFC 4180. A null value becomes an empty cell.

Can I convert CSV or YAML back to JSON?

No. This page converts from JSON only, to CSV, YAML or XML. It does not read those formats as input.

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser, so the JSON you paste stays on your device.

Why does Excel show everything in one column?

Excel in some locales expects a semicolon rather than a comma as the separator, so it treats each comma-separated line as a single value. Choose the semicolon separator and convert again, or import the file with Data > From Text/CSV and select the separator there.

Are very large numbers rounded?

No. Numbers are copied exactly as they are written in your JSON, so an integer such as 12345678901234567890 appears unchanged in the output. JSON.parse would round it, but the converter does not rely on that.

Guides

  • · 2 min read

    How to Convert JSON to CSV, YAML or XML

    Turn JSON into a CSV spreadsheet, YAML or XML, with worked examples showing how nested objects, arrays and null values are handled, and how to open it in Excel.