XML to JSON Converter Online

Convert XML to JSON and back, check XML well-formedness with line and column, pretty-print or minify XML, and convert TOML or INI to and from JSON.

Free tool: 20 requests per minute.

Result

Press “Run” to see the result.

Send a document in xml, json, toml or ini (or as the raw body with from) and pick to: json, xml, toml, ini, validate, pretty or minify. XML to JSON keeps attributes under a prefix (@_ by default, attribute_prefix=none for none), puts mixed text in #text, and can force arrays for repeated elements (array_tags=item,line or always_array=true), keep the element order (preserve_order=true), strip namespace prefixes (remove_ns=true) and keep CDATA or comments. Values stay strings unless parse_values=true, so tax codes and invoice numbers such as 0101234567 keep their leading zeros.

JSON to XML turns keys starting with the prefix into attributes, arrays into repeated elements and wraps the result in root when needed; the output is checked again and a warning is returned if a key is not a valid element name. validate reports the first error with its line and column, plus the root element, namespaces and element count; pretty / minify re-indent XML (or JSON) keeping comments, CDATA and processing instructions.

Safety: entity expansion is limited (no "billion laughs"), external entities (SYSTEM / PUBLIC) are never loaded, nesting is capped at 256 levels and documents at 5 MB. TOML support covers TOML 1.0 except arbitrary-precision integers (dates and times become strings, inf / nan become strings); INI supports sections, ; / # comments, quoted values, key[] arrays and optional dotted sections.

Use this in your code

curl -X POST "https://apibox.io.vn/v1/xml-convert" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"xml":"<invoice id=\"HD001\"><buyer>Công ty A</buyer><item><name>Pen</name><qty>2</qty></item><item><name>Book</name><qty>1</qty></item></invoice>"}'

API documentation → Get a free API key

FAQ

Why are numbers returned as strings?

XML has no types, and codes like 0101234567 must keep their leading zeros. Add parse_values=true to get numbers and booleans.

How do I always get an array for repeated elements?

List them in array_tags (e.g. array_tags=HHDVu), or use always_array=true for every element below the root.

Is DOCTYPE / entity processing safe?

Yes: internal entities are expanded only within small limits, nested expansions beyond them stay as text, and external entities are rejected.