# XML Formatter & Validator - Beautify, Minify and Convert XML ↔ JSON

> Free online XML formatter: beautify or minify XML, validate it with line and column errors, keep comments and CDATA, and convert XML to JSON and back.

- URL: https://qilingtools.com/en/xml-format
- Category: Developer Tools (https://qilingtools.com/en/dev)
- Tags: [Developer](https://qilingtools.com/en/tags/dev), [Data Formats](https://qilingtools.com/en/tags/data), [Code Formatting](https://qilingtools.com/en/tags/format)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

XML from API responses, SOAP envelopes, Android layouts, Maven pom.xml files, RSS feeds or logs often arrives squeezed onto one line. Paste it here for neatly indented XML: one element per line, text-only elements kept on a single line, mixed content such as <p>Hello <b>world</b></p> preserved intact, and comments, CDATA sections, processing instructions and DOCTYPE left untouched; elements with many attributes can list one attribute per line. Minify removes whitespace between tags (and optionally comments) and shows the size before and after. The browser's built-in XML parser validates your document as you type, pointing to the line and column of mismatched tags, unquoted attributes or illegal characters. You can also convert XML to JSON — attributes become "@name", text becomes "#text", repeated elements become arrays and numbers or booleans can be typed automatically — or turn JSON back into XML.

## How to use

1. Choose Beautify, Minify, XML → JSON or JSON → XML
2. Paste XML (or JSON) and set indent, attribute wrapping and comment options
3. Check the validation result, then copy or download the output

## Features

- Beautify with 2 / 4 spaces or tabs
- Mixed content, comments, CDATA and DOCTYPE preserved
- Optional one-attribute-per-line layout
- Minify with size comparison
- Live well-formedness validation with line and column
- XML to JSON with @attributes, #text and arrays
- JSON to XML with optional declaration and custom root

## FAQ

### Does formatting change my XML?

Elements, attributes and text are unchanged; only indentation and line breaks between tags are adjusted. Mixed-content elements stay on one line so no extra whitespace is inserted into text. If your document depends on whitespace between tags (for example xml:space="preserve"), keep the original.

### How is XML converted to JSON?

Each element becomes a JSON key; attributes are written as "@name" and text as "#text"; repeated child elements are collected into an array; text-only elements without attributes become plain strings, and empty elements become null. With type conversion on, text such as "42" or "true" becomes a number or boolean.

### Why does it say my XML is not well-formed?

XML is strict: every start tag needs a matching, correctly nested end tag, attribute values must be quoted, there can be only one root element, and & and < in text must be written as &amp; and &lt;. The reported line and column show where the parser noticed the problem, which is usually at or just after the mistake.

### Is my data uploaded?

No. Formatting, validation and conversion all happen locally in your browser, so API payloads and configuration files never leave your computer.

## Related tools

- [JSON Formatter](https://qilingtools.com/en/json): Free online JSON formatter: beautify or minify, validate with the exact line and column of any error, browse a collapsible tree, sort keys and escape strings.
- [Base64 Encode/Decode](https://qilingtools.com/en/base64): Free online Base64 encoder and decoder: UTF-8 safe, optional URL-safe variant, convert text to Base64 and back in real time. Processed locally, never uploaded.
- [URL Encode/Decode](https://qilingtools.com/en/url-encode): Free online URL encoder and decoder with encodeURIComponent and encodeURI modes. Escapes Chinese, spaces and special characters. Real-time and local, no upload.
- [JWT Decoder](https://qilingtools.com/en/jwt): Free online JWT decoder: decode the header and payload of a JSON Web Token, show expiry and issued-at times, all locally without uploading the token.
- [Timestamp Converter](https://qilingtools.com/en/timestamp): Free online Unix timestamp converter: convert timestamps and dates, auto-detect seconds or milliseconds, and show local, UTC, ISO 8601 and relative time.
- [Hash / Checksum](https://qilingtools.com/en/hash): Free online hash calculator: SHA-1, SHA-256, SHA-384 and SHA-512 of text or any file through the browser crypto API. Files never leave your device.
- [UUID Generator](https://qilingtools.com/en/uuid): Free online UUID generator: create RFC 4122 UUID v4 in bulk with a cryptographic RNG. Options for uppercase, no hyphens and braces, with one-click copy.
- [Base Converter](https://qilingtools.com/en/base-convert): Free online number base converter: convert between binary, octal, decimal, hexadecimal and any base 2–36. Uses BigInt for huge integers, computed locally.
