Data Formats

XML Formatter & Validator — Pretty Print, Minify, Convert

Format, minify, and validate XML in your browser with exact error positions, then convert between XML and JSON. No upload, no sign-up.

Free to use No sign-up Runs in your browser

Tool workspace

Well-formed XML. 7 elements, 3 attributes, depth 3
Output

Parsing, formatting, and conversion run entirely in your browser. Nothing is uploaded.

What This XML Tool Checks and Changes

This tool parses XML with its own reader rather than a browser DOM parser, so it reports the first well-formedness problem with a line and column: mismatched closing tags, unquoted or duplicated attributes, unclosed elements, stray text outside the root, and more than one root element. Formatting keeps comments, CDATA sections, processing instructions, and self-closing tags intact, and keeps short text-only elements on a single line so the result stays readable. Well-formedness is not schema validation: this tool does not check a DTD, XSD, or RELAX NG grammar.

How to Format or Validate XML

  1. 1Paste XML into the input area. Validation runs immediately and reports either document statistics or the exact position of the first error.
  2. 2Choose Format to indent the document with two spaces, four spaces, or tabs.
  3. 3Choose Minify to strip formatting whitespace and see how many bytes the document saves.
  4. 4Use XML to JSON to get a structure that keeps attributes under @name keys and mixed text under #text.
  5. 5Use JSON to XML for the reverse direction, then copy the result or download it as a file.

Everyday XML Tasks

Read a machine-generated payload

Pretty-print a single-line SOAP envelope, RSS feed, sitemap, or API response so the structure becomes reviewable.

Find the exact break in a broken file

Get the line and column of a mismatched tag or unquoted attribute instead of a generic parse failure.

Shrink an XML asset

Minify configuration or feed output before shipping it, and see the byte difference before and after.

Move between XML and JSON

Convert legacy XML into JSON for a newer service, or produce XML from a JSON object for a system that still requires it.

Frequently asked questions

Does this validate against an XSD or DTD schema?

No. It checks well-formedness: tag matching and nesting, attribute quoting and uniqueness, a single root element, and correctly terminated comments, CDATA sections, and processing instructions. Grammar validation against a DTD, XSD, or RELAX NG schema is a separate step this tool does not perform.

Will formatting change my document's meaning?

Formatting only adds or removes whitespace between elements and normalizes attribute quoting to double quotes. Comments, CDATA, processing instructions, and the DOCTYPE declaration are preserved. Significant whitespace inside mixed content can shift, so avoid reformatting documents where inter-element whitespace is meaningful.

How are attributes and repeated elements represented in JSON?

Attributes become @name keys, mixed text becomes a #text key, and repeated sibling elements become an array. This is the common convention used by several XML-to-JSON libraries, and the JSON to XML direction reads the same shape back.

Is my XML uploaded anywhere?

No. The parser, formatter, minifier, and converters all run in your browser, so configuration files, invoices, and API payloads never leave your device.