TXT · Text & Data tools

Data Format Converter

From
To
Indent
Input · JSON (auto)
Output · JSON
0 Bin0 Bout0lines in0keysEmptyJSON

The JSON pivot

Six formats, one converter. JSON, YAML, XML, TOML, CSV, and TSV each parse into a plain JSON value and each write out from that same value, so picking any input and any output format works, including pairs like TOML to CSV that most converters don’t bother building directly.

Paste data on the left, choose the input format or leave it on Auto-detect, choose the output format, and the result updates as you type. Auto-detect checks for JSON first, then a consistent CSV or TSV column count, then TOML, then falls back to YAML, since YAML’s syntax is loose enough to match almost anything.

Example: JSON to XML

{ "user": { "id": 42, "active": true, "tags": ["admin", "beta"] } }

becomes

<user>
  <id>42</id>
  <active>true</active>
  <tags>admin</tags>
  <tags>beta</tags>
</user>

The single top-level key (user) becomes the root element instead of an extra wrapper, and each array entry becomes a repeated sibling element. Numbers and booleans are written as text, since XML has no native number or boolean type, and reading the file back in returns strings.

XML attributes and text nodes

XML has two things JSON doesn’t: attributes and mixed text content. The converter uses the @_name convention for attributes and #text for text content next to child elements, matching how most JavaScript XML libraries represent XML as JSON. <user id="42">Alice</user> becomes { "user": { "@_id": "42", "#text": "Alice" } }.

CSV and TSV shape

CSV and TSV are tables, not trees, so converting into them means deciding what a row is. An array of objects becomes one row per object with the header set to the union of every key seen, in order. A single object becomes one row. Nested objects and arrays flatten into dotted column names such as address.city or tags.0 unless Flatten nested is off, in which case the nested value is written as a JSON string inside one cell.

Going the other way, Header row controls whether the first line becomes object keys or gets read as data, and Coerce types turns cells that look like 42, true, or null into numbers, booleans, and null instead of leaving everything as text.

TOML limits

TOML requires an object at the root; a bare array or a plain string with no key around it can’t convert to TOML directly. TOML also has no null, so any null field is dropped from the output rather than written as an empty value, and the warning strip notes it.

YAML anchors

An anchor (&name) and its alias (*name) let one YAML value reference another so it appears twice without being duplicated in the file. Parsing resolves the alias to a full copy of the anchored value, so the reference itself doesn’t survive a round trip through this converter or through JSON, which has no equivalent concept.

For validating or reformatting a single format without converting it, use the JSON formatter, YAML formatter, XML formatter, or TOML formatter. To clean up messy CSV rows before converting them, start with the CSV editor. To query or reshape a JSON value after conversion, the JSON query playground and JSON schema generator pick up where this tool leaves off.

Frequently Asked Questions

The input always parses to a plain JSON value first, and the output always builds from that same value. YAML to XML runs as YAML to JSON, then JSON to XML, so every combination of the six formats works without a dedicated converter for each pair.

CSV needs a flat table: an array of objects, or a single object treated as one row. A deeply nested JSON value gets flattened into dotted column names like address.city unless you turn off Flatten nested, in which case the nested value is written as a JSON string in one cell.

Attributes become object keys prefixed with @_, and text inside an element with attributes or child elements becomes a #text key. Converting back to XML reverses both conventions, so XML to JSON to XML round-trips cleanly.

TOML has no way to represent a root-level array or a bare scalar; it needs an object at the top. It also has no null. Wrap the value in a key for the array case, and remove or replace null fields before converting.

No. YAML anchors are resolved to their referenced value while parsing, so the output holds a full copy instead of a reference. The warning strip below the output pane flags this when the input contains anchors.

CSV and TSV both go through the same tabular codec, so CSV to TSV works directly: rows and header are re-serialized with a different delimiter, no detour through JSON needed conceptually, though the tool still uses the same pivot internally.

Looking for a faster, single-purpose workflow?

Jump straight to a conversion

Explore Our Tools

Browse all tools