Skip to content
Blog

How to Convert Between CSV, JSON, YAML, and XML

Developers constantly convert between data formats - JSON for APIs, YAML for configs, CSV for spreadsheets, XML for legacy systems. Doing it manually is tedious and error-prone. Here''s how to do it fast and right.

Share:Twitter/XLinkedIn

How to Convert Between CSV, JSON, YAML, and XML

If you've ever spent twenty minutes fighting a JSON-to-CSV converter that didn't handle nested objects, or manually renamed XML tags because your tool couldn't map them - you already know the pain. Data format conversion is one of those unglamorous tasks that eats up disproportionate amounts of developer time.

The good news: it doesn't have to. Let's walk through the most common conversions, when you'd need each, and how to do them instantly.

The Four Formats and When They're Used

JSON (JavaScript Object Notation)

The dominant format for web APIs and data interchange. Clean, readable, and natively understood by JavaScript. If you're building or consuming REST APIs, you're swimming in JSON.

{
  "users": [
    { "id": 1, "name": "Alice", "role": "admin" },
    { "id": 2, "name": "Bob", "role": "viewer" }
  ]
}

CSV (Comma-Separated Values)

The lingua franca of data export/import. Open any spreadsheet in Google Sheets or Excel and export it - you're getting CSV. Simple, universal, and terrible at representing nested or hierarchical data.

id,name,role
1,Alice,admin
2,Bob,viewer

YAML (YAML Ain't Markup Language)

The format of choice for configuration files. Kubernetes, Docker Compose, GitHub Actions workflows, Ansible playbooks - all YAML. It's more readable than JSON for humans and supports comments, which JSON doesn't.

database:
  host: localhost
  port: 5432
  credentials:
    username: admin
    password: secret

XML (Extensible Markup Language)

Once the universal standard for structured data, now somewhat legacy - but still widespread in enterprise systems, SOAP APIs, Microsoft Office documents (.docx is a ZIP of XML files), and RSS feeds.

<users>
  <user id="1">
    <name>Alice</name>
    <role>admin</role>
  </user>
</users>

Why Converting Between Them Is Tedious

Each format has different rules. JSON keys must be strings. YAML relies on indentation. CSV is flat - no nesting. XML has opening and closing tags. A naive conversion breaks down the moment your data has:

  • Nested objects (JSON/YAML → CSV: how do you flatten this?)
  • Arrays of objects (CSV → JSON: what becomes the array key?)
  • Special characters (quotes, commas in CSV values)
  • Type information (YAML distinguishes strings from numbers; CSV doesn't have types)

The result: half the converters on the web silently drop data, mangle Unicode, or produce invalid output. And if you're dealing with sensitive data, using an online converter means uploading your data to a server you don't control.

The Client-Side Solution

Toolblip handles all conversions entirely in your browser. No uploads. No server round-trips. Your data never leaves your device. This matters when you're working with:

  • Proprietary business data you can't expose to third-party servers
  • User information subject to privacy regulations
  • Credentials or tokens embedded in configuration files

Here's the full suite of converters available:

From To Tool
CSV JSON CSV to JSON
JSON CSV JSON to CSV
YAML JSON YAML to JSON
JSON YAML JSON to YAML
TOML JSON TOML to JSON
XML JSON XML to JSON

Common Conversion Scenarios

"I got an API response in JSON but need to import it into Excel"

Export your data as CSV. Use JSON to CSV - it flattens nested objects using dot notation (e.g., address.city) so nothing gets lost. Open the CSV in Excel or Google Sheets and you're done.

"I wrote a Kubernetes config in YAML but need it as JSON for a tool"

Use YAML to JSON - it preserves all the indentation-aware structure YAML gives you and outputs clean, valid JSON. Useful when a tool only accepts JSON but you prefer writing in YAML.

"I have a spreadsheet of user data I need to send as a JSON payload"

Export from Excel as CSV, then use CSV to JSON. If your CSV has headers, the converter uses them as keys automatically.

"I'm migrating from a legacy XML system to a modern JSON API"

XML to JSON handles the tag-to-key conversion. Element names become object keys, text content becomes values, and attributes get prefixed (e.g., id attribute → @id).

"My config file is in TOML but I need JSON for a Node.js project"

TOML to JSON converts your TOML configuration directly. TOML tables become objects, arrays become arrays - clean one-click conversion.

A Note on CSV Quirks

CSV has no official standard, which means real-world CSV files vary wildly:

  • Delimiter: Most use commas, but tabs (TSV), semicolons, and pipes (|) are common in Europe
  • Quoting: Fields with commas or quotes must be quoted - some tools quote everything unnecessarily
  • Headers: Some CSVs have headers, some don't - CSV to JSON assumes headers by default but can work without them

If your CSV isn't parsing correctly, check whether it uses a different delimiter or has inconsistent quoting.

Convert Without Worry

The next time you're staring at a JSON file you need as YAML, or a CSV that should be JSON, don't do it manually. Open the right Toolblip converter, paste your data, and download the result. Everything runs locally in your browser - fast, private, and correct.