XML formatter & converter. Parsed on your device.
Files never leave your browser, nothing is uploaded.
XML → JSON maps attributes to "@name" keys, element text to
"#text", and repeated siblings to arrays. JSON → XML reads JSON from the
input pane and wraps it in the root element name above (a single-key object becomes the root itself).
Format, convert and check, without a server round-trip
This XML formatter uses your browser's own XML parser, so it reports the exact line and column of a syntax error the way a compiler would, and it never sends your document anywhere. Beautify pretty-prints with 2-space, 4-space or tab indentation; minify collapses everything to one compact line; validate confirms well-formedness and counts the elements. Conversion is lossless-in-spirit: XML → JSON keeps attributes (as @-prefixed keys), text nodes, CDATA and repeated siblings as arrays, while JSON → XML rebuilds a document under a root element you name. No account, nothing uploaded, free forever.
How to use the XML Formatter & Converter
This tool formats, minifies and validates XML with your browser's own XML parser, and converts XML to JSON or JSON to XML. When the XML is malformed it shows the line and column of the error with a caret under the spot. It is for developers, integrators and anyone working with feeds, configs, sitemaps or API payloads.
Step by step
-
Add your XML or JSON
Paste into Input (XML or JSON), or use Load file to pick or drop an .xml or .json file of up to 15 MB. A loaded XML file is beautified at once and a JSON file is converted to XML. The page opens with a sample library document already formatted; press Sample to bring it back at any time.
-
Choose an action
Beautify indents the XML, Minify puts it on one line, and Validate checks it and shows a formatted copy. XML → JSON converts the input to JSON, and JSON → XML reads JSON from the input and builds XML. The result appears in Result.
-
Set the options
Pick Indent: 2 spaces, 4 spaces or tab, and Declaration: auto, always or never. Tick or untick Self-close empty tags, Keep comments, Sort attributes and Coerce numbers/booleans. For JSON → XML, the box after the checkboxes sets the root element name (root by default). Changing an option reruns the last conversion.
-
Fix errors
If the input is not well formed, Result shows the parser's message, the line and column, and the lines around it with a caret under the problem. Edit the input and run the action again.
-
Use the result
Press Copy to copy the result, or Download to save it as formatted.xml or converted.json. Swap moves the result into the input for a second pass, and Clear empties both panes.
Reading the result
- The status line beside the Result heading summarizes the last action, for example Beautified · 15 elements and the size for the sample. While you type it also reports Valid XML, Valid JSON or the error line, without changing the result.
- In XML → JSON, attributes become keys starting with @, element text becomes #text, repeated sibling elements become an array, and an empty element becomes null. The whole document sits under a key named after the root element.
- In JSON → XML, an object with a single key becomes the root element itself, unless that key holds an array; anything else is wrapped in the root element name you set. Arrays turn into repeated elements, and keys that are not valid XML names have the bad characters replaced with underscores.
Tips and common mistakes
- Beautify and Minify trim and collapse runs of whitespace inside text, while CDATA sections stay as they are. Do not run documents where exact spacing in text matters through them.
- Coerce numbers/booleans turns 24.50 into 24.5 and 02134 into 2134. Untick it before XML → JSON when codes, prices or IDs must keep their exact text.
- Declaration: auto keeps a declaration only if your input had one. Any declaration the tool writes says version 1.0 and UTF-8, whatever the original said, and for JSON → XML only Declaration: always adds one.
- After Minify, changing an option produces beautified output. Press Minify again if you want the one line version.
- Inside the input box, the Tab key inserts two spaces instead of moving focus.
Privacy and limits
Parsing and conversion run in your browser and nothing is uploaded or saved. Loaded files are read on your device; the 15 MB cap applies to files, while pasted text is limited only by your browser's memory.
Everything an XML tool should do.
- Beautify XML with 2-space, 4-space or tab indentation, and control whether the
<?xml?>declaration is kept. - Minify XML to a single compact line for production payloads.
- Validate XML and jump straight to the exact error line and column, shown with a caret under the offending character.
- Convert XML → JSON with attributes mapped to
@namekeys, text to#text, and repeated siblings collapsed into arrays. - Convert JSON → XML by wrapping your JSON under a named root, with optional number/boolean coercion, attribute sorting and self-closing empty tags.
- Drop or paste any file up to 15 MB, plus live validation as you type and one-click copy, download or swap-into-input. Nothing is uploaded.
Frequently asked questions.
Is the XML Formatter free?
Is it private? Are my files uploaded anywhere?
Does it work offline?
How does XML → JSON handle attributes and repeated tags?
@name keys, an element's text becomes a #text key, and repeated sibling elements are collapsed into a JSON array so nothing is lost. With Coerce numbers/booleans on, values like "42" and "true" become real numbers and booleans.Why does it show a line and column for errors?
^) under the exact character, so you can fix malformed XML the same way you would read a compiler error, without guessing.How big a file can I paste or drop?
Published · Last updated .