Skip to content
Toolwright

XML Formatter & Converter

XML Formatter & Converter checks that XML is well-formed, with the line and column of the first problem, then formats it, shrinks it to one line or converts it to JSON and back. It checks well-formedness only, not XSD or DTD validity, and everything runs in your browser.

Tool 137 · Developer
Outside requests …How to checkRuns on this deviceWorks offline once opened

How to use XML Formatter & Converter

  1. Paste your XML, or drop a file.
  2. Choose Format, Minify, Check, XML to JSON or JSON to XML.
  3. Copy the result or download it.

Frequently asked questions

Is my XML uploaded?

No. The text is read and written in your browser. Nothing is sent anywhere.

What does Check look at?

Whether the XML is well-formed: every tag is closed in the right order, attributes are quoted and not repeated, there is one root element, and ampersands are written as entities. It tells you the line and column of the first problem. It does not check the file against a schema (XSD) or a DTD.

Does formatting change my data?

Text, attribute values, entities and CDATA are kept exactly as written. Only the space between tags is changed. When an element mixes text and tags, as in a paragraph with bold words, its content is left alone so words are never glued together or split apart.

Is it safe with files that declare entities?

Yes. Entities declared in a DOCTYPE are never expanded and external files are never loaded, so a file built to blow up memory (a "billion laughs" file) or to read your files is just shown as text.

How is XML turned into JSON?

Attributes become keys that start with @, text next to attributes or tags goes under #text, and repeated tags become a list. Empty tags become null, every value stays text (so 007 is not turned into 7), and comments are dropped. Converting back reads the same conventions.

Why does my HTML fail the check?

HTML allows things XML does not, like tags that are never closed (<br>), unquoted attributes and &nbsp;. Use an HTML tool for HTML.

Next step

Converted to JSON? Format and validate it next. Open JSON Formatter & Validator.

  1. 056

    JSON Formatter & Validator

  2. 061

    JSON to YAML Converter

  3. 138

    YAML Validator and Linter

  4. 109

    SVG Editor