XML Formatter
A free XML formatter that beautifies or minifies XML, checks that it is well-formed with the line and column of any error, shows a tree, runs XPath and converts XML to JSON and back. Nothing leaves your browser.
- Free, no sign-up
- Well-formed check
- Tree view and XPath
- XML and JSON both ways
- Nothing uploaded
People also use
How to use the XML formatter online in three steps
Paste XML in the left box, or press Open file, and the formatted result appears on the right as you type. If the XML has a mistake, you see the line, the column and a small marker under the spot instead. Above the boxes, a green Well-formed XML note shows the root element, the number of elements and attributes, the nesting depth and the namespace.
Pick a Mode at the top: Format, Minify, Tree view, XML to JSON or JSON to XML. Below the result sit the settings for that mode and an XPath box that runs a query against your document.
Everything happens in your browser, with its own built-in XML parser. Your XML is not uploaded, so this xml formatter online works the same for a small RSS feed and for a private config file.
- 1
Paste or open XML
Paste XML into the XML input box, or press Open file to load an .xml, .svg, .rss, .kml, .gpx, .plist, .config or similar file. Clear empties the box.
- 2
Choose a mode and settings
Pick Format, Minify, Tree view, XML to JSON or JSON to XML, then set the indent, attribute and comment options shown for that mode.
- 3
Copy or download
Press Copy to put the result on your clipboard, or Download to save formatted.xml, minified.xml or converted.json.
The XML formatter remembers your mode and settings in this browser for next time. The XML you paste is never saved.
XML formatter and validator: well-formed, not schema
This page is an xml formatter and validator in one, but it is worth being exact about what validator means here. It checks that your XML is well-formed: every tag is closed, tags are nested in the right order, attribute values are in quotes, there is one root element, and characters such as & and < are written as entities like & and <.
It does not check your XML against a schema. XSD and DTD validation, which asks whether the right elements appear in the right places with the right types, is not something this XML formatter does. A document can be well-formed and still be rejected by a system that expects a certain schema.
When the XML is not well-formed, the result box shows the message from the browser's parser, such as a mismatched tag or an unescaped character, with the line and column. Under the input you see that line with a ^ marker under the column, so you can find the spot quickly in a long file.
| Message | Typical cause | Fix |
|---|---|---|
| Opening and ending tag mismatch | <b> closed with </B> or tags closed in the wrong order | XML is case-sensitive; close the inner tag first |
| Unescaped & | AT&T or a URL with ?a=1&b=2 in text | Write & instead of & |
| Extra content at the end | Two root elements next to each other | Wrap everything in one root element |
| Attribute without quotes | <item id=5> | Write id="5" or id='5' |
| Premature end of data | A tag left open at the end of the file | Add the missing closing tag |
XML beautifier online: what Format mode does
Format mode is the xml beautifier online that most people come for. It reads your document, drops the whitespace-only gaps between tags and writes it again with one element per line and clean indentation. Choose 2 spaces, 4 spaces or Tab under Indent.
Elements with a single text value stay on one line, like <title>Notes</title>. Comments, CDATA sections, processing instructions and the doctype are written back in place. The <?xml?> declaration is kept as it was, or added as version 1.0 with UTF-8 when the input has none, as long as Keep or add the <?xml?> declaration is ticked.
XML pretty print online: tags, attributes and comments
Most of the time you just want the XML formatter to make a document that arrived as one long line readable. That is what xml pretty print online is about, and the Tags and attributes card lets you match the house style of your project:
| Setting | Default | What it does |
|---|---|---|
| Sort attributes A–Z | Off | Writes attributes in alphabetical order; xmlns declarations stay first |
| One attribute per line when more than | never, 1 to 5 | Elements with more attributes than the number put each attribute on its own line |
| Empty tags as <tag/> | On | Writes <tags/> for empty elements; off writes <tags></tags> |
| Keep or add the <?xml?> declaration | On | Keeps the original declaration or adds a standard one |
| Keep comments | On | Off removes every <!-- comment --> |
Some XML must not be re-indented. In an element that mixes text and tags, such as <p>Hello <b>world</b>!</p> in XHTML or DocBook, adding line breaks would change the text. In those elements, and in any element with xml:space="preserve", the content is written back exactly as it was. Only the surrounding structure is formatted.
XML minifier online: the whole document on one line
Minify does the opposite of Format. It removes the whitespace-only text between tags and returns the whole document on one line, which is handy for API requests, test data and embedding XML in a string. This xml minifier online keeps the declaration, keeps whitespace inside elements marked xml:space="preserve", and removes comments if you untick Keep comments.
Text with real content is left alone, so a minified file still holds the same data, and the XML formatter can expand it again at any time. Press Download to save it as minified.xml.
XML viewer online: the collapsible Tree view
Tree view turns the document into a collapsible outline. Each element shows its name, up to six attributes and, for elements without children, the first part of its text. The first two levels open by default; click an element to open or close it, and a closed element shows how many children it has.
This makes the page a handy xml viewer online for large feeds, sitemaps and exports, where scrolling through thousands of lines of text is slow. The XPath box still works in this mode, so you can browse and query side by side.
XML to JSON converter, and JSON to XML
Choose XML to JSON and the result becomes JSON, using the indent you pick. The rules are simple and predictable:
- The root element becomes the single top-level key.
- Attributes become keys starting with @, for example "@id": "bk101".
- An element with only text becomes a plain string value.
- Text next to attributes or child elements goes into a "#text" key.
- Elements that repeat under the same parent become an array.
- All values are strings; numbers and true or false are not guessed.
JSON to XML reads the same layout back. Paste a JSON object with one top-level key, and that key becomes the root element; keys starting with @ become attributes, "#text" becomes text and arrays become repeated elements. Keys that are not valid XML names are written as <item>. As an xml to json converter it runs fully in the browser, and the result downloads as converted.json.
Need the data in a table instead? Convert to JSON here, then use JSON to CSV, or go the other way with CSV to JSON. To tidy the JSON itself, open the JSON Formatter.
XPath tester online: run XPath 1.0 queries
The XPath box runs an XPath 1.0 expression against the document and lists the matches below it. Elements are shown as XML, attributes as name="value" and text nodes as plain text, up to 500 matches. Expressions such as count(//book) return a number, a string or a boolean instead.
Use it as an xpath tester online before you put an expression into code. The sample starts with //book[price > 20]/title/text(), which returns the titles of books priced above 20. If the root has a default namespace (xmlns="…"), plain names will not match; use the prefix d: instead, as in //d:item. Prefixes declared on the root element, such as xmlns:g, work as written.
| Expression | Returns |
|---|---|
| //book | Every book element anywhere |
| /catalog/book[1]/title | The title of the first book |
| //book/@id | The id attribute of every book |
| //price[@currency='EUR'] | Prices with a given attribute value |
| count(//book) | The number of books, as a number |
| //d:loc | loc elements in a document with a default namespace, such as a sitemap |
Open SVG, RSS, KML, GPX, plist and config files
Open file reads the file in your browser and puts its text in the input box. It accepts the XML family as well as plain .xml: SVG graphics, XSD schemas, XSL and XSLT stylesheets, RSS and Atom feeds, KML and GPX map tracks, Apple .plist files, .config and .csproj project files, plus .json and .txt for JSON to XML. The XML formatter can format, minify, show as a tree or query any of them with XPath.
To turn a formatted SVG into an image, use SVG to PNG. To compare two versions of a config after formatting both the same way, paste them into the Diff Checker.
XML validator online: will this file parse?
Many people use an xml validator online only to answer one question: will this file parse? The green Well-formed XML line answers it as you type, without a button. If it turns into an error, fix the spot shown and the line comes back.
Keep the limits in mind. Well-formed is not the same as valid against an XSD or DTD, and some errors are reported where the parser noticed them, which can be a line or two after the real mistake.
What people use it for
Read API responses
Turn a SOAP or REST reply that came back on one line into readable, indented XML.
Fix config files
Find the unclosed tag in a web.config, pom.xml or .csproj before a build fails.
Check feeds and sitemaps
Make sure an RSS feed or sitemap parses, then count entries with an XPath such as count(//d:url).
Clean up SVG code
Indent an exported SVG so paths and groups are easy to edit by hand.
Move data to JSON
Convert an XML export to JSON for a script or a JavaScript app, then on to a table with JSON to CSV.
Prepare test data
Minify XML for a request body, or sort attributes so two files compare cleanly in the Diff Checker.
Troubleshooting: errors, XPath and odd output
The error line looks fine
The parser reports where it noticed the problem. Look at the line above, especially for an unclosed tag or a missing quote.
Error about an & in text
XML needs & for a literal ampersand, also inside URLs. HTML named entities such as are not defined in XML; use  .
XPath finds nothing
The document probably has a default namespace. Write //d:item instead of //item.
Some text did not get indented
That element mixes text and tags or has xml:space="preserve", so its content is kept exactly on purpose.
The declaration changed or appeared
With Keep or add the <?xml?> declaration ticked, a missing declaration is added. Untick it to leave it out.
JSON to XML shows an error
Paste a JSON object, not an array or a single value, for example {"root": {"item": ["a", "b"]}}.
XML formatter free and private: it runs in your browser
This xml formatter free of charge has no account, no limit on the number of documents and no upload. Parsing, formatting, the tree, XPath and the JSON conversion all run in your browser. Opened files are read on your device and are not sent anywhere.
Only your mode and settings are stored, in this browser's local storage. Very large documents depend on your device's memory, and the Tree view shows up to 500 children per element to keep the page fast.
Frequently asked questions
How do I use the xml formatter online?
Paste your XML into the left box or press Open file. Format mode shows the indented result on the right straight away. Press Copy or Download when it looks right.
Is it an xml formatter and validator in one?
Yes. Every time the text changes it checks that the XML is well-formed and shows either the formatted result or an error with the line and column.
Does the validator check my XML against an XSD or DTD?
No. It checks well-formedness only: closed and correctly nested tags, quoted attributes, one root element and escaped special characters. Schema validation against an XSD or DTD is not done here.
Is the xml formatter free to use?
Yes, it is free, with no account and no limit on how often you use it. Nothing is uploaded, so there is no file size cap set by a server.
What does the xml beautifier online change in my file?
It changes only whitespace between tags: line breaks and indentation. Text values, attributes, comments, CDATA and the declaration keep their content.
Can I choose the indent for xml pretty print online?
Yes. Choose 2 spaces, 4 spaces or Tab under Indent. The same setting applies to XML to JSON and JSON to XML.
How do I put each attribute on its own line?
In the Tags and attributes card, set One attribute per line when more than to a number from 1 to 5. Elements with more attributes than that are split, one attribute per line.
Why was some text not re-indented?
Elements that mix text and child tags, and elements with xml:space="preserve", are kept exactly as they were, because new line breaks would change their text.
What does the xml minifier online remove?
It removes whitespace-only text between tags, and comments if Keep comments is off. Real text and whitespace inside xml:space="preserve" elements stay.
Can I use this as an xml viewer online for big files?
Yes. Tree view shows the document as a collapsible outline with element names, attributes and short text values. Very large files depend on your device's memory.
How does the xml to json converter handle attributes?
Attributes become keys starting with @, text next to them becomes #text, and repeated elements become arrays. All values stay strings.
Can I convert JSON back to XML?
Yes. Choose JSON to XML and paste a JSON object. Keys with @ become attributes, #text becomes text and arrays become repeated elements.
Which XPath version does the xpath tester online support?
XPath 1.0, through the browser's own engine. Expressions can return nodes, a number, a string or a boolean, and up to 500 matches are listed.
Why does my XPath return no matches?
Most often the document has a default namespace set with xmlns. Use the prefix d: before each name, as in //d:item. Prefixes declared on the root element can be used as they are.
How is this different from an xml validator online that uses a schema?
A schema validator checks structure and data types against an XSD or DTD. This page checks well-formedness only, which is the first step any parser needs.
Where do I find the error in my XML?
The message shows the line and column, and under the input the line is printed with a ^ marker under the column. If it looks fine, check the line above it.
Which files can I open?
XML and related formats: .xml, .svg, .xsd, .xsl, .xslt, .rss, .atom, .kml, .gpx, .plist, .config and .csproj, plus .json and .txt.
Can I remove comments?
Yes. Untick Keep comments in Format or Minify mode and every comment is left out of the result.
Does it keep or add the XML declaration?
With Keep or add the <?xml?> declaration ticked, the original declaration is kept, or a standard UTF-8 version 1.0 one is added. Untick it to leave it out.
Is my XML uploaded to a server?
No. It is parsed and formatted in your browser with its built-in XML parser. Only your settings are remembered in this browser; the XML is never saved.
What do the numbers above the boxes mean?
They describe your document: the root element, how many elements and attributes it has, the deepest nesting level and the root namespace, if any.
Format your XML now
Beautify, minify, check, browse as a tree, query with XPath and convert to JSON. Free, private and done on your device.
Back to the toolLast updated October 2026 · Written and maintained by the FlipMyFormat team