Data

XML Formatter

Paste XML and DevKitLab re-indents it into a clean tree, then checks whether the document is well-formed and reports the first error with line and column. It works on API responses, SOAP envelopes, SVG, RSS and Atom feeds, sitemaps, Android and Maven configuration, and any other XML you need to read. Choose two spaces, four spaces, or tabs, fold long elements, copy a one-line minified version for logs and messages, or upload and download files. Everything runs in your browser — no XML leaves your device.

  • Pretty print arbitrary XML into a clearly indented tree with element folding and syntax highlighting
  • Indent width supports two spaces, four spaces, or tabs to match your project convention
  • Minify to a single line that drops whitespace between tags for logs, messages, and storage
  • Well-formedness check reports the first error with line and column so you can jump straight to it
  • Comments, CDATA sections, processing instructions, and the XML declaration are preserved
  • Upload .xml, .svg, .rss, or .xsl files and download the formatted result for your toolchain
  • One-click copy for the formatted output or the minified single line
  • Local-only processing — your XML, endpoints, tokens, and sample values never leave the browser
tools/XML Formatter
Waiting for input
XML commands

Overview

This XML tool re-indents documents into a readable tree, validates well-formedness, and offers a single-line minified mode. It fits reading API responses, inspecting SOAP, tidying SVG and feeds, and reviewing configuration files.

  1. 01

    Pretty print and indent

    Collapsed or single-line XML is expanded into a nested tree with consistent indentation, so elements, attributes, and text content are easy to scan.

  2. 02

    Well-formedness check

    The browser XML parser checks the document and the status badge reports the first error with line and column, so unclosed tags or mismatched names are quick to find.

  3. 03

    Minified single line

    Copy minified collapses the document into one line and drops whitespace between tags, which suits log fields, XML messages, and storage that prefers compact XML.

  4. 04

    Element folding

    Fold and unfold elements to collapse long sections, so you can focus on one part of a deep document without losing the overall structure.

  5. 05

    Preserves special nodes

    Comments, CDATA sections, processing instructions, the XML declaration, and DOCTYPE are kept as written rather than dropped during formatting.

  6. 06

    Indent width options

    Switch between two spaces, four spaces, or tabs to match your repository style, and the document re-indents immediately when you change the option.

  7. 07

    File upload and download

    Read local .xml, .svg, .rss, or .xsl files, format them, and download the result so the workflow fits with editors and version control.

  8. 08

    Local-only processing

    Formatting, validation, minifying, file upload, and download all run in the browser tab. Your XML, endpoints, tokens, and sample values never reach a server.

How to use

A typical flow: paste the XML, pick an indent width, read the formatted tree, then copy the formatted or minified version.

  1. 01

    Paste your XML into the editor, or click upload to read a local .xml, .svg, .rss, or .xsl file. Pasting formats it automatically.

  2. 02

    Pick the indent width at the bottom — two spaces, four spaces, or a tab — to match your project style.

  3. 03

    Read the formatted tree. Fold long elements with the gutter arrows or the collapse and expand buttons to focus on one section.

  4. 04

    Check the status badge. If the document is not well-formed, it shows the line and column of the first error; click it to jump there.

  5. 05

    Fix unclosed tags, mismatched names, or stray characters in the editor, and the badge updates as the document becomes well-formed.

  6. 06

    Copy formatted when you need readability, copy minified when you need a compact single line, or click download to save an .xml file.

  7. 07

    To iterate further, edit the XML directly in the editor and the tool keeps reformatting with the current indent option.

Details

These features cover the most common XML formatting needs: unreadable single-line documents, the need for both compact and readable forms, locating the first parse error, and safely handling private messages.

  • Pretty print arbitrary XML into a clearly indented, foldable tree with syntax highlighting.
  • Indent width supports two spaces, four spaces, or tabs, applied as soon as you switch.
  • Minify collapses the document to a single line and removes whitespace between tags.
  • Well-formedness check reports the first error with a line and column you can click to reach.
  • Comments, CDATA, processing instructions, and the XML declaration survive formatting.
  • Element folding collapses long sections so deep documents stay manageable.
  • Upload .xml, .svg, .rss, or .xsl files and download the formatted output for your toolchain.
  • Copy the formatted output for review, or copy a single-line minified version for logs and messages.
  • All processing stays in the browser — XML, endpoints, tokens, and sample values are never uploaded.

Use cases

This page fits any moment you need XML to be more readable, more compact, easier to review, or quick to validate before using it elsewhere.

  1. Reading API responses

    Expand a single-line XML response from a REST or SOAP endpoint so you can walk through elements, attributes, and nested values during inspection.

  2. Inspecting SOAP envelopes

    Format a SOAP request or response captured from a proxy or log, then read the header and body structure to find a missing or malformed element.

  3. Tidying SVG markup

    Indent SVG exported from a design tool to inspect paths, groups, and attributes, or minify it to a single line before embedding in HTML or CSS.

  4. Inspecting RSS and Atom feeds

    Pretty print a feed to check item titles, links, and dates, or validate that the feed stays well-formed after you generate or edit it.

  5. Reviewing config files

    Reformat pom.xml, web.xml, Android layouts, or other configuration so reviewers can read the element tree and spot changes more easily.

  6. Cleaning XML from logs

    Single-line XML pulled from application logs becomes a readable tree here, so you can confirm what a service actually sent or received.

  7. Preparing teaching examples

    Format XML samples for articles, course notes, and slides so the markup reads consistently and learners can follow the nesting.

  8. AI assistant output cleanup

    Reformat XML generated by an AI assistant to lock in stable indentation and confirm it is well-formed before using it in a real system.

See also

If the message you are working with is JSON rather than XML, hand it to JSON Formatter for structure, folding, and error positioning. When you need to move between formats, for example turning JSON into XML or the reverse, use JSON Converter for format-specific conversion. If the XML is wrapped in log prefixes or repeated boilerplate, run Text Replace first to strip the outer text, then come back here to reformat.

A few reminders about XML formatting

Formatting only changes readability, not meaning. The points below are the ones most often misunderstood when reformatting XML.

  1. Formatting preserves the data

    The tool adjusts whitespace, line breaks, and indentation between nodes. Element names, attributes, and text content stay the same, and the parsed document should be equivalent before and after.

  2. Whitespace can be significant

    In mixed content and in elements where whitespace matters, indentation and minification change the literal text. When whitespace inside an element is meaningful, review the result rather than reformatting blindly.

  3. Well-formed is not the same as valid

    This tool checks that tags are balanced and properly nested. It does not check the document against a DTD or XML Schema, so a well-formed document can still be invalid against a schema.

  4. Entities and encoding

    Characters like the ampersand and angle brackets must be escaped as entities in XML. The formatter does not unescape or re-escape your content; it keeps the entities you provide.

  5. Not an XSLT or XPath engine

    The page reformats and validates XML structure. It does not run XSLT transforms, evaluate XPath, or resolve external references and includes.

  6. No network or schema fetching

    The tool never fetches a DTD, schema, or namespace URL. Everything is treated as local text, so external declarations are not resolved.

Best practices

The deeper the nesting and the longer the document, the more a stable format helps. These habits cut review noise and avoid subtle data changes.

  • Agree on an indent width for the team so XML formatting does not become a recurring review topic.
  • Use four spaces for deeply nested documents like layouts and SOAP envelopes; two spaces keeps shorter config files compact.
  • Fold long elements to review one section at a time instead of scrolling through the whole tree.
  • When inspecting an API, format the response first, then decide whether the issue is a missing element, a wrong namespace, or bad data.
  • Use minified output when embedding XML in logs, messages, or storage, but review it when whitespace inside elements is meaningful.
  • Treat a well-formedness pass as a structure check only; validate against a schema separately when correctness matters.
  • Sanitize private XML before pasting. The tool stays local, but the output you copy can land in tickets, chats, docs, or screenshots.

Limitations

This tool handles XML layout, indentation, minification, and well-formedness. It does not replace schema validators, XSLT processors, or XPath engines.

  • It does not validate against a DTD or XML Schema. Well-formedness only confirms that tags are balanced and properly nested.
  • It does not run XSLT transforms or evaluate XPath. Use a dedicated processor for transformation and querying.
  • It does not resolve external entities, includes, or namespace URLs; everything is treated as local text and nothing is fetched.
  • It does not unescape or re-escape content. Entities such as the ampersand or angle brackets are kept exactly as you provide them.
  • It does not repair broken XML automatically. The error position points you to the problem, but the fix is yours to make.
  • Processing stays local, but local security still depends on your device, browser extensions, screen sharing, and copy destinations.

FAQ

Common questions about indentation, minification, validation, special nodes, file size, and privacy.

Does my XML get uploaded to a server?

No. Formatting, validation, minifying, file upload, copy, and download all run inside the browser tab. DevKitLab never sends your XML or endpoints to a server.

Does it validate against a schema?

No. It checks well-formedness — that tags are balanced and properly nested — using the browser XML parser. It does not validate against a DTD or XML Schema, so a well-formed document can still fail schema validation elsewhere.

What does minified mode do?

Copy minified collapses the document into a single line and removes whitespace between tags. It suits log fields, XML messages, and storage; review it first when whitespace inside an element is meaningful.

Are comments and CDATA preserved?

Yes. Comments, CDATA sections, processing instructions, the XML declaration, and DOCTYPE are kept during formatting rather than stripped.

Why does it say the document is not well-formed?

The parser found a structural problem such as an unclosed tag, a mismatched closing name, an unescaped ampersand or angle bracket, or more than one root element. The badge shows the line and column of the first error so you can jump to it.

Will formatting change my data?

Formatting only adjusts whitespace, line breaks, and indentation between nodes; element names, attributes, and text content stay the same. The exception is whitespace inside elements where it is significant, which indentation and minification can change — review those cases.

Can it pretty print SVG, RSS, or SOAP?

Yes. SVG, RSS and Atom feeds, SOAP envelopes, sitemaps, and most configuration XML are all just XML, so they format and validate the same way.

Does it run XSLT or XPath?

No. The tool reformats and validates XML structure only. Transforming with XSLT or querying with XPath needs a dedicated processor.

Can it handle very large XML files?

Documents in the hundreds of KB to a few MB work fine. Very large files (tens of MB) can slow the browser, so split them first or process in batches.

Related tools

Continue the data workflow inside DevKitLab: format JSON messages, convert between data formats, or jump to a related text tool.