Skip to main content
L
Loopaloo
Buy Us a Coffee
All ToolsImage ProcessingAudio ProcessingVideo ProcessingDocument & TextPDF ToolsCSV & Data AnalysisConverters & EncodersWeb ToolsMath & ScienceGames
Guides & BlogAboutContact
Buy Us a Coffee
L
Loopaloo

Free online tools for developers, designers, and content creators. Your files are processed in your browser and are never uploaded - no accounts required. A few network utilities (like What's My IP and Currency Converter) call public APIs to do their job and say so on their pages.

support@loopaloo.com

Tool Categories

  • Image Tools
  • Audio Tools
  • Video Tools
  • Document & Text
  • PDF Tools
  • CSV & Data
  • Converters
  • Web Tools
  • Math & Science
  • Games

Company

  • About Us
  • Contact
  • Blog
  • FAQ

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

Support

Buy Us a Coffee

© 2026 Loopaloo. All rights reserved. Built with privacy in mind.

Privacy|Terms|Disclaimer
  1. Home
  2. Document & Text
  3. XML Formatter & Tools
Add to favorites

XML Formatter & Tools

Format, minify or convert XML to JSON as you type, with line-and-column error checks, a tree view and XPath queries that handle namespaces.

Text processed locallyMore document & textJump to full guide
Related readingXML and XPath: Understanding Structured Data and Powerful Queries12 min

Initializing in your browser…

You might also like

JSON Formatter & Validator

Format, validate and minify JSON, JSONC or JSON5 as you paste, with exact numbers, precise error locations, a tree view, JSONPath queries and schema checks.

YAML Formatter & Converter

Format and validate YAML or convert between YAML and JSON as you type, keeping comments, anchors and exact numbers, with YAML 1.1 and 1.2 support.

Code Minifier & Beautifier

Minify or beautify JavaScript, TypeScript, CSS, HTML, JSON, XML and SQL as you type, without touching strings or licences, and see the bytes saved.

XML Formatter & Tools: a worked example

An order export arrives as one long line of XML and you need to check the items before it is sent to the warehouse.

One-line XML

<order id="A-17"><customer>Ana Silva</customer><item sku="KB-2" qty="1">Keyboard</item><item sku="MS-9" qty="2">Mouse</item><note><![CDATA[Leave at <reception> & ring]]></note></order>
What XML Formatter & Tools produces

Formatted, 2-space indent

<order id="A-17">
  <customer>Ana Silva</customer>
  <item sku="KB-2" qty="1">Keyboard</item>
  <item sku="MS-9" qty="2">Mouse</item>
  <note><![CDATA[Leave at <reception> & ring]]></note>
</order>

Each element is indented by its depth, and elements that hold only text stay on one line so the values are easy to scan. The CDATA section is copied exactly, including the < and & that would otherwise need escaping. Switching to To JSON gives an order object with "@id": "A-17" and an item array of two objects, each with @sku, @qty and #text, because the two item elements repeat under the same parent.

What is XML Formatter & Tools?

Paste XML to indent it, minify it or convert it to JSON as you type, with an instant well-formedness check that points to the exact line and column of any error. Browse the result as a collapsible tree or query it with XPath, all in your browser.

How it works

XML still runs a surprising amount of the world: RSS and Atom feeds, SVG images, Office documents, Android layouts, Maven and .NET config files, SOAP services and sitemaps. It often arrives on a single line or with inconsistent indentation. This formatter lays it out cleanly, tells you immediately whether it is well formed, and does so without changing what the document means.

Formatting that respects the document. Each element is indented by its nesting depth with 2 spaces, 4 spaces or tabs. Text content, attribute values and comments are kept exactly. CDATA sections are written back byte for byte, because whitespace inside them is data. Elements marked xml:space="preserve", and mixed content where text and elements sit side by side, are left as they are, since adding line breaks there would change the text a program reads. Minify removes the whitespace between elements under the same rules, so the minified file is the same document in fewer bytes.

Errors you can act on. Every change re-checks the document. If it is not well formed, you get the line and column, the offending line with a caret under the problem, and a suggestion such as which element is still open or which closing tag does not match. The tool also asks your browser's own XML parser, so a document that passes here will load in other software that reads standard XML.

Tree and XPath views. The Tree view lets you fold and unfold elements to find your way around a large file. The XPath view evaluates XPath 1.0 expressions and shows matching nodes with a path you can copy, or the number, string or true/false value an expression returns. When the document declares a default namespace, as SVG, Atom, RSS extensions and many config formats do, an unprefixed name like //book matches nothing in XPath 1.0. The tool gives the default namespace a prefix and shows you how to use it, which solves one of the most common XPath puzzles.

Converting to JSON. To JSON turns elements into objects, attributes into @-prefixed keys, text into #text when an element also has attributes, and repeated elements into arrays. JSON has no place for comments or processing instructions, so when the document contains them the tool lists what was left out rather than dropping it silently. Everything happens locally, so internal configuration and data files stay private.

How to use

  1. 1Paste XML into the box, open a file, or press Try an example to cycle through a bookstore, an RSS feed, an SVG and an app config.
  2. 2Choose Format, Minify or To JSON. For Format, pick 2 spaces, 4 spaces or tabs.
  3. 3If the document is not well formed, read the line, column and hint above the panels and fix the input.
  4. 4Switch the right-hand panel to Tree to browse the structure, or to XPath to run a query.
  5. 5Copy the result or download it as .xml or .json.

Key features

  • Format with 2 spaces, 4 spaces or tabs, minify, or convert to JSON, all live
  • Well-formedness check with line, column, caret and a suggested fix
  • Double-checked against the browser's own XML parser
  • CDATA, comments, xml:space="preserve" and mixed content kept intact
  • Collapsible tree view with expand and collapse all
  • XPath 1.0 queries with automatic handling of default namespaces
  • JSON conversion that lists anything JSON cannot represent
  • Document summary: elements, attributes, depth, namespaces and CDATA sections
  • Copy and download with the correct file type
  • Runs locally in your browser

When to reach for this

  • Reading an API or SOAP response

    Indent a single-line response from a log or network trace so you can find the element you need, then query it with XPath.

  • Fixing a broken config file

    Find the unclosed tag in a web.config, pom.xml or Android layout from the exact line and column of the error.

  • Cleaning up SVG or feed files

    Format an exported SVG to edit it by hand, or minify it before inlining it into a page.

  • Moving data from XML to JSON

    Convert an XML export into JSON for a JavaScript app, and see whether any comments or processing instructions were left out.

Tips & best practices

  • Paste only the XML part of a log line; leading text before the root element makes the document invalid.
  • Use Minify before embedding SVG in HTML or CSS to save bytes without touching the drawing.
  • In the XPath view, count(//item) and sum(//price) return a single number, handy for checking a feed or export.
  • If the checker reports several problems, fix the first one; later ones are often a consequence of it.

Examples

  • An order on one line

    <order id="A-17"><customer>Ana Silva</customer><item sku="KB-2" qty="1">Keyboard</item><item sku="MS-9" qty="2">Mouse</item>...</order> formats to six lines, one element per line, with the CDATA note kept exactly as written.

  • A mismatched closing tag

    <order><item>Keyboard</order> is reported at line 1, column 22: </order> does not match the open <item>, with the hint that every element has to be closed in order.

  • XPath with a default namespace

    For the bookstore example, which declares xmlns="http://example.com/bookstore", //book finds nothing, while //bookstore:book[bookstore:price > 12]/bookstore:title returns A Brief History of Time.

Frequently asked questions

What does "well formed" mean?

A well-formed XML document follows the basic syntax rules: exactly one root element, every element closed and properly nested, attribute values quoted, and special characters such as & and < escaped outside CDATA. Any XML parser can read a well-formed document. Validity against a DTD or XSD schema is a separate, stricter check that this tool does not perform.

Will formatting change my data?

No. Only whitespace between elements is added or removed. Text, attribute values, comments and CDATA sections are kept, and elements with xml:space="preserve" or mixed text and markup are left untouched because whitespace there is meaningful.

Why does my XPath return nothing?

The most common reason is a default namespace. In XPath 1.0 an unprefixed name only matches elements in no namespace, so //item finds nothing in a document with xmlns="...". The XPath view assigns the default namespace a prefix and shows it, so write //prefix:item instead.

How are attributes and repeated elements converted to JSON?

Attributes become keys starting with @, text inside an element that also has attributes becomes #text, and elements that repeat under the same parent become an array. Comments and processing instructions have no JSON equivalent, so they are listed under What JSON could not carry.

Can I use tabs instead of spaces?

Yes. Choose Tab in the Indent menu next to Format. The choice is saved in the share link along with the output mode.

Is my XML uploaded?

No. Parsing, formatting, conversion and XPath all run in your browser, so confidential configuration and data never leave your device.

Related tools and how they differ

  • XPath Tester: A dedicated XPath workbench with all four result types and namespace bindings you can edit.
  • JSON Formatter & Validator: Formats and queries the JSON you get from the To JSON conversion.
  • YAML Formatter & Converter: Formats YAML configuration files and converts them to and from JSON.

Further reading

  • XML and XPath: Understanding Structured Data and Powerful Queries12 min read

Private by design

Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.