JSON Converter

Input
Output

JSON Converter features

Six formats, any direction

JSON, YAML, XML, CSV, TSV and query strings convert into each other, so you do not need a separate tool for every pair

Live output

The result refreshes as you type or paste, with no convert button — useful when you are reshaping a deeply nested structure

Errors with line and column

JSON syntax errors report the exact line and column, and YAML errors name the offending line, which beats a bare SyntaxError

Output under your control

Indent with two spaces, four spaces or minify completely, and sort keys recursively so two configs diff cleanly

XML attributes preserved

An @ prefix marks attributes and #text holds text nodes, so converting to XML and back does not silently drop attributes

Nothing leaves the browser

Parsing and serialisation are entirely local, so configuration files containing keys or credentials are safe to paste in

How to use the JSON Converter

1

Pick source and target format

The two dropdowns say what you have and what you want. Choosing the wrong source format fails immediately, which is itself a quick validation. The target defaults to YAML; switch it back to JSON when you need to minify.

2

Paste the content

Drop your data into the left box and the right box updates live. Press "Load sample" to get a sample that matches the current source format.

3

Adjust the options

Indentation controls whether the output is pretty or minified. The XML root name only matters when the source has no single top-level key. For CSV, check the delimiter and the header row.

4

Verify by converting back

Press "Swap formats and content" to feed the result back in as input. If the two directions agree, nothing was lost — the fastest way to check nesting and attributes survived.

Common uses

Writing config files

Turn an API response into a YAML config in one paste instead of deleting braces by hand

Getting data into a spreadsheet

Convert an array of records to CSV and open it in Excel for analysis

Talking to a legacy system

An older endpoint that only speaks XML: convert the JSON body, attributes preserved via the @ prefix

Unpacking request parameters

Paste a URL query string to see the structure, with repeated keys merged into arrays

Diffing two configs

Turn on key sorting and give both files the same indentation to strip out ordering noise

Finding a JSON syntax error

Minified JSON hides the position of the mistake; this tool reports the exact line and column

Data formats explained

JSON's type system and its traps

JSON has only six types: object, array, string, number, boolean and null. There is no date, no integer-versus-float distinction and no undefined — languages map these after parsing. Numbers are IEEE 754 doubles, so integers above 2^53 (a 19-digit snowflake ID, for instance) lose precision on parse; the correct fix is for the server to return them as strings. JSON also forbids trailing commas, single quotes and comments, and those three account for most hand-written JSON errors.

YAML indentation and implicit types

YAML expresses hierarchy with indentation: keys at the same level must align, and indentation must use spaces, never tabs. Its other distinguishing feature is implicit typing — true, false, null and ~ are recognised as booleans and null, and a purely numeric string needs quotes to stay a string. YAML 1.1 even treated yes, no, on and off as booleans, so the country code NO (Norway) parsed as false — the famous "Norway problem". This tool follows the YAML 1.2 core schema and recognises only true, false, null and ~, avoiding that ambiguity.

XML attributes, text and lists

An XML element can simultaneously carry attributes, text content and child elements, which is what makes it more complex than JSON. Attributes suit identifiers and metadata (id, type, unit), text suits the value itself, and child elements suit structure. XML has no array syntax: lists are expressed by repeating a child element, so a JSON conversion has to merge same-named siblings into an array. In the other direction each array element becomes a same-named child, and both directions must agree or the data will quietly change shape.

CSV is a family of formats, not one format

Strictly speaking CSV has no standard, only RFC 4180 as a de facto reference. The delimiter may be a comma, a semicolon or a tab (the last being TSV), and quoting rules, line endings and encoding all vary. Excel on Chinese Windows saves CSV as GBK by default, which turns into mojibake when read as UTF-8 — the most common trap of all. Another is leading zeros: a postcode of 007 becomes 7 if treated as a number, so this tool only infers a number when there is no leading zero and keeps everything else as a string.

Query strings carry no types

A URL query string is fundamentally text pairs of key and value with no type information, so the 1 in a=1 is a string and so is the true in a=true. Bracket notation (a[b]=1, a[]=1) is not part of any standard; it is a convention popularised by PHP, Rails and Express to express nested objects and arrays. Frameworks also disagree on duplicate keys — some take the last, some the first, some merge into an array. These differences are a classic cause of "works locally, wrong in production".

Conversion conventions cheat sheet

Construct JSON YAML XML
Object{ }key: valueChild elements
Array[ ]- itemRepeated elements
Attribute"@key"Ordinary keykey="value"
Text"#text"Ordinary keyElement content
Nullnullnull or ~Self-closing tag
CommentNot supported# comment<!-- -->
Note: @key and #text on the JSON side are this tool's convention for lossless XML round trips — delete them if you only need the data.

Frequently asked questions

Q: What is the real difference between JSON and YAML?
A: Both describe almost the same data model — objects, arrays and scalars — and differ in notation and audience. JSON spells out structure with braces and brackets, every language can parse it, and it is built for machine-to-machine transfer. YAML expresses hierarchy through indentation, dropping most brackets and quotes, which makes it easier for humans to read and write. The trade-off is that YAML is extremely sensitive to indentation: one extra space or a stray tab changes the structure or breaks the file, while JSON ignores whitespace entirely.
Q: Why does JSON to CSV sometimes fail?
A: Because CSV is a two-dimensional table and can only hold rows of records with a fixed set of columns, while JSON allows arbitrary nesting. Only when the top level is an array of flat objects can the data be represented losslessly as a table. When a value is a nested object or array, this tool serialises that cell as JSON text so nothing is lost, but whatever reads the CSV has to parse that cell again.
Q: What do @ and #text mean when converting XML to JSON?
A: They are this tool's convention for preserving XML information. An XML element can carry both attributes and text content, and a JSON object has no concept of attributes, so attribute names are prefixed with @ and the text content goes into a #text key. For example <book id="1">Hi</book> becomes {"book":{"@id":"1","#text":"Hi"}}. Converting back honours the same convention, so a round trip loses nothing.
Q: What happens to repeated XML child elements?
A: They become an array. XML allows several child elements with the same name under one parent, which is how it expresses lists, and the JSON equivalent is an array. So <ul><li>a</li><li>b</li></ul> becomes {"ul":{"li":["a","b"]}}. When there is only one child with that name it is not wrapped in an array — it is simply the value.
Q: Why did my Chinese text turn into \u4e2d escapes?
A: That is JSON's ASCII escape notation, semantically identical to writing the character directly — only the display form differs. This tool keeps the original characters and never escapes non-ASCII text. If data pasted in from elsewhere was already escaped, converting it to YAML or CSV restores the real characters, because the escapes are decoded during parsing.
Q: How are duplicate keys handled when converting a query string?
A: Duplicate keys are merged into an array. a=1&a=2 becomes {"a":["1","2"]}, which is what most server frameworks do. Bracket notation produces nested structures: a[b]=1 becomes {"a":{"b":"1"}} and a[]=1&a[]=2 becomes {"a":["1","2"]}. Note that all values are strings — numbers must be converted yourself.
Q: Is any of this data uploaded to a server?
A: No. All parsing and serialisation happens in JavaScript inside your browser, and nothing you type triggers a network request, so the tool also works offline. That matters for configuration files containing API keys, phone numbers or internal hostnames.