Skip to content
yutils
Example

Input (XML)

<user>
  <name>yutils</name>
  <tags>
    <tag>tools</tag>
    <tag>dev</tag>
  </tags>
</user>

Output (JSON)

{
  "user": {
    "name": "yutils",
    "tags": {
      "tag": [
        "tools",
        "dev"
      ]
    }
  }
}

Note

Repeating tags (`<tag>`) become arrays. Attributes appear as `@_attr` (configurable). Round-trip conversion supported.

Usage / FAQ

When to use

  • Feed legacy SOAP / RSS / sitemap.xml data into a JSON pipeline
  • Convert JSON to XML for systems that still require XML (rare but real)
  • Quickly inspect XML from Android, iOS, or older enterprise systems
  • Cross-convert OpenAPI / AsyncAPI XML and JSON definitions
  • Normalize scraped XML to JSON for downstream `jq` processing

FAQ

Q.How are attributes represented?
A.As keys prefixed with `@_` (e.g. `<a href="...">` becomes `{"a": {"@_href": "..."}}`). The prefix is configurable.
Q.What if a repeating tag only appears once?
A.By default it becomes a single object. Enable always-array mode if you want it forced into an array — downstream code stays consistent.
Q.What about comments and CDATA?
A.Dropped by default. Enable the preservation option to keep them as separate fields.
Q.What happens to null and empty objects in XML?
A.Both `null` and `{}` become an empty element (`<a/>`). XML has no null, and no way to tell an empty object from an empty string. So converting to XML and back turns both into an empty string (`""`) — if you need a round trip, keep such values as strings. An empty array produces no element at all, so that one is reported as an error instead.
Q.What is the difference between the Compact and Ordered shapes?
A.Compact is the readable default, but when an element mixes text with children (`<p>Hello <b>x</b>!</p>`) the text runs merge and their order is lost. Ordered lists every node in an array, keeping order and whitespace, so converting back reproduces the original XML — at the cost of longer JSON where even indentation shows up as a `#text` node. Use Compact for data XML, Ordered for document markup.
Fun facts
  • 1:1 conversion between XML and JSON is fundamentally impossible — XML's attributes, namespaces, comments, and mixed content don't map cleanly onto JSON. Most converters reach for conventions (e.g., attributes become `@name` keys) and still lose information on round-trip.

    W3C — XML 1.0
  • Moving from SOAP (XML-based RPC) to REST (typically JSON) was the biggest web-API paradigm shift of the 2010s. SOAP's heavy envelope (multi-KB overhead) lost decisively to JSON's lightness in the mobile era — Twitter's 2018 SOAP shutdown is a fitting capstone.

    Wikipedia — SOAP
  • JSON dominates web APIs, but XML still rules publishing — RSS, Atom, EPUB, DocBook, Office Open XML (a .docx is a zipped XML bundle). The clean split between 'structured content' (XML) and 'data interchange' (JSON) has settled.

    Wikipedia — XML applications