Skip to content

XML Formatter & Viewer

Format, beautify, and validate XML with syntax highlighting, tree view toggle, and minification

XML Formatter & Viewer

Indent:
View:
594 chars / 1 lines
Formatted output679 chars / 22 lines
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
  <book category="cooking">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
  </book>
  <book category="children">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>
  <book category="web">
    <title lang="en">Learning XML</title>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>39.95</price>
    <description>A comprehensive guide to XML fundamentals, including namespaces, schemas, and transformations.</description>
  </book>
</bookstore>

Features

Format & beautify

Automatically indent and format XML with configurable spacing (2, 4, or tab).

Minify

Remove unnecessary whitespace and compress XML to a single line for production.

Syntax highlighting

Color-coded tags, attributes, values, comments, and CDATA sections for easy reading.

Tree view

Visualize XML structure as a color-coded, hierarchical tree view.

Updated . Provided as is. Check the output before you rely on it in production.

How to use XML Formatter & Viewer

  1. 1

    Paste your XML

    Paste minified, broken or formatted XML into the input, or load the sample.

  2. 2

    View formatted output

    Formatted XML appears in the right panel with syntax highlighting. Switch to Tree view to see the nested structure. Errors show with line numbers.

  3. 3

    Choose indentation or minify

    Set the indent width, or switch on Minify to compress the XML onto a single line.

  4. 4

    Copy or download output

    Copy the result, or download the formatted XML file for your project.

Questions and answers

What is XML Formatter & Viewer?
XML marks up data with nested, named tags and attributes and is still used in SOAP APIs, RSS feeds, sitemaps and config files. This tool checks that XML is well-formed, indents it with 2 spaces, 4 spaces or tabs, minifies it, and shows it as highlighted code or an indented element tree.
Does XML Formatter & Viewer store or send my data?
No. All processing happens entirely in your browser. Your XML data never leaves your device — nothing is sent to any server.
Can XML Formatter & Viewer minify XML?
Yes. In addition to beautifying XML, it can minify it by removing whitespace, newlines, and indentation. This is useful for reducing file size when embedding XML in API requests or config files.

Use it as an API

XML Formatter & Viewer is also callable as a free HTTP JSON API at https://aidevhub.io/api/xml-formatter/ — GET with query parameters or POST with a JSON body, no authentication, CORS enabled, fair use (abusive traffic is throttled at the edge; there is no per-request quota header). Responses return { ok, tool, result, meta }.

curl -s -X POST https://aidevhub.io/api/xml-formatter/ \
  -H "Content-Type: application/json" \
  -d '{"xml":"<root><item id=\"1\">alpha</item><item id=\"2\">beta</item></root>","mode":"format"}'

Machine-readable contract: /api/tool/xml-formatter.json All API endpoints: /agents/ LLM site index: /llms.txt

For AI agents: how to call this tool

Machine-readable contract, endpoints and examples. Humans can ignore this section.

Best Path For Builders

Dedicated API endpoint

Deterministic outputs, machine-safe contracts, and production-ready examples.

Dedicated API

https://aidevhub.io/api/xml-formatter/

OpenAPI: https://aidevhub.io/api/openapi.yaml

GET /api/xml-formatter/ GET xml-formatter
POST /api/xml-formatter/ POST xml-formatter