Shiklo Tools
PDF40
Image20
Calculators & Converters25
Text & Writing13
Developer26
Video14
Audio14
Document14
Data & Spreadsheet12
Web & SEO9
OCR & Scanning5
Archive & File12
Security & Privacy23
Health & Medical29
QR & Barcode5

XML Formatter

Beautify, minify and validate XML with the exact line and column of any error, and convert XML to JSON. Private, runs in your browser.

Paste messy or single-line XML and get clean, indented XML you can actually read. The XML Formatter pretty prints with 2 spaces, 4 spaces or tabs, minifies XML for transport, and checks that the document is well-formed. If it is not, you see the exact line and column of the problem, such as an unclosed tag or a mismatched end tag.

It keeps comments, CDATA sections, processing instructions, the DOCTYPE and every attribute exactly as you wrote them, and it can convert the XML to JSON in one click. Everything runs in your browser: SOAP messages, configuration files and data feeds are never uploaded to a server.

How to use XML Formatter

  1. Paste your XML, open a file (.xml, .svg, .rss, .xsd, .config…) or click Sample.
  2. Choose the indent: 2 spaces, 4 spaces or Tab. The result appears as you type.
  3. Fix any error shown with its line and column, or click Minify for compact XML.
  4. Copy the result, download it, or click XML → JSON to convert it.

Features

  • Pretty print XML with 2 spaces, 4 spaces or tabs.
  • Minify XML: whitespace between tags removed, optional removal of comments.
  • Well-formedness check with the exact line and column of each error.
  • Comments, CDATA, processing instructions and DOCTYPE kept as written.
  • Elements that hold only short text stay on one line for readability.
  • XML to JSON conversion, with attributes marked by an @ prefix.
  • Collapsible tree view of elements, attributes and text.
  • Works with SVG, RSS, Atom, SOAP, XSD, XSLT, sitemaps and .config files.
  • Live formatting up to 300 KB; larger files format with one click.
  • Private: the XML never leaves your device.

What an XML formatter does

XML produced by programs is often written on a single line, with no spaces between elements, because computers do not need indentation. People do. The formatter splits the document into its parts (start tags, end tags, text, comments, CDATA and declarations) and writes each element on its own line, indented one level deeper than its parent. An element that contains nothing but a short piece of text, such as a title or a price, stays on one line so the output does not become needlessly long. Text inside elements and the values of attributes are never changed, so the formatted XML means exactly the same thing as the original.

Formatting versus minifying

Formatting is for reading, reviewing and comparing XML. Minifying is the opposite: it removes the whitespace between tags so the file is as small as possible for storage or sending over a network. Both keep the data the same.

OptionWhat changesUse it for
Format, 2 spacesOne element per line, 2-space indentReading and code review; the most common style
Format, 4 spacesOne element per line, 4-space indentTeams whose style guide asks for 4 spaces
Format, TabOne element per line, tab indentEditors where each person sets the tab width
MinifyWhitespace between tags removedSmaller files for APIs, feeds and storage
Minify, remove commentsAlso drops commentsProduction files where comments are not needed

Validating XML: common errors

Well-formed XML follows a few strict rules: every start tag has a matching end tag, elements close in the reverse order they opened, there is exactly one root element, attribute values are in quotes, and the ampersand and less-than characters in text are written as entities. The validator checks all of these and points to the line and column of the first problem. Typical messages are an unclosed tag, an end tag that does not match the open element, an attribute without quotes, a duplicate attribute, or text outside the root element. Note that this is a well-formedness check; it does not check the document against an XSD or DTD schema.

Converting XML to JSON

Click XML → JSON to turn the document into a JSON object. Each element becomes a key, repeated elements become arrays, and attributes become keys that start with @ (for example @id), so they cannot clash with child elements of the same name. Numbers and true or false values in element text are converted to JSON numbers and booleans; attribute values stay strings. The JSON can then be opened in the JSON Formatter or turned into a table with JSON to CSV.

Where XML is still used

Although JSON is now common for web APIs, XML is everywhere: SOAP web services, RSS and Atom feeds, sitemaps for search engines, SVG images, Microsoft Office files (which are zipped XML), Android layouts, Maven and .NET project files, invoices in UBL and other e-invoicing formats, and many bank and government data exchanges. A formatter makes these files readable when you need to debug or edit them by hand.

Privacy

XML files often contain private data: customer records, invoices, API responses with tokens, or internal configuration. This tool formats, validates and converts the XML entirely in your browser using JavaScript. Nothing is uploaded, logged or stored, and the page keeps working offline once it has loaded.

Frequently asked questions

Is the XML formatter free and private?

Yes. It is free with no sign-up and no usage limits, and the XML is processed only in your browser. It is never uploaded.

Does formatting change my data?

No. Only the whitespace between elements changes. Element text, attribute values, comments, CDATA sections and processing instructions are kept exactly as written.

Why does it say my XML is not valid?

The document is not well-formed. The message shows the line and column of the first problem, for example an end tag that does not match, a missing quote around an attribute value, or an ampersand that should be written as the amp entity.

Does it validate against an XSD schema?

No. It checks that the XML is well-formed (correct syntax), which catches most mistakes. Checking against an XSD or DTD schema is not included.

Can I format SVG, RSS or sitemap files?

Yes. They are XML, so you can paste them or open the file directly. The formatter accepts .xml, .svg, .rss, .atom, .xsd, .xsl and .config files.

How big can the XML be?

Files up to 300 KB are formatted live as you type. Larger files format when you click Format, and files of several megabytes take only a moment.

How are attributes shown in the JSON?

Attributes become keys with an @ prefix, such as @id or @lang, next to the child elements. Repeated elements with the same name become a JSON array.

Related tools