No upload, 100% local, no account

Article

CSV, JSON, XML, and YAML Data Conversion Guide

CSV, JSON, XML, and YAML are the four formats developers encounter most often in data pipelines, config files, and APIs. Converting between them is straightforward when data models match, but surprisingly lossy when they do not. This guide covers what each format can represent, where information disappears during conversion, and the encoding pitfalls that cause silent corruption. Our data converter handles CSV, JSON, YAML, and flat XML entirely client-side in your browser with zero uploads, supports custom CSV delimiters, and can export tabular records as SQL INSERT statements.

The four formats and their data models

CSV organizes data as a flat grid of rows and columns. The first row typically names the columns; every subsequent row is one record. There is no nesting, no type information, and no standard for anything beyond plain text in cells. Every value is a string unless the consuming application imposes a type. JSON models data as a tree of objects (key-value maps) and arrays. Values can be strings, numbers, booleans, null, nested objects, or arrays of any depth. This lets a single JSON document represent a customer record with embedded address objects, line-item arrays, and typed numeric totals. XML models data as a tree of elements. Each element can carry named attributes and contain child elements or text content. There is no built-in numeric or boolean type; everything is text. Schemas such as XSD can enforce types at validation time, but the wire format is always character data. YAML uses indentation to express the same object-and-array model as JSON, with cleaner human-readable syntax. YAML is a superset of JSON: any valid JSON document is also valid YAML. It adds multi-line strings, comments, and anchor-alias references for repeated blocks. YAML is common in configuration files; JSON is common in API responses.

FeatureCSV (RFC 4180)JSON (RFC 8259)XML 1.0 (W3C)
ReferenceRFC 4180 / MIME text/csvRFC 8259 / ECMA-404W3C REC-xml-20081126
Data StructureFlat 2D Tabular GridHierarchical Key-Value / ArrayHierarchical Tree + Attributes
Type SystemUntyped (String / Text only)Typed (Number, String, Bool, Null)Textual / XSD Schema Typed
Line EndingsCRLF (\r\n) standardLF (\n) or CRLF (\r\n)Normalized to LF (\n)
Diagram showing the four data models side by side: CSV as a flat grid, JSON as a nested object tree with typed values, XML as an element tree with attributes, and YAML as an indented block structure
Data models across CSV, JSON, XML and YAML

Lossy conversions: flattening and the XML ambiguity

The most common lossy conversion is flattening nested JSON or XML into CSV. A JSON object with a nested address field cannot map cleanly to a CSV row. The typical workaround is dot-notation column names: customer.address.city becomes its own column. This works for one level of nesting, but breaks completely when an array appears. A customer with three phone numbers requires either three separate columns (hard-coding the maximum count), splitting into a second CSV file, or encoding the array as a delimited string inside a single cell. None of these options round-trips back to the original JSON without extra metadata. XML introduces a separate ambiguity: the attribute versus child element choice. The value Paris could be stored as an attribute (<city name="Paris">) or as a child element (<city><name>Paris</name></city>). When a converter reads XML and produces JSON, it must decide how to map attributes. Common conventions include prefixing attribute keys with @ or placing them under an "_attributes" key. The choice is not standardized, which means two converters reading the same XML can produce structurally different JSON. If you plan to round-trip data through XML and JSON, fix a convention before starting.

FeatureClient-Side ParserCloud Converter API
UTF-8 BOM (\uFEFF)Preserved / Handled in-memoryStripped or Corrupted
64-bit Int (> 2^53 - 1)Preserved as string (no float loss)IEEE-754 binary64 float loss
File retention & verificationZero upload, verifiable in your browser Network tab (F12)Uploaded and stored temporarily on remote servers
Works offlineAfter the required downloads, while the browser retains themNo

CSV pitfalls: delimiters, quoting, and encoding

CSV has no single formal standard, only RFC 4180 as a widely cited reference. The most common delimiter is a comma, but semicolons (common in European locales where commas serve as decimal separators), tabs (TSV), and pipes all appear in practice. A file called .csv may use any of these without signaling which. When a field value contains the delimiter itself, RFC 4180 requires wrapping the field in double quotes: "San Francisco, CA". A double quote inside a quoted field must be escaped by doubling it: "He said ""hello""". A field containing a literal newline must also be quoted. Parsers that skip this step produce row-count errors that are hard to trace. Encoding is a separate trap. CSV files from Windows tools often carry a UTF-8 BOM (byte order mark: the three bytes EF BB BF at the start of the file). The BOM helps Excel identify the encoding, but many programming language parsers treat the BOM as part of the first column name, producing a column named "id" instead of "id". This breaks any downstream code that looks up columns by name. When reading a CSV file programmatically, strip the BOM before parsing, or use a library that handles it explicitly.

Illustration of CSV quoting rules: a field containing a comma wrapped in double quotes, a field containing a double quote with the escape doubled, and a UTF-8 BOM byte sequence at the start of a file highlighted in a hex view
Three common CSV parsing traps

Choosing a format: config, interchange, and spreadsheets

Format choice is usually determined by context, not preference. JSON is the default for REST APIs and browser-to-server interchange. It is compact, natively parsed in every programming language, and carries type information for numbers and booleans. Its weakness is the absence of comments, which makes it unsuitable for files that developers read and edit by hand. YAML is preferred for configuration files (Kubernetes manifests, CI pipeline definitions, Ansible playbooks) because it allows inline comments and is easier to read than JSON with many levels of indentation. Its main risk is that indentation errors are silent: a mis-indented key moves to a different scope without any parse error. XML remains standard in older enterprise systems, SOAP web services, document formats (DOCX, SVG, RSS), and contexts requiring schema validation or namespace disambiguation. It is verbose, but XPath and XSLT tooling is mature. CSV is the right choice when the data is genuinely flat and the consumer is a spreadsheet application or a data analyst. It is not suitable for configuration or API interchange because it has no type system and no nesting.

Doing it locally with data-converter

The data-converter tool on this site parses and converts between CSV, JSON, YAML, and flat XML entirely inside the browser, and can also generate SQL INSERT statements from tabular records. No data is transmitted to a server at any point. The conversion runs in your local JavaScript runtime, and the output is available for download or copy without anything leaving your device. This matters for data that is not yours to share: API responses containing personal information, configuration files with internal hostnames, or CSV exports from internal databases. Pasting that data into a web-based converter that runs on a server means the content is sent over the network and processed on hardware you do not control. With data-converter, the browser tab is the processing environment. The tool applies RFC 4180 quoting with selectable delimiters (comma, semicolon, tab, or pipe) when reading or writing CSV, targets flat record lists for XML parsing, and expects a flat array of objects for JSON, YAML, or XML going to CSV or SQL: nested objects or arrays under a key serialize as JSON strings rather than automatic dot-notation columns, so flatten those fields beforehand if you need separate columns.

Tools in this article

Frequently asked questions

Can I round-trip JSON through CSV and get the original back?

Only if the JSON is a flat array of objects with no nested fields and no arrays as values. The moment you have a nested object or an array value, the CSV representation requires a structural decision (dot-notation columns, multiple rows, or encoded strings) that cannot be automatically reversed. If your data has nesting, JSON, XML, or YAML will round-trip cleanly; CSV will not.

Why does my CSV look wrong in Excel after exporting from a European application?

European locales often use semicolons as the CSV delimiter because commas are reserved for decimal notation. Excel on a European locale expects semicolons. If the file uses commas, Excel treats the entire row as a single column. The fix is either to change the delimiter in the export settings, or to use Excel's Data Import wizard, which lets you specify the delimiter manually. The UTF-8 BOM issue is separate: without a BOM, Excel may also misread accented characters as garbled text.

What is the difference between YAML and JSON in practice?

Both represent the same underlying data model: objects, arrays, strings, numbers, booleans, and null. YAML adds comments (lines starting with #), multi-line string literals, and anchor references for repeated blocks. JSON is strictly a subset of valid YAML, but JSON parsers do not read YAML. The practical rule: use JSON for API payloads and data storage; use YAML for configuration files that humans edit and that benefit from inline comments.

Sources