XML tool
Format and beautify · well-formedness check with errors by row and column · XML to and from JSON
转换规则写死在页面上,可预期
XML → JSON 的五条规则:① 属性存为「@属性名」键;② 只有文本的元素存为字符串(CDATA 按文本处理,空白会保留原样);③ 重名兄弟元素存为数组;④ 空元素存为空字符串;⑤ 注释丢弃。JSON → XML 按同一套规则反向还原——以 @ 开头的键回到属性位置,数组变回重名兄弟元素。规则不黑箱,页面上写什么样、产物就是什么样。
校验报的是"行:列",不是"哪里不对"。格式良好性(标签配对、属性引号闭合、实体转义、XML 声明)由自写解析器逐字符检查,出错直接给出行列号;浏览器里还会用原生 DOMParser 交叉复核一遍,两边结论不一致时页面会明说。它不校验 DTD / XSD,带前缀的名字按普通名字处理——模式级校验请用专门的 XSD 工具。
边界是硬守卫,不是软提示。输入上限 5MB、嵌套深度 200 层:超限直接拒绝并说明原因,不会静默截断你的内容;解析器对未闭合标签、裸 & 符号这类经典错误都会给出人话原因,不用自己猜。
FAQ
Attributes are stored as "@attributeName"; an element with only text becomes a string; repeated sibling elements become an array; an empty element becomes an empty string; CDATA is treated as text; comments are dropped. JSON to XML reverses the same ruleset - keys starting with @ go back to being attributes.
No. This page checks well-formedness (matching tags, attribute quotes, entity escaping, the declaration) and reports the line and column of the error; it does not validate DTD / XSD, and prefixed names are treated as plain names. For schema-level validation, use a dedicated XSD tool.
No. Parsing, formatting and converting all happen inside the browser - the content never leaves the machine, nothing is written to localStorage, reloading clears it; this page has no upload endpoint, and you can verify that in the Network panel of the developer tools.
It suits everyday configuration and API payloads, capped at 5 MB; nesting depth is limited to 200 levels to keep a pathological document from exhausting memory. Over the limit the page refuses outright and says why - it never silently truncates.