Encoders & Utilities

Data Format Converter

Convert between JSON, YAML, TOML, XML, and CSV. Auto-detect input format, pretty-print toggle, and inline error messages. Runs entirely in your browser.

About this tool

Data Format Converter translates between the five everyday configuration and data-interchange formats: JSON, YAML, TOML, XML, and CSV. Paste any of them and the tool auto-detects the input format, parses it, and re-emits it in the target format with proper escaping and pretty-printing. Parse errors are shown inline with line and column so you know exactly what to fix.

Each format has its own quirks. JSON is the lowest common denominator — strings, numbers, booleans, arrays, objects. YAML adds comments, multi-line strings, and references. TOML is JSON with a config-file-friendly surface syntax (sections, comments, dates). XML adds attributes and namespaces that do not translate cleanly to the others. CSV is tabular and only round-trips to and from the "array of flat objects" shape of the source. The tool flags lossy conversions before applying them.

When to use this tool

  • Migrating config files. A Helm chart in YAML to be consumed by a Terraform module that wants JSON — paste and convert.
  • Quick CSV inspection. Paste a spreadsheet export, get a clean JSON array to feed into your test suite.
  • YAML / TOML interop. Same configuration values, different surface syntax preferences across team members.
  • Debugging XML APIs. Convert the SOAP response to JSON to read it without drowning in angle brackets.

About lossy conversions

JSON → YAML and back is lossless for plain data. XML → JSON loses the distinction between attributes and child elements (we map attributes to a @attr key, which is a convention not a standard). CSV → JSON requires the first row to be headers (toggle this) and assumes flat records — nested objects are not representable. The tool warns when the round-trip would not be byte-identical so you can choose to accept or pick a different target.

Frequently asked questions

Why does my YAML fail to parse?

YAML is whitespace-sensitive — tabs are not allowed (use spaces) and indentation must be consistent within a block. Common errors: a colon without a following space (key:value vs key: value); missing quotes around values that contain : or #; tabs mixed with spaces. The parse error message includes the line and column so you can find the offending character quickly.

Can I convert XML with attributes?

Yes — XML attributes become keys prefixed with @ when converting to JSON / YAML / TOML. <item id="1">text</item> becomes { "item": { "@id": "1", "#text": "text" } }. This is a convention (used by Badgerfish, JsonML variants) — not a single standard. Converting back to XML rebuilds the original structure. Mixed content (text and elements interleaved) is the lossy case; we flag it.

How does CSV detect headers?

By default the first non-empty row is treated as headers and the rest as data rows. You can disable this — then each row becomes an array of values without keys. For exotic delimiters (semicolon, tab, pipe) we auto-detect from the first row's character frequencies. UTF-8 BOM is stripped silently; CRLF and LF line endings are both accepted.

Does my data leave the page?

No — every parser runs in JavaScript in your browser. There is no network call, no logging, no persistence. You can disconnect from the network before pasting sensitive configs and the tool still works. For maximum safety with private data, save the page offline (HTML + JS) and run it from a local file.