HelperCrate

XML Formatter

Pretty-print XML and convert between XML and JSON in your browser.

Your files never leave your device. Everything runs in your browser.

What XML Formatter does

XML Formatter pretty-prints XML, converts XML to JSON and turns JSON back into XML, all with the browser's built-in DOMParser. It is useful for reading SOAP responses, feed files, configuration exports and any other XML that arrives as one long line.

Formatting re-indents the document with two or four spaces. XML to JSON follows simple, predictable rules: element attributes become properties prefixed with @, text content becomes #text when an element also has attributes, repeated child elements become arrays, and the root element is kept as the top-level key so the document can be converted back without losing structure. Namespace declarations such as xmlns:h and namespaced names such as h:item are preserved as plain text keys.

The tool validates well-formedness only. Internal entities declared in a DOCTYPE are expanded, external DTDs and external entities are not fetched, and there is no schema validation, so it cannot tell you whether the content matches an XSD.

How to use XML Formatter

  1. Paste XML or JSON into the input box.
  2. Choose a direction: Format XML, XML → JSON or JSON → XML.
  3. Select two or four spaces for the indentation.
  4. Click Convert and check the status line; invalid XML is reported instead of a result.
  5. Use Copy or Download to save the output, or Sample to load a demo document.

Features

Tips and common mistakes

Frequently asked questions

Is my XML uploaded?

No. Parsing and conversion happen in your browser with DOMParser, so the document never leaves your device.

How are attributes represented in JSON?

Each attribute becomes a property whose name starts with @, such as @id or @xmlns:h. Element text becomes #text when the same element also has attributes.

Are XML comments preserved?

No. The formatter currently drops comments while re-indenting. Keep the original file if comments are important, and check the roadmap in the progress notes for a future option.

Can the tool follow an external DTD or fetch external entities?

No. External resources are not fetched, and an external entity reference makes the document invalid. This is also safer when opening untrusted XML, because it avoids network requests triggered by the document itself.

Does it validate against a schema?

No. It checks that the document is well-formed XML and that it can be parsed, but it does not check element order, allowed attributes or datatypes against a DTD or XSD.

What happens to namespaces?

Namespace declarations and prefixed names are kept as literal text, for example xmlns:h and h:item. Prefixes are not resolved to URIs, which is enough for most display and data-transfer use.

XML and JSON are parsed and formatted locally with DOMParser — nothing is uploaded.