XML 转 JSON
UpBox优盒工具箱,免费在线 XML 转 JSON:粘贴一段 XML,实时得到结构清晰的 JSON,属性以 @ 前缀保留、文本归到 #text、同名同级元素自动合成数组,支持 0-8 空格缩进。
无需注册 · 数据不上传No sign-up · nothing uploaded
XML 输入XML input
JSON 结果JSON result
属性统一放在 @ 前缀下,文本放在 #text;同名同级元素自动合成数组;只有一个子元素时不加数组,读代码时注意这点;注释、声明、DOCTYPE 会被忽略
工具介绍
对接老系统、读 RSS、看 SOAP 报文,拿到的常是 XML;要写代码时又希望它是 JSON,手敲一遍很容易漏标签。 Connecting to a legacy system, reading RSS or inspecting a SOAP payload usually hands you XML — and writing code is easier with JSON. Retyping it by hand loses tags.
贴上原文就出结构:属性有 @ 前缀,节点文字在 #text,重复的条目自动变数组,缩进还能拖到 0 变一行。 Paste the source and the structure appears: attributes carry an @ prefix, node text sits in #text, repeats become arrays, and the indent slider goes down to 0 for a single line.
- 属性前缀 @@ for attributes
- 同名合成数组Repeats to arrays
- 实时转换Live conversion
- 缩进可调Indent control
使用说明
- 粘贴 XML。Paste the XML.
- 看右侧 JSON。Read the JSON on the right.
- 按需调缩进。Adjust the indent.
- 复制给代码用。Copy it into your code.