XML Formatter
Reindent XML for readability or strip it down to a single line. A hand-written tokenizer splits the document into tags, text, comments, CDATA sections, processing instructions and doctype declarations, so no browser XML parser is involved. Unbalanced tags are reported as a warning; genuinely broken markup raises an error.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
Pretty-printing and minifying XML
Paste an XML document and either reindent it for reading or collapse it onto a single line. A hand-written tokenizer splits the source into tags, text, comments, CDATA sections, processing instructions and doctype declarations, and the chosen operation re-emits those tokens as text you can copy or download as formatted.xml.
When to reformat an XML document
Reach for it when a config file, SOAP response or sitemap arrives with no indentation and you need to see the hierarchy, or when you want to strip out whitespace before shipping a smaller file.
Indentation and whitespace handling
The operation picks pretty-print or minify. Indent chooses two spaces, four spaces or a tab and applies only to pretty-printing. Minify drops text nodes that are nothing but whitespace and keeps the rest verbatim, while pretty-print collapses runs of whitespace inside text to a single space.
What counts as broken markup
An unterminated tag, comment, CDATA section or processing instruction, or a stray angle bracket inside a tag name, raises an error. Mismatched or unclosed element tags are reported only as a warning, and you still get a best-effort result. Because no browser XML parser is called, the document is never schema-validated.
Formatted entirely on your device
The tokenizer and reformatter run in the browser on the text you supply, so the document is never uploaded and the formatting works offline.
Questions
Does it use the browser XML parser?
No. Tokenizing and re-emitting is done by hand in plain JavaScript, so DOMParser is never called and the input is not validated against a schema.
What counts as broken markup?
An unterminated tag, comment, CDATA or processing instruction, or a stray "<" inside a tag (for example "<a<"). These raise an error. Mismatched or unclosed element tags only produce a warning and a best-effort result.
Is whitespace inside elements preserved?
Minify drops text nodes that are only whitespace and keeps the rest verbatim. Pretty-print collapses internal runs of whitespace in text to a single space.
Related tools
See categoryJSON Formatter & Validator
Pretty-print, minify, recursively sort keys or validate JSON, with line/column errors.
HTML Entity Encode / Decode
Escape text for safe insertion into HTML, or decode named and numeric entities.
JSON to TypeScript
Generate TypeScript interfaces or type aliases from a JSON sample, with nested named types.
.env <-> JSON
Parse a .env file into JSON, or turn a JSON object into .env text. Runs entirely on your device.