Agenvix Enterprise Suite
Markup Toolkit

XML Formatter, Beautifier & Validator

Pretty-print minified XML with your preferred indentation, validate well-formedness with exact line numbers, minify for transport and convert XML to JSON. Sitemaps, RSS feeds, SOAP envelopes, Android layouts and config files - all processed locally in your browser.

How It Works
Pretty Print
Validation with Line Numbers
XML → JSON
No Upload
Agenvix Studio v2.0
Well-formed14 elements · depth 4
Input:
catalog.xml · 1 line (minified)
Output:
20 lines · 2-space indent · CDATA kept
Also:
Minify, strip comments, convert to JSON
● Comments & declarations preservedCopy or download .xml
Quick Test Presets:Click to load
Comments & declarations preserved
100% Free

XML Formatter Workspace

Paste XML on the left. Switch between Beautify, Minify and XML → JSON. The validator reports the first error with its line and column.

Validation runs in your browser as soon as the page is interactive.
Formatted XML
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <!-- Autumn catalog -->
  <product id="p-100" sku="TSHIRT-M">
    <name>Organic Cotton T-Shirt</name>
    <price currency="USD">24.90</price>
    <tags>
      <tag>apparel</tag>
      <tag>organic</tag>
    </tags>
    <description><![CDATA[Soft & breathable <b>unisex</b> tee]]></description>
    <stock warehouse="LHR">120</stock>
  </product>
  <product id="p-101" sku="MUG-01">
    <name>Ceramic Mug</name>
    <price currency="USD">12.00</price>
    <tags/>
    <stock warehouse="KHI">0</stock>
  </product>
</catalog>
Elements
14
Attributes
8
Comments
1
Max depth
4

Why Developers Use the Agenvix XML Formatter

A careful formatter that keeps your document semantically identical.

Faithful Pretty Printing

Declarations, DOCTYPE, comments, processing instructions and CDATA sections are preserved; elements with short text stay on one line for readability.

Real Validation

The browser's XML parser checks well-formedness - mismatched tags, unescaped ampersands, bad attributes - and the error message includes the line so you can jump straight to it.

XML to JSON

Convert documents to JSON with attributes prefixed by @, repeated elements collected into arrays and mixed text under #text - handy for APIs and quick inspection.

Private by Design

Invoices, SOAP payloads and config files never leave your machine. There is no upload, no account and no history.

Simple as 1-2-3

How the Formatter Works

Tokenise, validate, re-indent.

01

Paste XML

Minified feeds, API responses, exported settings - any XML, even slightly broken markup is formatted on a best-effort basis.

02

Choose Mode & Options

Beautify with 2/4 spaces or tabs, strip comments, minify, or convert to JSON.

03

Copy or Download

Copy the result or download .xml / .json. The status line confirms whether the document is well-formed.

Node Reference

How Each XML Construct Is Handled

Formatting, minifying and JSON conversion rules.

Feature / SpecificationBest Use CaseEngine / Output StandardPrivacy & SecurityPerformance RatingAction
Elements & attributesDocument structureIndented per depthJSON: @attr keysCore
Text contentValuesTrimmed, inline when shortJSON: string or #textCore
<!-- comments -->DocumentationKept (optional strip)Dropped by minifyOptional
<![CDATA[ … ]]>HTML / code payloadsByte-for-byte preservedJSON: text valueCore
Declaration, DOCTYPE, PIHeadersPreserved on own lineNot in JSONCore
Comprehensive Guide

Well-Formed XML and Readable Markup

1. Well-formed vs valid

Well-formed XML follows the syntax rules: one root element, every tag closed, attributes quoted, special characters escaped (&amp;, &lt;). Valid XML additionally conforms to a schema (XSD, DTD, RELAX NG). This tool checks well-formedness - the layer that breaks most feeds and API payloads - and reports the first offending line. Schema validation needs the schema itself and is out of scope here.

2. The errors you will actually see

The most common failures are an unescaped ampersand in a URL or title (& must be &amp;), a mismatched closing tag, an attribute without quotes, text before the <?xml ?> declaration (including a UTF-8 BOM), and HTML-style void tags such as <br> that must be <br/> in XML.

Paste the document, read the line number in the status bar, fix that spot and re-validate.

3. Converting XML to JSON

XML and JSON do not map one-to-one: XML has attributes, ordered mixed content and namespaces. The conversion here uses a widely used convention - attributes become @name keys, repeated child elements become arrays, an element with only text becomes a string, and text next to child elements lands in #text. Namespace prefixes are kept as part of the key (for example atom:link).

4. Minify for production

Whitespace between elements is usually insignificant, so minified sitemaps, feeds and SOAP requests are smaller and faster to parse. Minify removes comments and inter-element whitespace but never touches text content or CDATA. If your schema treats whitespace as significant (rare, for example xml:space="preserve"), keep the formatted version.

Frequently Asked Questions

Everything you need to know about formatting XML

Validation, options, JSON conversion and privacy.

How do I format XML online?

Paste your XML into the input, choose 2 or 4 spaces or tabs, and the beautified document appears instantly. Copy it or download an .xml file.

Does the formatter validate my XML?

Yes. It checks well-formedness with the browser's native XML parser and shows the first error with its line and column. Schema (XSD/DTD) validation is not performed.

Are comments and CDATA preserved?

Beautify keeps comments, CDATA, the XML declaration, DOCTYPE and processing instructions. You can strip comments with the toggle; minify removes comments by default.

How does XML to JSON handle attributes?

Attributes become keys prefixed with @ (for example "@id"), repeated child elements become arrays, text-only elements become strings and mixed text is stored under "#text".

Can I format a broken XML file?

Beautify works on a best-effort basis even when the document is not well-formed, so you can read it and find the problem. The validator will tell you where the first error is.

Is my XML sent to a server?

No. Formatting, validation and conversion all run in your browser; nothing is uploaded or stored.