Converting

XML to JSON converter

Convert XML to JSON with attributes stored as @name fields and text as _text when needed. Repeated sibling elements become arrays. The direction selector also supports JSON input.

Input (XML or JSON)

0 chars · 0 words · 0 lines

Get QR code
Copy to clipboard
Save to file
Direction:

Output

0 chars · 0 words · 0 lines

Get QR code
Copy to clipboard
Save to file

Read XML attributes and repeated elements as JSON

Paste XML and leave Auto-detect selected, or choose XML to JSON. The input <user id="7">Alice</user> becomes {"user":{"@id":"7","_text":"Alice"}}. A simple element with no attributes or children becomes a string value.

Repeated sibling tags become arrays. For example, <root><item>a</item><item>b</item></root> becomes {"root":{"item":["a","b"]}}. Numeric-looking text stays a string. The parser keeps the root element name as the outer JSON key.

Understand the limits of the XML mapping

This lightweight parser omits comments and processing instructions. It trims surrounding text whitespace and does not preserve the original order of mixed text and child elements. It is a converter rather than a strict XML validator. Check document syntax with the XML validator.

The JSON to XML direction on this page reads @name as an attribute and _text as text. Supply one outer key as the document element. The separate JSON to XML page uses a root wrapper and a different mapping. Use the JSON formatter to inspect larger results.

Common questions

How are XML attributes represented in JSON?
An attribute such as id="7" becomes a JSON property named @id with the string value 7. Text alongside attributes becomes an _text property.
Is XML to JSON conversion lossless?
No. This mapping omits comments and processing instructions, trims text, and cannot preserve mixed-content order. Keep the original XML when those details matter.
Share

marduc812

SourcePrivacy

© 202620261119_b7bad2b