ToolsBlog
ToolsXML Formatter & Beautifier

XML Formatter & Beautifier

Paste or open XML to indent it with 2 spaces, 4 spaces or tabs, minify it, or check it for syntax errors with the exact line and column. Your XML is processed in your browser and never uploaded.

PrivateFreeOffline

Paste XML here, drop a file, or open one from your device.

.xml, .svg, .xsd, .xsl, .rss, .kml, .gpx, .plist and other XML text files up to 50 MB.

Press Format (or Ctrl/⌘ + Enter) to indent your XML. Syntax errors are shown here with their line and column.

Next steps

  • JSON FormatterFormat JSON the same way.
  • YAML FormatterFormat YAML the same way.
  • KML to GeoJSON ConverterXML is KML? Convert it to GeoJSON.

Quick start

  1. 1

    Paste or open your XML

    Paste XML into the editor, drop a file on it, or choose Open file. Try a sample if you just want to see how it works.

  2. 2

    Choose the indentation

    Pick 2 spaces, 4 spaces, or tabs.

  3. 3

    Press Format

    The XML is checked first. If it is malformed, the line and column of the first error are shown and the cursor jumps there.

  4. 4

    Copy or download

    Copy the result to the clipboard or download it as formatted.xml.

Data stays on your device

Parsing and formatting run in your browser. Opened files are read locally and are not uploaded.

Shortcuts

FormatCtrl/⌘ + Enter

Format XML into readable, indented elements, minify it, or check that it is well-formed. The formatter changes only whitespace between tags; text, CDATA, comments and attribute values are left exactly as they are. It checks XML syntax, not XSD or DTD schemas.

2, 4 or tab

Indentation

Line + column

Errors

In your browser

Runs

Format with your indentation

Indent with 2 spaces, 4 spaces or tabs. Formatting the result again changes nothing.

Errors with line and column

Malformed XML is reported with the line, column and a plain explanation, and the cursor jumps to it.

Your data stays the same

Text, CDATA, comments, processing instructions, namespaces and entity references are preserved exactly.

Minify

Remove whitespace between tags for a compact document without touching text values.

Private

Nothing is uploaded. The XML is parsed and formatted in your browser.

How do I beautify XML online?

Paste the XML into the editor (or open a file), choose 2 spaces, 4 spaces or tabs, and press Format. Each nested element goes on its own indented line. Copy the result or download it as formatted.xml.

Is my XML uploaded to a server?

No. Parsing and formatting run in JavaScript in your browser tab. Files you open are read locally and the XML is never sent to ChatDB.

Does the XML formatter validate my XML?

It checks that the XML is well-formed: tags are closed and nested correctly, there is one root element, attributes are quoted and not repeated, and every & starts a valid entity or character reference. It does not validate against an XSD schema or DTD, so a well-formed file can still be rejected by an application that expects particular elements.

Where is the error in my XML?

When the XML is malformed, the formatter shows the line and column of the first problem with a short explanation, for example a closing tag that does not match, and moves the cursor to it. Fix it and press Format again to find the next one.

Does formatting change my data?

Only whitespace between tags and inside tags changes. Text, attribute values, comments, CDATA sections, processing instructions, the DOCTYPE and entity references such as & are kept exactly as written. Inside elements that mix text with child elements, and under xml:space="preserve", the content is left exactly as written because its whitespace can be part of the data.

How do I minify XML?

Press Minify to remove the whitespace between tags. Whitespace inside text is data, so it is kept; a document whose text spans several lines stays on several lines.

Why does my & cause an error?

In XML a literal ampersand must be written as &. HTML names such as   are not defined in XML either: use   or declare the entity in a DOCTYPE.

How large an XML file can I format?

Files up to 50 MB can be opened. In our tests a 28 MB file with 1.5 million elements formatted in under a second in desktop Chrome; typing in the editor gets slower at that size.

Format XML: before and after

API responses, SOAP messages, sitemaps and exported config files often arrive as one long line. Format puts each nested element on its own line. Elements that hold text stay on one line, so values are not split up.

Before

<order id="42"><!-- rush --><item sku="A-1">Notebook</item><qty>2</qty><note><![CDATA[Leave at door & ring]]></note></order>

After Format (2 spaces)

<order id="42">
  <!-- rush -->
  <item sku="A-1">Notebook</item>
  <qty>2</qty>
  <note><![CDATA[Leave at door & ring]]></note>
</order>

What the formatter changes, and what it leaves alone

  • Changes: whitespace between tags, and line breaks or extra spaces between attributes inside a tag (attributes end up separated by single spaces).
  • Keeps exactly: text, attribute values and their quote style, namespace prefixes, comments, CDATA sections, processing instructions such as <?xml-stylesheet?>, the DOCTYPE, and references like &amp; or &#169;.
  • Does not reindent: elements that mix text with child elements (XHTML paragraphs, DocBook) and elements under xml:space="preserve", because adding whitespace there would change the content.

The result is the same document: apart from whitespace between tags, parsing the formatted XML gives the same elements, attributes and text as the original. Minify does the reverse and removes whitespace between tags, keeping whitespace inside text.

Fix common XML errors

Format, Minify and Check syntax all check that the XML is well-formed first. The first error is shown with its line and column. These are the messages people hit most often:

MessageHow to fix it
Expected </item> … but found </items>The closing tag must match the opening tag exactly, including case.
A bare "&" is not allowedWrite & as &amp;, or put the text in a CDATA section.
The entity "&nbsp;" is not definedXML only predefines &amp; &lt; &gt; &quot; &apos;. Use &#160; for a non-breaking space.
Only one root element is allowedWrap the elements in a single parent element.
Text is not allowed before the root elementRemove stray text, such as a log prefix or a byte-order mark pasted as text, before the first tag.
The XML declaration must be the very first thingMove <?xml version="1.0"?> to the top, or delete the second one when two files were pasted together.

Well-formed is not the same as valid

A well-formed document follows XML's syntax rules. A valid document also matches a schema (XSD) or DTD that says which elements are allowed, in what order, and with which types. This tool checks syntax only, so use your schema validator to check required fields or data types. JSON or YAML instead? Use the JSON formatter or YAML formatter.

More tools

JSON to Parquet Converter

Convert your JSON files to Parquet with ease.

Open

Markdown Editor

Edit and preview your Markdown content with real-time live preview side by side.

Open

GeoJSON Viewer

View GeoJSON files, validate map features, and continue GIS workflows.

Open

ChatDB

Free, browser-side data tools. No uploads, no accounts.

Data tools

Reader

  • Online CSV Viewer
  • Parquet Viewer & Reader
  • Excel Viewer and Editor
  • SQLite Viewer
  • Gzip CSV Reader
  • CSV Size Analyzer
  • Parquet Schema Reader
  • Parquet Metadata Reader
  • Data Profiler
  • Image Measure
  • Shapefile Viewer
  • GeoJSON Viewer

Editor

  • CSV Viewer and Editor
  • Excel Viewer and Editor
  • Online Excel Editor
  • CSV Splitter
  • Markdown Editor
  • Image Cropper
  • SVG Editor
  • Screenshot Background Creator
  • Document Scanner
  • Audio Clipper
  • Video Trim & Crop Tool

Converter

  • CSV to Gzip Converter
  • CSV to Parquet Converter
  • Excel to CSV Converter
  • Parquet to CSV Converter
  • JSON to Parquet Converter
  • Parquet to JSON Converter
  • CSV Decompressor
  • CSV to JSON Converter
  • CSV to Markdown Table
  • Image Converter
  • KML to GeoJSON Converter
  • GPX to GeoJSON Converter
  • GeoJSON to KML Converter
  • Shapefile to GeoJSON Converter

Formatter

  • CSV Encoder
  • SQL Formatter
  • JSON Formatter
  • XML Formatter
  • YAML Formatter
  • Dataset README Generator
  • URL Encoder & Decoder
  • Regex Tester

Compressor

  • CSV Compressor
  • CSV to Gzip Converter
  • CSV Decompressor
  • Image Compressor

AI

  • Parquet AI
  • CSV AI
  • Color Palette Generator
  • Extract Image Colors

GIS

  • Lat/Lng Point Finder
  • KML to GeoJSON Converter
  • GPX to GeoJSON Converter
  • GeoJSON to KML Converter
  • Shapefile to GeoJSON Converter
  • Shapefile Viewer
  • GeoJSON Viewer

Image tools

Convert To

  • Convert to JPEG
  • Convert to PNG
  • Convert to WEBP
  • Convert to GIF
  • Convert to BMP
  • Convert to TIFF
  • Convert to ICO
  • Convert to AVIF
  • Convert to FF
  • Convert to HDR
  • Convert to EXR
  • Convert to QOI
  • Convert to TGA
  • Convert to PNM

Edit

  • Image Cropper
  • SVG Editor
  • Screenshot Background Creator
  • Document Scanner

Compress

  • Compress JPG
  • Compress JPEG
  • Compress PNG
  • Compress WEBP
  • Compress GIF

Company

  • All tools
  • Blog
  • Privacy Policy
  • Terms of Service

© 2026 ChatDB. All rights reserved.

v2.4.1