XML formater
NovoUljepšajte, smanjite i potvrdite XML izravno u vašem pregledniku.
Runs entirely in your browser. Nothing is uploaded.
Free online XML formatter — beautify, minify & validate
This XML formatter instantly transforms dense or minified XML into clean, readable markup with proper indentation. Paste any XML, choose your indent style (2 spaces, 4 spaces, or Tab), and click Beautify — the result appears in the output pane in milliseconds. It works for any XML-based format: REST and SOAP API responses, RSS and Atom feeds, SVG files, Android manifests, Maven POMs, Spring config files, GPX tracks, Apple PList files and more.
The same tool can minify XML — stripping all unnecessary whitespace to produce the smallest possible document — and validate whether the document is well-formed, reporting the exact line and column of any error. Everything runs locally in your browser; your XML is never uploaded, making it safe to paste confidential data.
Configurable indentation and smart formatting
Choose from three indent styles — 2 spaces, 4 spaces or Tab — to match your project's code style. The output updates immediately when you change the setting. The beautifier correctly handles XML declarations (<?xml version="1.0"?>), self-closing tags, processing instructions, comments and mixed content.
For minification, the Minify button collapses all inter-tag whitespace to produce a single-line document — the standard form for XML sent over HTTP, embedded in databases, or stored in configuration systems where payload size matters. Formatting and minification only touch whitespace; element names, attribute values and text content are never altered.
Validate XML well-formedness instantly
Click Validate (or Beautify — both run the check) to test whether your XML is well-formed. The tool uses the browser's native DOMParser to parse your document and reports the first error with a precise location. Common problems it catches include unclosed tags, overlapping elements, multiple root nodes, unescaped ampersands, misquoted attributes and encoding mismatches.
A green Well-formed XML badge confirms the document is structurally correct. A yellow warning indicates potential issues, but the formatter still applies indentation so you can compare the output and spot the problem. This is the same XML validation the browser uses to parse XHTML and SVG.
Collapsible XML tree viewer
Click the Tree tab to switch from raw formatted text to an interactive, collapsible tree view. Each XML element appears as a row with a triangle you click to expand or collapse its subtree. Attributes are shown in blue, tag names in green, and text content in dark ink — making it easy to scan complex nested structures at a glance.
The tree viewer is especially useful for SOAP envelopes, Maven POM files, large RSS feeds, Android resource files and any deeply nested XML where scrolling through raw text is impractical. Collapsing a branch hides its entire subtree in one click, letting you focus on the sections that matter.
How this compares to Notepad++, VS Code, XMLSpy and xmllint
Notepad++ with the XML Tools plug-in and VS Code (Shift+Alt+F) both format XML but require local software installations and only work on files saved to disk. XMLSpy and oXygen XML Editor offer advanced XML editing with schema validation (XSD, DTD, RelaxNG) but cost several hundred dollars per licence annually — far more than most developers need for occasional XML formatting. xmllint on the command line is free and powerful but requires libxml2 installed and a terminal session.
This online formatter needs no installation, no licence and no account. Paste directly from your clipboard, upload a file from your device, or load a built-in sample, then copy or download the result. The tree view is a feature most desktop tools charge for that works here for free — particularly handy for exploring deep SOAP response payloads or Android manifest files during debugging.
Upload, sample and download
Use the Upload button to open an XML file from your computer — it reads the file locally and populates the input box without uploading anything to a server. Or click Sample to load a short bookstore example that shows the formatter's output for a typical XML document with attributes and nested elements.
After formatting, click Copy to put the result on your clipboard or Download to save it as an .xml file. The download preserves whatever indent style you chose and is immediately ready to open in an editor or commit to a repository.
Private, instant and free — works on iPhone, Android and desktop
There is no sign-up, no extension to install and no paid plan. Every operation — formatting, minification, validation and the tree view — runs in your browser. Your XML never leaves your device. The tool is fully responsive and works in Safari on iPhone, Chrome on Android, and all desktop browsers — handy when you need to check an API response on your phone without opening a laptop.
Bookmark this free online XML formatter for the next time you need to read a dense API response, clean up a config file, or debug a malformed document.
A brief history of XML: from SGML to JSON and beyond
XML 1.0 was published as a W3C Recommendation in February 1998, but its lineage runs back much further. Its direct parent is SGML (Standard Generalized Markup Language), an ISO standard from 1986 that defined a meta-language for describing markup systems. HTML, first proposed by Tim Berners-Lee in 1991, is itself an SGML application — a fixed vocabulary of tags (<p>, <a>, <img>) for web content. XML simplified SGML by removing its most complex features and producing a general-purpose markup language where developers define their own tag vocabularies rather than inheriting a fixed one.
Through the 2000s the "XML everywhere" era took hold: developers used XML for data exchange between systems, application configuration (Spring beans, Maven POMs, Ant build scripts), UI layout (Android XML layouts, XAML in .NET, XUL in Firefox), document formats (OpenDocument, OOXML for Microsoft Office, EPUB for ebooks), and web services (SOAP, WSDL, UDDI). The W3C extended XML into a full family of standards: XSLT for transforming XML documents, XPath for querying nodes, XSD for schema validation, XQuery for complex queries across XML datasets, and RelaxNG as a simpler alternative schema language.
After 2010, JSON displaced XML as the default format for REST API payloads because it is more compact, maps directly to JavaScript objects, and is simpler to parse in most languages. But XML never disappeared: SOAP-based enterprise services, financial data standards, healthcare interoperability (HL7, FHIR), SVG graphics, and virtually every XML-based document format remain as relevant today as they were in 2005. Understanding when to use XML versus JSON — and how to process each — remains a core skill for backend and integration developers.
XML namespaces: sharing a document without naming collisions
XML namespaces solve a fundamental problem: two XML vocabularies may independently define elements with the same name. A purchase-order schema might define an <address> element, and a shipping schema might define one too, with different child elements. The namespace mechanism lets both coexist in a single document by associating element and attribute names with a URI identifier. A namespace declaration looks like xmlns:po="http://example.com/purchaseorder" — after which every element prefixed with po: belongs to that namespace. Critically, the URI is merely a unique string identifier; it does not need to resolve to an actual web page.
A default namespace (xmlns="http://www.w3.org/2000/svg") applies to the declaring element and all its descendants without requiring a prefix on every tag. This is why SVG files declare the SVG namespace on the root <svg> element — all child elements (<path>, <rect>, <circle>) are automatically in that namespace. In contrast, inline SVG embedded directly inside HTML5 does not need the namespace declaration because the HTML parser already knows to treat elements in an <svg> context as SVG.
Namespaces appear throughout the XML ecosystem. A SOAP 1.1 envelope declares xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" so that the <soap:Envelope>, <soap:Header> and <soap:Body> wrapper elements are unambiguous even when the body payload uses its own vocabulary. RSS and Atom feeds use namespaces to mix core feed elements with extension vocabularies such as Media RSS (xmlns:media="http://search.yahoo.com/mrss/") or the Dublin Core metadata set (xmlns:dc="http://purl.org/dc/elements/1.1/"). When you open a complex feed or enterprise XML document in a tree viewer and see prefixed element names, those prefixes are namespace aliases defined at the top of the document.
XML schema validation: DTD, XSD, RelaxNG and Schematron
Being well-formed — structurally valid XML — is only the first level of correctness. Schema validation checks that a document also conforms to a specific vocabulary: the right elements in the right order with the right data types. The oldest mechanism is the DTD (Document Type Definition), inherited from SGML. A DTD declares which elements and attributes are allowed and their required sequence, but it uses a non-XML syntax and cannot express data types — it cannot specify that a price must be a decimal number rather than arbitrary text. DTDs are still used in legacy systems and for document types such as XHTML.
XML Schema (XSD) is the W3C standard that replaced DTDs for most use cases. An XSD file is itself written in XML, supports rich data types (xs:integer, xs:date, xs:anyURI), allows complex type derivation by extension or restriction, and can enforce minimum/maximum occurrence constraints. XSD underpins major real-world standards: UBL (Universal Business Language) defines e-invoicing and procurement documents used in public-sector procurement across Europe and Asia; HL7 FHIR uses XSD schemas for healthcare data interoperability; OOXML (ISO/IEC 29500) specifies the XML schemas for Microsoft Word, Excel and PowerPoint file formats. RelaxNG, an OASIS standard, offers a simpler alternative to XSD with two syntaxes — an XML form and a more compact non-XML notation — and is used in DocBook, EPUB and other document standards.
Schematron (ISO/IEC 19757-3) takes a different approach: rather than defining the structure of a document up front, it expresses business rules using XPath assertions. A Schematron rule might say "if the status element contains 'active', then the end-date element must be absent" — a constraint XSD cannot express because XSD lacks conditional logic. Enterprise XML implementations commonly layer Schematron on top of XSD: XSD handles structure and data types, Schematron handles cross-element business rules. Together they form the validation stack used in e-invoicing standards such as the European PEPPOL network.
XPath and XSLT: querying and transforming XML documents
XPath (XML Path Language) is the query language for selecting nodes within an XML document. An XPath expression navigates the document tree using axes and steps: //book selects all <book> elements anywhere in the document; /catalog/book[price>30]/title selects titles of books in a catalog whose price exceeds 30; @isbn selects an attribute named isbn. The full axis syntax includes ancestor::, child::, descendant::, following-sibling::, preceding-sibling:: and attribute::, letting you navigate in any direction through the node tree. XPath 2.0 added a rich data-type system and a function library covering string manipulation, date arithmetic and sequence operations. XPath is the foundation of both XSLT and XQuery.
XSLT (eXtensible Stylesheet Language Transformations) is a declarative language — written in XML — for transforming an XML input document into HTML, plain text, or a different XML vocabulary. An XSLT stylesheet consists of template rules (<xsl:template match="...">) that fire when the XPath match expression selects a node. XSLT was originally designed to render XML for display before CSS matured, but its most durable uses are XML-to-XML translation between different schemas (for example, converting a proprietary purchase order format to UBL), RSS-to-HTML rendering on servers without JavaScript, and document publishing pipelines where the same XML source produces both PDF and HTML output. The Saxon processor (from Saxonica) is the leading enterprise XSLT engine, supporting XSLT 3.0 — which adds streaming, higher-order functions and JSON support.
In practice, most developers today reach for XPath through a library rather than a standalone tool. Python's lxml (which wraps libxml2, the C library that also powers PHP's DOM extension, the GNOME project, and xmllint) exposes .xpath() directly on parsed elements. On the command line, XMLStarlet provides an XPath interface: xml sel -t -m "//book" -v "title" -n file.xml prints one book title per line — XMLStarlet is to XML what jq is to JSON. For one-off exploratory queries, the tree view in this formatter lets you navigate the document structure visually before writing an XPath expression, saving the round-trip of running a command-line tool.
Frequently asked questions
What is an XML formatter / beautifier?
An XML formatter (also called an XML beautifier or pretty-printer) takes densely packed or minified XML and adds consistent indentation and line breaks so the structure is human-readable. For example, <root><item>1</item></root> becomes three clearly indented lines with opening tag, indented child, and closing tag. This tool also validates that the XML is well-formed at the same time.
How should XML be formatted?
Standard XML formatting places each element on its own line with child elements indented relative to their parent — usually by 2 or 4 spaces or a tab. Attributes stay on the opening tag line. A well-formatted document also begins with an XML declaration such as <?xml version="1.0" encoding="UTF-8"?>. Paste your XML above and click Beautify to apply standard formatting instantly.
How do I format (beautify) XML?
Paste your XML into the input box, choose your preferred indent (2 spaces, 4 spaces, or Tab), then click Beautify. The formatted result appears in the output pane and the tool reports whether the document is well-formed. You can also load a sample or upload an .xml file. Once formatted, click Copy or Download to save the result.
How do I minify XML?
Click Minify after pasting your XML. Minifying strips all whitespace between tags to produce a compact single-line document — for example: <root><item>1</item><item>2</item></root>. This is useful when sending XML over a network or embedding it in configuration where every byte counts. Minification never changes element names, attribute values, or text content.
How do I validate XML?
Click Validate (or simply click Beautify — both run the check). The tool parses your XML with the browser's built-in XML parser (DOMParser) and reports whether the document is well-formed, showing error messages with the line and column of the first problem. A green badge means valid; a yellow warning means the document may have structural issues.
What makes XML well-formed?
A well-formed XML document must: (1) have exactly one root element, (2) close every opened tag — either as <item></item> or the self-closing <item/>, (3) nest tags without overlap (no <b><i>text</b></i>), (4) quote all attribute values, (5) escape special characters (& → &, < → <, > → >), and (6) declare the correct encoding. Break any rule and the XML parser will reject the document.
How do I view XML as a collapsible tree?
After formatting or pasting your XML, click the Tree tab above the output panel. Each XML element appears as a collapsible row with a triangle you click to hide or show its children. Attributes are highlighted in blue, tag names in green, and text content in black — making it easy to explore deeply nested structures like SOAP envelopes, Maven POMs, Android manifests or large RSS feeds without scrolling through hundreds of raw lines.
Why is my XML invalid?
Common causes of invalid XML: (1) unclosed tag — <item> without </item>; (2) overlapping tags — <b><i>text</b></i>; (3) multiple root elements — two top-level tags side by side; (4) unescaped ampersand — a bare & instead of &; (5) misquoted or missing attribute quotes. Click Validate for an error message pointing to the exact line and column of the first problem so you can fix it quickly.
Does Notepad++ format XML?
Yes — Notepad++ can format XML with the XML Tools plug-in (Plugins → XML Tools → Pretty print). But the plug-in requires a separate installation step and only works on Windows. XMLSpy and oXygen XML Editor also format XML but both are paid desktop applications costing hundreds of dollars per seat. This online formatter needs no installation, no licence, and works in any browser on any device — paste your XML, click Beautify, done.
How do I format an XML document in VS Code?
In VS Code, open your .xml file and press Shift+Alt+F on Windows/Linux (or Shift+Option+F on Mac) to run the built-in Format Document command. You can also right-click and choose Format Document. For quick one-off formatting without opening an editor — especially for XML copied from a browser, terminal, or API response — paste it here and click Beautify.
Does formatting change the data?
No. Beautifying or minifying XML only changes whitespace between tags — it never alters element names, attribute values, or text content. The data is identical before and after formatting. You can verify this by formatting, then minifying the result and comparing it with the original minified form.
Is it safe to format XML online?
Yes. This tool runs entirely in your browser — your XML is never sent to a server, logged, or shared with anyone. Formatting, minification, validation, and the tree view all happen locally using JavaScript. It is safe to paste confidential data such as internal API responses, config files, or proprietary documents. Other online XML formatters like Code Beautify and FreeFormatter.com send your data to their servers — this tool never does.
What is the difference between XML and JSON?
Both XML and JSON are text formats for structured data exchange. XML uses nested angle-bracket tags with optional attributes (<person age="30">Alice</person>), supports comments and namespaces, and has a rich schema ecosystem (XSD, XSLT, XPath). JSON uses key-value pairs and arrays, is more compact, and is the default for REST APIs and JavaScript. XML remains dominant in enterprise systems, SOAP services, configuration files (Maven, Android, Spring), and document formats (SVG, EPUB, OpenDocument).
Does it work offline?
Yes. Once the page has loaded, all processing runs in your browser with no further network requests — so the formatter continues to work if you go offline. This is useful when you need to format internal XML files on a machine with restricted internet access.
How does this compare to xmllint and other command-line tools?
xmllint (part of libxml2) is the standard Unix command-line XML validator and formatter — run xmllint --format file.xml to pretty-print. It requires installing libxml2, which is straightforward on Linux/Mac but less so on Windows. Python's built-in xml.dom.minidom module can also pretty-print XML from the command line. This online formatter gives you the same output instantly in any browser without installing anything — and adds a collapsible tree view that command-line tools don't provide.
Related tools
Pogledaj sve alateStatistics Calculator
Calculate mean, median, mode, standard deviation, variance and more from a data set.
Matrix Calculator
Add, subtract, multiply matrices and compute determinant, inverse and transpose for 2×2–4×4 matrices.
JSON ⇄ CSV pretvarač
Pretvorite JSON niz u CSV i CSV natrag u JSON, s ispravnim navodnicima.
SQL formater
Uljepšajte i smanjite SQL upite s ključnim riječima i prijelomima klauzula.
JSON u TypeScript
Generirajte TypeScript sučelja iz JSON uzorka, s ugniježđenim tipovima.
CSV pregledavač
Pregledajte, sortirajte i pretražujte CSV ili TSV datoteke kao čistu tablicu — u vašem pregledniku.