---
title: "XML Formatter Online: Prettify and Pretty-Print XML | Prettify"
description: "Prettify XML online: paste minified or messy XML and get clean,
  two-space indented markup. Errors show the line and column. Runs in your
  browser."
url: https://prettify.tools/xml-formatter
---

# XML Formatter: Prettify and Pretty-Print XML

Paste minified or messy XML and Prettify gives it clean, two-space indentation, with each nested element on its own line. If the markup is broken, the formatter names the line and column of the problem. Everything runs in your browser.

## What the XML formatter does

You paste XML that sits on one line or has uneven indentation. The formatter returns the same document with one tag per line and a two-space step for each level of nesting. It is the tool to use when you want to prettify XML so that you can read or review it.

The input can be a SOAP response, a sitemap, a build file, an SVG, or a configuration file. The text inside your elements is kept. A short element such as a name with a value stays on one line.

## Key features

The formatter combines indentation with a well-formedness check, so one paste tells you both things.

- Each nested element starts on its own line, indented by two spaces per level.
- Whitespace-only text between tags is dropped, and the text inside elements is kept.
- A parse error shows the line and column, read from your browser XML parser.
- An information note appears when the XML declaration is missing, and a warning appears for a duplicate attribute in one tag.
- Namespace prefixes such as soap:Envelope and xmlns declarations keep the form you wrote.
- The editor opens .xml, .xhtml, .xsl, and .xslt files as XML. A .svg file opens as SVG, and Open as XML gives you its markup as XML.
- Copy and Download are in the result panel, and Download saves a file named prettify.xml.
- The Convert menu in the editor turns the XML into JSON, YAML, or CSV when you are done.

## How to prettify XML

Start in the box on this page. It formats as you paste. A document over 512 KB goes straight to the editor, which handles large files.

1. Paste your XML into the box labeled "Paste your XML", or select "Try an example".
2. Read the line above the result. It describes the shape of the document, or it names the line and column of a parse error.
3. Read the formatted XML in the result panel.
4. Select Copy to put the formatted XML on your clipboard, or select Download to save it.
5. Select "Open in full editor" to keep working. If the XML has an error, the button reads "Fix it in the editor".
6. In the editor, open the Raw view for the pretty-printed XML with line numbers and inline problems.
7. Select Copy Formatted in the toolbar to copy the result, or use Download to save it.

## Worked example: a minified invoice

This invoice arrives on one line, as an API often sends it. The formatter puts the customer fields two levels deep, keeps each line element and its attributes together, and leaves the text of every element as it was.

The XML declaration at the top stays as you wrote it. The sku and qty attributes stay on their elements in the order you wrote them. The Cable and Adapter values stay inside their line elements.

```
Input (one line):
<?xml version="1.0"?><invoice id="INV-204" currency="EUR"><customer><name>Nordlicht GmbH</name><city>Hamburg</city></customer><line sku="A-10" qty="2">Cable</line><line sku="B-22" qty="1">Adapter</line><total>48.50</total></invoice>

Result:
<?xml version="1.0"?>
<invoice id="INV-204" currency="EUR">
  <customer>
    <name>Nordlicht GmbH</name>
    <city>Hamburg</city>
  </customer>
  <line sku="A-10" qty="2">Cable</line>
  <line sku="B-22" qty="1">Adapter</line>
  <total>48.50</total>
</invoice>
```

## What the formatter keeps

The formatter changes only line breaks and indentation. Comments, CDATA sections, processing instructions, and entities such as \&amp; stay as you wrote them. Elements keep their order, so a, b, a stays a, b, a. A DOCTYPE keeps its name and external ID, but an internal subset in square brackets is left out.

Text mixed with tags, as in a paragraph with a bold word, stays on one line with its spaces. An XML declaration is kept when your document has one, and none is added when it does not. The Raw view in the editor shows the same result.

## Common use cases

Readable XML makes every later step easier. These are the jobs people bring here most.

- Read a one-line SOAP or REST response from a log or a terminal.
- Tidy a sitemap.xml or a pom.xml before a code review.
- Find the unclosed or mismatched tag in a file a parser rejects.
- Paste an SVG and see its structure as indented markup.
- Prepare a document for conversion to JSON or for reading in the XML Viewer.

## Frequently asked questions

### Are my XML comments kept?

Yes. Each comment stays where you wrote it, on its own line in the result. The Raw view in the editor keeps them too, so you can edit the document and copy it back with its comments.

### Can I prettify an SVG file?

Yes. An SVG is XML, so paste the SVG source here and the formatter indents it the same way as any other document. In the editor, a .svg file opens as SVG with an Image view. Select Open as XML to work on it as XML.

### Why does the error message read differently in each browser?

The message text comes from the XML parser built into your browser. Prettify reads the line and column from it and removes the boilerplate, so the position is reliable even when the wording differs.

### Is XPath free?

No. The XPath panel is a Pro tool. Formatting, validation, and the Tree, Raw, and Table views are free. Pro costs US$19.99 once, with no subscription.

### Is a SOAP response with customer data sent anywhere?

No. The formatter parses and indents your markup on your device. Prettify uploads your XML only if you create a share link yourself.

### How large a document can the box format?

The box reads up to 512 KB. For a larger document it shows the size and sends you to the full editor, which handles large files.

## Related tools

- [JSON Formatter: Prettify and Pretty Print JSON](https://prettify.tools/json-formatter)
- [XML Viewer Online](https://prettify.tools/xml-viewer)
- [Open and Explore CSV Files Online](https://prettify.tools/csv-viewer)
- [XML to JSON Converter](https://prettify.tools/xml-to-json)
- [XPath Tester and Playground](https://prettify.tools/xpath-playground)
- [RSS Feed Viewer](https://prettify.tools/rss-feed-viewer)

## Structured data

```json
{
  "@context": "https://schema.org",
  "@type": "SoftwareApplication",
  "name": "Prettify",
  "url": "https://prettify.tools",
  "description": "Multi-format data viewer, editor, and query engine for JSON, YAML, CSV, XML, Mermaid, Markdown, MDX, HTML, and SVG",
  "applicationCategory": "DeveloperApplication",
  "operatingSystem": "Web, macOS, Windows, Linux",
  "offers": [
    {
      "@type": "Offer",
      "price": "0",
      "priceCurrency": "USD",
      "description": "Free tier with core features"
    },
    {
      "@type": "Offer",
      "price": "19.99",
      "priceCurrency": "USD",
      "description": "Pro: lifetime access to all features"
    }
  ],
  "publisher": {
    "@id": "https://prettify.tools/#organization"
  }
}
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "@id": "https://prettify.tools/#organization",
  "name": "Prettify",
  "legalName": "Off Leash Labs",
  "url": "https://prettify.tools/",
  "logo": {
    "@type": "ImageObject",
    "url": "https://prettify.tools/icon-512.png",
    "width": 512,
    "height": 512
  },
  "contactPoint": {
    "@type": "ContactPoint",
    "contactType": "customer support",
    "email": "offleashlabs@gmail.com",
    "availableLanguage": "English"
  }
}
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "WebPage",
      "@id": "https://prettify.tools/xml-formatter",
      "url": "https://prettify.tools/xml-formatter",
      "name": "XML Formatter Online: Prettify and Pretty-Print XML | Prettify",
      "description": "Prettify XML online: paste minified or messy XML and get clean, two-space indented markup. Errors show the line and column. Runs in your browser.",
      "isPartOf": {
        "@type": "WebSite",
        "name": "Prettify",
        "url": "https://prettify.tools"
      }
    },
    {
      "@type": "FAQPage",
      "mainEntity": [
        {
          "@type": "Question",
          "name": "Are my XML comments kept?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "Yes. Each comment stays where you wrote it, on its own line in the result. The Raw view in the editor keeps them too, so you can edit the document and copy it back with its comments."
          }
        },
        {
          "@type": "Question",
          "name": "Can I prettify an SVG file?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "Yes. An SVG is XML, so paste the SVG source here and the formatter indents it the same way as any other document. In the editor, a .svg file opens as SVG with an Image view. Select Open as XML to work on it as XML."
          }
        },
        {
          "@type": "Question",
          "name": "Why does the error message read differently in each browser?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "The message text comes from the XML parser built into your browser. Prettify reads the line and column from it and removes the boilerplate, so the position is reliable even when the wording differs."
          }
        },
        {
          "@type": "Question",
          "name": "Is XPath free?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "No. The XPath panel is a Pro tool. Formatting, validation, and the Tree, Raw, and Table views are free. Pro costs US$19.99 once, with no subscription."
          }
        },
        {
          "@type": "Question",
          "name": "Is a SOAP response with customer data sent anywhere?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "No. The formatter parses and indents your markup on your device. Prettify uploads your XML only if you create a share link yourself."
          }
        },
        {
          "@type": "Question",
          "name": "How large a document can the box format?",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "The box reads up to 512 KB. For a larger document it shows the size and sends you to the full editor, which handles large files."
          }
        }
      ]
    }
  ]
}
```
