OneTools Online

XML Formatter

XML Input

Choose an operation

Output

Free Online XML Formatter - Beautify, Minify, Validate and Convert XML

An online XML workbench with five operations: beautify with tabs or 2/3/4-space indentation, minify, validate with the line the parser stopped on, draw the document as a collapsible tree, and convert XML to JSON, XSD, DTD or class objects in 18 programming languages. Every operation runs in your browser, so the document you paste is never uploaded.

How to Use

  1. Paste your XML, or open a file

    Type or paste into the input box, or open a local .xml file from your machine. The file is read in the browser and never uploaded.

  2. Pick an operation

    Choose format, minify, tree view, validate or Data to Class. Format offers tabs or 2/3/4 spaces; Data to Class offers 22 targets, from JSON and XSD to class definitions in 18 languages.

  3. Run it, then copy, print or save

    Press the button to run the operation. The result appears on the right, where you can copy it, print it, or save it as a .xml file, a source file, or a PNG in tree view.

XML Format / Beautify

Reformat cramped or machine-generated XML into readable, consistently indented markup. Pick tabs or 2, 3 or 4 spaces; attribute order, comments and the XML declaration are preserved. One-click copy, print, or save the result as a .xml file.
Indentation
2 spaces
3 spaces
4 spaces
One-click copy formatted content
Print formatted content
Save formatted content as .xml

XML Minifier / Compactor

Collapse the whitespace between tags to produce a compact document, which cuts payload size for SOAP bodies, config files and sitemaps. Whitespace inside text content is left alone, so element values survive the trip intact.
One-click copy compact content
Print compact content
Save compact content as .xml

XML Validator (Check XML Syntax)

Check that a document is well-formed XML: tags closed and properly nested, attributes quoted, no illegal characters. When something is wrong the report names the line and column the parser stopped at, and the full input is reprinted with line numbers and the offending line marked.

XML Tree View

Draw the document as a collapsible tree, one node per element, with attributes and text values on the leaves. Click any node to fold or unfold its children. The whole tree can be saved as a PNG, sent to the printer, or copied to the clipboard as an image.
Inspect deeply nested structures at a glance
Fold branches to focus on one subtree
Export the tree as a PNG for documentation

Data to Class (Turn XML into Class Objects)

Supported XML conversion types:
XML to JSON
XML to JSON Schema
XML to DTD
XML to XSD
XML to Java
XML to Python
XML to Objective-C
XML to Swift
XML to C#
XML to Go
XML to Rust
XML to Crystal
XML to C++
XML to TypeScript
XML to JavaScript PropTypes
XML to Flow
XML to Kotlin
XML to Elm
XML to Ruby
XML to Dart
XML to Pike
XML to Haskell
One-click copy the generated code
Print the generated code
Save the generated code to a source file

Other Features

Converts to JSON, JSON Schema, DTD, XSD and class definitions in 18 programming languages including Java, C#, TypeScript, Go, Rust and Swift. The generated schemas are a starting point, not a finished contract: some targets type every scalar as a string, and the JSON Schema output marks every field as required, so review the result before you rely on it. Everything runs client-side, free and without a conversion limit.

Frequently Asked Questions

Why does my XML fail validation when it looks correct?
Well-formedness is strict. A single unclosed tag, a missing end tag, an unescaped ampersand or a bare angle bracket inside text will stop the parser. Attribute values must be quoted, even when they are numbers. The validator reports the line and column where parsing stopped, which is usually just after the real mistake.
Is my XML uploaded to a server?
No. Formatting, minifying, validating, tree rendering and every conversion run as JavaScript in your browser. The document never leaves your machine, so this tool is safe for configuration files and payloads that contain internal data.
What is the tree view for?
It draws the element hierarchy as a diagram instead of text. Deeply nested configuration or SOAP responses are much easier to read this way, and folding a branch lets you ignore everything except the subtree you care about. The diagram can be saved as a PNG, printed, or copied as an image.
Can I generate a schema or a class from my XML?
Yes. Data to Class reads the structure of your document and emits XSD, DTD, JSON Schema, or a class definition in one of 18 languages. Element names become class and field names, and nested elements become nested types. Treat the output as a first draft: naming conventions and nullability are guesses, and the Ruby, Dart and Haskell targets type every value as a string.