The same record in four formats
The easiest way to see the differences is to write one record four ways. The data: a customer called Asha Rao, with a zip code that starts with zero, an active flag, and two tags.
Notice that only JSON, YAML and XML can express the list of tags natively. CSV flattens everything to a grid of text cells, and that is both its strength and its limit.
- JSON: {"name": "Asha Rao", "zip": "02134", "active": true, "tags": ["new", "vip"]}
- CSV: a header line name,zip,active,tags followed by the row Asha Rao,02134,true,"new;vip". Tags had to be squeezed into one cell using a made-up separator.
- YAML: name: Asha Rao, then zip: "02134", then active: true, then tags as a list with the items new and vip on separate lines, using indentation to show structure.
- XML: a customer element with child elements name, zip, active and a tags element containing two tag elements.
When each format is the right choice
A rule of thumb: if a program talks to a program, use JSON. If a person in a spreadsheet has to open it, use CSV. If a person edits it by hand and needs comments, use YAML. If an industry standard or older system requires it, or the data is really a document with markup, use XML.
| Format | Best for | Strengths | Weaknesses |
|---|---|---|---|
| JSON | APIs, web apps, config read by programs | Simple, widely supported, handles nesting, has strings, numbers, booleans, null, arrays and objects | No comments, no dates, strict syntax (trailing commas break it) |
| CSV | Spreadsheets, bulk tabular data, imports and exports | Compact, opens in any spreadsheet, easy to stream | Flat only, no types, quoting rules vary, encoding surprises |
| YAML | Hand-edited configuration, CI files, Kubernetes manifests | Readable, supports comments, minimal punctuation | Indentation errors, implicit typing surprises, several ways to write the same thing |
| XML | Documents, enterprise and legacy integrations, markup with attributes | Attributes, namespaces, schemas, mixed text and markup | Verbose, more work to parse and read |
Pick the format by who or what reads it, not by habit.
Pitfall 1: nested data does not fit in a table
CSV is a grid; JSON is a tree. Converting a tree to a grid needs decisions. An order with three line items could become three rows that repeat the order number, one row with the items joined into a single cell, or columns like item1, item2, item3. Each choice loses something or breaks round-tripping. The JSON to CSV tool on this site flattens nested objects into columns using dotted names such as address.city, which works for objects with a fixed shape but not well for arrays of different lengths. Review the output before using it, and keep the original JSON.
Going from CSV to JSON is easier, but each row becomes a flat object. If you need nesting, you must rebuild it from column names.
Pitfall 2: types disappear
JSON knows that 42 is a number and "42" is a string. CSV knows neither; everything is text, and the program or spreadsheet that reads it guesses. A column of 1.5 and 2 may be read as numbers; a column containing true may become a boolean in one tool and text in another. Dates are worse, because JSON has no date type either and CSV has no format rules: 03/04/2026 means different days in different countries. YAML has a different trap, called implicit typing. Depending on the parser, a bare value like no, on or 1e3 may become a boolean or number, and a version such as 1.10 may be read as the number 1.1. Quote values whose type matters.
Pitfall 3: leading zeros and long numbers
Zip codes, phone numbers, account numbers and product codes that begin with zero are identifiers, not numbers. In the record above the zip is 02134. Open a CSV in a spreadsheet and it may display 2134, because the spreadsheet decides the column is numeric and discards the zero. Saved again, the damage is permanent. Long numbers suffer too: a 16-digit card number or an ID may be shown in scientific notation, and digits beyond about 15 significant ones can be rounded, because spreadsheets store numbers as double-precision floating point. In JSON, the same applies to JavaScript parsers: integers larger than 9,007,199,254,740,991 lose precision. The safe approach is to store identifiers as strings, set the column to text on import, and quote them.
Pitfall 4: encoding, BOMs, delimiters and quotes
CSV files have no declared encoding. UTF-8 is the common choice for exchange, but some spreadsheet programs assume a legacy encoding unless the file starts with a byte order mark (BOM), three bytes at the start of the file. With the BOM, accented letters and non-Latin scripts display correctly in such programs; without it, you may see garbage like "é" for "é". The opposite problem occurs in programs that do not expect a BOM: the first header becomes an invisible character plus the name, so a lookup for "name" fails. If a column mysteriously cannot be found, a BOM is a suspect.
Delimiters are another trap. Many European locales use a semicolon as the list separator because the comma is the decimal mark, so a "CSV" from one machine may not parse on another. The CSV Delimiter Converter on this site changes between comma, semicolon, tab and pipe. Quoting also matters: a field containing a comma, a quote or a line break must be wrapped in double quotes, and an inner quote doubled. Hand-built CSV that skips this breaks on a name like O'Neil, "Jr." or an address with a line break.
JSON and XML are stricter. JSON requires double quotes and forbids trailing commas, comments and single-quoted strings. XML requires escaping of the characters &, < and >, and a single root element.
Treat identifiers as text, save as UTF-8, and check the delimiter before importing a CSV.
Converting safely: a checklist
This site includes JSON to CSV, CSV to JSON, JSON to YAML, YAML to JSON, JSON to XML and XML to JSON converters, all running in the browser so private data is not uploaded. They are good for configuration, test data and small datasets. For very large files, or data with complex rules, a script or database import is a better fit.
- Keep the original file. Conversions are not always reversible.
- Decide how you will represent lists and nesting, and write it down.
- Convert a small sample first, and look at the first and last rows, any row with a comma, a quote or an empty value, and a row with a leading zero.
- Compare record counts before and after. Use the JSON Diff tool to compare two JSON files.
- Validate the result: the JSON Formatter reports syntax errors, and the XML Formatter does the same for XML.
- Check that identifiers are still text and dates are in a format the next system expects.
Frequently asked questions
Is JSON better than XML?
Not universally. JSON is simpler and dominant for web APIs. XML supports attributes, namespaces, schemas and mixed content, so it remains common in enterprise and document-oriented systems.
Why did my zip code lose its leading zero in a spreadsheet?
The spreadsheet guessed the column was a number and dropped the zero. Import the column as text, or store identifiers in quotes, and keep them as strings in JSON.
Can I convert nested JSON to CSV without losing data?
Only if you choose a flattening scheme, such as dotted column names, and the arrays are consistent. Variable-length arrays force trade-offs, so keep the original JSON.
What is a BOM in a CSV file?
A byte order mark is a few bytes at the start of a UTF-8 file. Some spreadsheet programs need it to detect UTF-8; some other programs treat it as part of the first header. If a header looks wrong, check for it.
Try these tools
JSON to CSV
Convert a JSON array to CSV in your browser. Flattens nested objects, picks delimiters and downloads a ready .csv for Excel or Sheets.
Open toolCSV to JSON
Convert CSV to JSON in your browser. Auto-detects delimiter, uses the header row as keys, and can convert numbers and booleans.
Open toolJSON to YAML Converter
Convert JSON to clean, readable YAML instantly. Choose indent size, copy or download the result. Free and runs in your browser.
Open toolYAML to JSON Converter
Convert YAML to JSON instantly with clear error messages. Pretty-printed output, file upload and download. Free and private.
Open toolJSON to XML Converter
Convert JSON to well-formed XML online with a custom root element, proper escaping and pretty printing. Runs in your browser; your data is never uploaded.
Open toolXML to JSON Converter
Convert XML to JSON online using your browser’s own XML parser. Attributes become @keys, text becomes #text and repeated tags become arrays. Private and free.
Open toolJSON Formatter
Format, validate, beautify and minify JSON instantly. Shows the exact line and column of any error. Free and runs in your browser.
Open toolCSV Delimiter Converter
Convert between comma, semicolon, tab and pipe separated files. Auto-detects the delimiter, handles quoted fields, shows a preview. Free and private.
Open tool