⚡Free Tools

XML Formatter, Validator & Viewer

Beautify or minify XML, find the exact line of any error, explore it as a tree, test XPath queries and convert between XML and JSON. Private and instant: nothing is uploaded.

Input

Format, validate and convert XML in one place

This XML formatter turns a single unreadable line of XML into a neatly indented document in one click, and checks that it is well-formed while doing so. Paste XML, drop a file such as .xml, .svg, .rss, .kml, .gpx, .xsd or web.config, and press Format or Ctrl+Enter. Choose 2 spaces, 4 spaces or tabs. Minify does the opposite and removes the whitespace between tags, which is useful for SOAP requests, sitemaps and embedded SVG.

The parser is the XML engine built into your browser, so the checks follow the XML 1.0 rules exactly. Nothing is uploaded: you can safely paste invoices, e-way bill or GST e-invoice payloads, bank statements in XML, SOAP messages with credentials or internal configuration.

Error messages you can act on

When the XML is broken, you see the line and column, a two-line snippet with a caret under the exact character, and the line is marked in red in the numbered editor. Press Go to error to put the cursor there. The most frequent problems are:

What is preserved when formatting

The formatter keeps the XML declaration, the DOCTYPE (including an internal subset), comments, processing instructions, CDATA sections, namespace declarations and the order of attributes. Elements that contain only text stay on one line, so <price>199</price> is not split across three lines. Mixed content, such as a paragraph with a <b> inside it, is kept inline exactly as written, because adding line breaks there would change the text. Whitespace-only text between tags is treated as indentation and replaced. If you want to remove comments, tick Remove comments. If a system cannot read self-closing tags, tick the option that writes <a></a> instead of <a/>.

Tree view and XPath

The Tree view shows each element with its attributes and a short preview of its text. Large files open lazily, so even a multi-megabyte feed stays responsive. Each row carries a path chip; click it to copy an XPath such as /catalog/book[2]/price and load it into the XPath box. The XPath tester runs real XPath 1.0 queries using your browser's engine: try //book[@lang='hi'], count(//book) or sum(//price). For elements in a default namespace, use *[local-name()='title'].

XML to JSON and JSON to XML

Choose XML → JSON to get a JSON object that follows the widely used convention: attributes become keys with a prefix (@id by default, or _id / -id), text becomes the value or a #text key when the element also has attributes, and repeated child elements become arrays. Tick Numbers as numbers if you want 199 rather than "199". JSON → XML reverses the mapping, so you can round-trip a document, edit it as JSON and convert it back. If the JSON has several top-level keys or is an array, the result is wrapped in a <root> element.

Quick reference: the five XML entities

Only five characters have predefined entities in XML, and two of them are mandatory inside text. Use &amp; for an ampersand and &lt; for a less-than sign everywhere in text and attribute values. Use &quot; inside an attribute delimited by double quotes and &apos; inside one delimited by single quotes. &gt; is optional but is required in the sequence ]]>. HTML names such as &nbsp; or &copy; do not exist in plain XML; write the character itself or a numeric reference such as &#160;. This formatter writes the mandatory escapes for you when it outputs text and attributes, so its output is always safe to paste into another system.

Who uses an XML formatter

Privacy, offline use and limits

All processing happens in your tab with no server round-trip, and the page works offline once it has loaded; install it from the header to open it like an app. The tool has been tested with files over 1 MB, Hindi and emoji text, and broken input. It checks well-formedness, not validity against an XSD or DTD schema. External entities are never fetched, which protects you from XXE attacks.

Frequently asked questions

Is my XML sent to a server?

No. It is parsed by your browser's built-in XML engine inside this tab. You can go offline after the page loads.

Does it validate against an XSD schema?

It checks that the document is well-formed according to XML 1.0 (tags, quotes, entities, one root, namespaces). Schema validation against XSD or DTD is not done.

Why is my paragraph not split onto separate lines?

Elements that mix text and child tags are kept inline on purpose, because inserting line breaks there would change the text content.

How are attributes shown in XML to JSON?

As keys with a prefix, @ by default. Text in an element that has attributes goes into a #text key. Repeated child elements become an array.

Can I format SVG, RSS or sitemap files?

Yes. They are XML, so any SVG icon, RSS or Atom feed, sitemap.xml, KML, GPX, Android layout or .NET config can be formatted and validated here.

Is it safe against XXE?

Yes. The browser parser does not fetch external entities or DTDs, so a malicious document cannot read files or call other servers.

Keyboard shortcuts

Ctrl + EnterFormat
Ctrl + Shift + MMinify
Ctrl + Shift + JXML → JSON
Ctrl + Shift + CCopy output
Ctrl + SDownload