XML conversion does not expand entities

CodeMoment · Updated 2026-10-31

Some XML converters expand entities. A document can then name a local file or a URL, and the converter reads it while turning the document into JSON. That is the external-entity problem: text you pasted points at something you did not mean to open.

This page rejects a DOCTYPE and an ENTITY declaration. It does not fetch them, and it does not expand a custom name. Only five predefined entities are decoded: amp, lt, gt, quot, and apos. A numeric character reference is decoded too. Any other name stops. A code point past Unicode stops. The first decode is the last one, so text that comes out looking like another entity is left as text.

Attributes become keys that start with @. Text mixed with child elements is kept under #text. A repeated sibling tag becomes an array. JSON going back to XML needs one root name. Whitespace at the two ends of an element's text is trimmed. Nesting stops after 32 levels.

The XML ↔ JSON tool converts and formats in this tab. The text is not uploaded.