Guide · JSON & Data

JSON vs XML vs YAML vs CSV: When to Use Each

Updated 2026-08-07 · 4 min read

Four formats show up in the same week: a REST body, a SOAP leftover, a CI config, and a spreadsheet export. They are not interchangeable styles. They are different jobs. Pick the one that matches the consumer, then convert locally when the consumer changes.

DevOkk’s converters - XML to JSON, CSV to JSON, YAML to JSON - run in the browser. No account. If the document holds tokens or PII, do not paste it into a random site. Browser-local is the safer default.

Four formats, four jobs

JSON is typed values for programs: objects, arrays, strings, numbers, booleans, null. No comments. No attributes. One document. This is the default for HTTP APIs and test fixtures.

XML is a document tree with elements, attributes, namespaces, and mixed text. This is the default for SOAP, many feeds, and older vendor files.

YAML is indentation-based config for humans: comments, anchors, multiline blocks, implicit types. This is the default for CI and a lot of ops files.

CSV is a table: rows, a header, no nesting unless you fake it with dotted column names. This is the default for exports people open in a spreadsheet.

If you force all four through one mental model (“it is all just data”), you will misuse arrays, lose attributes, drop comments, and guess types. The rest of this page is when not to do that.

JSON for APIs and fixtures

Use JSON when the next reader is JSON.parse, a mobile client, or a mock server. Keep instants as ISO-8601 strings or Unix numbers. Keep money as strings if you do not trust floats. Do not put comments in production JSON; put them in the ticket.

Pretty-print when a human is looking. Minify when a machine is consuming. View when the document is deep. Graph when nesting is the question. Those tools assume you already have JSON: JSON Formatter, JSON Viewer, JSON Minifier, JSON to Graph Visualizer.

Do not use JSON as a substitute for a 200-column warehouse extract. You can, but CSV streams better and people will reopen it in Excel anyway.

XML for documents and legacy contracts

Use XML when the contract already is XML. Converting a SOAP envelope to JSON to send it back as SOAP is extra work. Convert when your side needs objects: a frontend, a fixture, a graph of EnvelopeBodyFault.

Attributes and repeating elements do not have one true JSON shape. Read How to Convert XML to JSON before you write items.map against a feed that sometimes has one <item>.

Namespaces are real. If two id attributes live in different namespaces, flattening them is a bug. For a one-off paste, you may still flatten. For an integration, keep enough of the name to disambiguate.

XML is a poor config format for new services. It is a fine document format. Do not restart a holy war; look at the file you were sent.

YAML for configs humans edit

Use YAML when people will change replicas and image in a pull request. Keep it as the source of truth. Emit JSON when a tool is allergic to YAML.

Implicit types (NO → false) are the recurring injury. Quote strings that look like booleans or numbers. Anchors expand on conversion; comments die. Details: How to Convert YAML to JSON.

Do not use YAML for a 50,000-row table. Indentation will not save you. Do not use YAML for an API response unless you enjoy content-negotiation arguments.

Secrets live in YAML more often than in CSV. Treat a values file like a token. Convert a redacted copy if you only need structure.

CSV for tables and exports

Use CSV when the data is a grid and the next person has Excel, or the next system has COPY. Headers are the schema. Types are a rumor.

Convert to JSON when a script wants [{sku, qty}]. Read How to Convert CSV to JSON for delimiters, quoted commas, and empty cells.

Do not use CSV for a nested checkout payload. You will invent payment_1_method columns and cry. Do not use CSV for a Kubernetes manifest.

A graph of a flat CSV-turned-JSON is usually a waste. A formatter and a viewer are enough.

Convert locally when the consumer changes

A realistic week:

  1. SOAP fault arrives as XML → XML to JSON → formatter → paste faultstring into the ticket.
  2. Product export arrives as CSV → CSV to JSON → minify a redacted fixture.
  3. CI snippet is YAML → YAML to JSON → check that NO stayed a string.

Keep the original file. Conversion is lossy in different ways (comments, attributes, types). If you need to go back, the original is the only honest source.

Do not chain three random websites for those three jobs. DevOkk keeps the paste in the tab. Policy can still say the paste should never have existed.

After you have JSON, the JSON tools hub is the rest of the session. This comparison page is the decision, not the formatter.

Pick a converter and stop

If the file in front of you is XML, open XML to JSON. If it is a table, open CSV to JSON. If it is a config, open YAML to JSON. If it is already JSON, skip converters and start with JSON Formatter. Use dummy or redacted samples when the real document should not be in a browser.

Frequently asked questions

Which format should an HTTP API use?

JSON, unless you already have an XML contract (SOAP, a feed, a standards body). Do not invent a new XML API for a browser client in 2026 without a reason.

Which format should a config file use?

YAML if humans edit it and you accept implicit-type footguns. JSON if machines generate it and you want comments to stay out. Do not use CSV for nested settings.

Which format should a table export use?

CSV for spreadsheets and warehouse loads. JSON arrays of objects for fixtures and mock APIs. Convert in the browser when you need the other shape.

Do the DevOkk converters upload my file?

XML to JSON, CSV to JSON, and YAML to JSON are designed to process pasted text in the browser. Still avoid pasting production tokens or PII into random websites.

Can I convert JSON back to YAML or XML here?

This article’s tools go toward JSON, which is what the rest of the DevOkk JSON toolkit expects. Going the other way is a different job; keep the original file if you still need it.

Is YAML a superset of JSON?

YAML 1.2 can parse many JSON documents. Real-world YAML is not 'JSON with comments.' Implicit types, anchors, and multiple documents do not exist in JSON. Convert and inspect types.

More reading that links back to the same tools and workflows.