XML formatter and validator
Paste XML to check it, tidy it or squeeze it. Ctrl+C copies the result.
PrivateNo uploadsRuns in your browserPretty print puts each tag on its own line. Short empty tags turns <a></a> into <a/>.
Need JSON instead? Convert XML to JSON

For readable files
Long files, easy on the eyes.
Big file. Anand opens a feed from a partner.
BeforeOne giant block of tags
With sdevTags lined up and easy to follow

Easy to follow
Each tag lines up so the team can read it.

Deal done
The partner feed goes live that week.
How to format and check XML
Paste or open
Paste XML into the Input pane, press Open to pick an .xml file, or drop it on the pane. Sample loads a small shop price list.
Pick the style
Pretty print indents each level with the indent you choose; Minify puts it all on one line. Choose short empty tags and whether to keep comments. Mistakes show their line and column.
Copy or download
Press Copy, or Ctrl+C with nothing selected, to copy the result. Download saves it as an .xml file.
Good to know
- Mixed text and tags, such as a sentence with a bold word, gets each piece on its own line when pretty printed. Use Minify or xml:space="preserve" to keep such text exactly.
- Files over 2 MB stay out of the editor; a worker reads them from disk so the page does not freeze. Only the first 1 MB of the result is drawn, Copy and Download use all of it.
- The header line, such as <?xml version="1.0"?>, and a DOCTYPE with its entity list are kept at the top.
- Entities such as & stay as they are; nothing is decoded or encoded.
Where people use it
Read a long XML reply
Turn one long line of XML into neat, indented tags you can follow.
Find a missing tag
See the exact line where a tag is not closed or a quote is missing.
Shrink before sending
Minify XML to save space in a request or a file upload.
Turn it into JSON
Once it is clean, convert the XML to JSON.
XML to JSON and JSON to XML converter
Why this one
It handles big XML files in the browser and points you to the problem line.
- Pretty print and minify on one page.
- Clear error lines when the XML is broken.
- Large files work in your browser, with no upload.
What you can change
- Pretty print or minify
- Indent 2 spaces, 4 spaces or tab
- Short empty tags
People find this page by searching
- xml formatter
- xml beautifier
- xml validator
- format xml online
- xml pretty print
- xml minify
- xml viewer
- check xml syntax
Cite this tool
- APA
sdev.in. (n.d.). XML formatter and validator [Web tool]. https://www.sdev.in/tools/xml-formatter
- MLA
"XML formatter and validator." sdev.in, https://www.sdev.in/tools/xml-formatter.
- Chicago
sdev.in. "XML formatter and validator." https://www.sdev.in/tools/xml-formatter.
- BibTeX
@misc{sdev-xml-formatter, title = {XML formatter and validator}, author = {{sdev.in}}, howpublished = {\url{https://www.sdev.in/tools/xml-formatter}}, note = {Web tool} }
Questions people ask
What does Pretty print change?
It puts each element on its own line and indents it by its depth. An element that holds only text stays on one line, like <name>Ravi</name>. Text, attribute values, comments and CDATA sections are kept as they are.
What does Minify remove?
Only the spaces and line breaks between tags, extra spaces inside tags and, if you untick Keep comments, the comments. Text inside elements is never changed.
Why does it say my XML is invalid?
Every tag must be closed, tags must close in the right order, attribute values need quotes and there must be one outer element. The error names the line and column; Go to error jumps there.
Can I keep spacing inside an element exactly?
Yes. Give the element xml:space="preserve" and it is copied exactly as written, with everything inside it.
Is my file uploaded?
No. Checking and formatting run in a background worker inside your browser. Nothing is sent to a server.