Tools › Data
XML Format
Indent XML, or minify it; pick parts out with an XPath query; convert XML to JSON and back.
About this tool What it's for, how to use it and an example
What it's for
Lay out XML so it’s readable, or squash it onto one line. It also checks that the XML is well formed and shows the parser’s error if it isn’t.
For example, when a config file, SOAP response, RSS feed or SVG arrives as one long line, prettify it to see its structure.
How to use it
Paste XML, choose an indent (2 or 4 spaces, or tabs), and choose Prettify or Minify. Comments, CDATA sections, processing instructions and namespace declarations are kept.
Type an XPath query, such as //book[price < 10]/title or count(//book), and Prettify shows only what it picks out: elements, attribute values, text or a single number. Namespace prefixes declared in the document can be used in the query.
XML → JSON turns elements into objects, attributes into keys starting @, text into #text (or the whole value, for an element with nothing else), and repeated elements into lists. JSON → XML does the reverse with the same rules, so the two round-trip.
Example
Paste this and choose Prettify:
<note><to>Alice</to><from>Bob</from><body>See you <b>soon</b></body></note>
Each child of <note> goes on its own indented line. <body> stays on one line, because it contains text and
adding line breaks would change that text.
Good to know
Elements that contain text are never re-wrapped, so mixed content such as XHTML paragraphs stays on one line. Whitespace-only text between elements is removed. XML → JSON gives every value as a string, since XML has no numbers or booleans. XPath is the browser’s own XPath 1.0.
An element with text in it is kept on one line, since adding line breaks there would change its text.
Private: this tool runs in your browser. Nothing you type, paste or choose leaves this page.
Saved you a few minutes? Say thanks with a coffee.
Something wrong with this tool, or missing from it? Report a bug or suggest a feature.