XML Formatter
Beautify, minify and validate XML, and convert XML ↔ JSON.
Your XML is parsed and formatted locally in your browser and nothing is uploaded to a server.
Working with JSON too? Try the JSON Formatter.
About XML Formatter
This xml formatter beautifies, minifies and validates XML and converts between XML and JSON, all processed locally in your browser. Paste a document and pretty-print it with clean two-space indentation, collapse it to a single minified line, or use the built-in xml validator to confirm it is well-formed with the exact line and column of the first problem. The XML to JSON mode keeps attributes distinct using an @_ prefix so they round-trip cleanly, and the JSON to XML mode rebuilds markup from an object. Attributes and comments are preserved when you reformat. It is built for developers, QA engineers and integration teams working with config files, SOAP payloads, RSS feeds and API responses who need a quick xml beautifier or to format xml online without uploading sensitive data anywhere.
Features
- Beautify XML with consistent two-space indentation
- Minify XML to a single compact line
- Validate that a document is well-formed, reporting line and column of the first error
- Convert XML to JSON, keeping attributes under an @_ prefix
- Convert JSON back to XML markup
- Preserves element attributes and comments when reformatting
- Download results as data.xml or data.json
- Runs entirely in your browser
How to use the XML Formatter
- Paste your XML (or JSON for JSON to XML) into the input box.
- Choose a mode: Beautify, Minify, Validate, XML to JSON or JSON to XML.
- Read the formatted result, validation message or converted output in the output panel.
- Copy the output or download it as data.xml or data.json.
Example
Input
<note id="1"><to>Tove</to><from>Jani</from></note>
Output
<note id="1">
<to>Tove</to>
<from>Jani</from>
</note>
Beautify mode adds two-space indentation while keeping the id attribute.
Common errors & troubleshooting
- Validation fails with a line and column reference. — Jump to that position and fix the mismatched or unclosed tag; the document must be well-formed before it can be beautified or converted.
- Attributes vanish or look odd after XML to JSON. — Attributes are intentionally kept with an @_ prefix (e.g. @_id) so they stay distinct from child elements; this is expected and lets them round-trip.
- JSON to XML produces unexpected nesting. — Ensure your JSON has a single root key and uses @_ prefixed keys for attributes, mirroring the XML to JSON output shape.
- Beautify rejects an HTML snippet. — This tool expects well-formed XML, so void HTML tags and unquoted attributes will fail; use the HTML formatter for HTML instead.
Frequently asked questions
- What is the XML Formatter used for?
- The XML Formatter beautifies, minifies and validates XML and converts between XML and JSON, so you can clean up config files, SOAP payloads, RSS feeds or API responses in one place.
- How do I convert XML to JSON with the XML Formatter?
- Switch to XML to JSON mode and paste your document. Attributes are kept with an @_ prefix (for example @_id) so they round-trip distinctly from child elements when you convert back to XML.
- What does the Validate mode check?
- It checks that the document is well-formed, meaning matching tags and valid nesting, and reports the line and column of the first problem it finds.
- Does the XML Formatter preserve comments and attributes?
- Yes. Both element attributes and comments are preserved when you beautify or minify the document.
- Can the XML Formatter convert JSON back into XML?
- Yes. Switch to JSON to XML mode and paste a JSON object to rebuild XML markup from it, using @_ prefixed keys for any attributes.
- Is my XML uploaded anywhere when I use the XML Formatter?
- No. The XML Formatter runs entirely in your browser, so your data never leaves your device.
Related tools
- JSON Formatter — Beautify, minify and validate JSON with error locations.
- HTML Formatter — Beautify or minify HTML, format inline CSS/JS, and preview the result.
- CSS / SCSS Formatter — Beautify or minify CSS/SCSS/LESS, sort properties and remove duplicates.
- JS / TS Formatter — Beautify or minify JavaScript, TypeScript and JSX/TSX with Prettier options.
- SQL Formatter — Format SQL for MySQL, PostgreSQL, SQL Server, SQLite, BigQuery and Oracle.
- YAML ↔ JSON — Convert YAML to JSON and back.
- JSON to CSV — Convert an array of flat JSON objects to CSV.
- GraphQL Formatter — Format or minify GraphQL queries and schemas, validate syntax and extract operations.
All ArrayKit tools