---
title: XML Viewer, Formatter, and Converter | Prettify Docs
description: Open, validate, and pretty-print XML in Prettify. See attributes,
  views, XPath queries, feeds, and conversion to JSON, YAML, and CSV.
url: https://prettify.tools/docs/xml
---

[Docs](https://prettify.tools/docs) / Formats

# XML

Last updated: October 23, 2026

Prettify opens, validates, and pretty-prints XML in your browser, and converts it to JSON, YAML, and CSV. It reads RSS and Atom feeds. SVG has its own page: see [SVG](https://prettify.tools/docs/svg). This page explains the XML behavior. For feeds, see [RSS and Atom feeds](https://prettify.tools/docs/rss-feeds).

Open the editor at [/app/editor](https://prettify.tools/app/editor), or start from the [XML Formatter](https://prettify.tools/xml-formatter) tool page.

## How Prettify detects XML

Prettify reads text as XML when it starts with `<` and parses as a well-formed document. A `.xml`, `.xhtml`, `.xsl`, or `.xslt` file opens as XML too. An SVG file does not open as XML. It opens as [SVG](https://prettify.tools/docs/svg), with an Image view. To read SVG text as XML, pick XML in the format list. Prettify then shows an empty XML tab. Paste the SVG text into that tab.

You can also set the format by hand in the sidebar or the Command Palette. Open the Command Palette with `Cmd+K` (Mac) / `Ctrl+K` (Windows, Linux).

## Attributes and the data model

Prettify turns the XML tree into keys and values for the Tree, Table, and Diagram views. An attribute is stored under a key with an `@` prefix. Repeated child tags become an array. Text inside an element with attributes is stored under `#text`.

```xml
<book id="b1">
  <title>Dune</title>
  <tag>sci-fi</tag>
  <tag>classic</tag>
</book>
```

The example reads as one `book` object, with `@id` set to `b1` and two `tag` values in an array.

## Views

XML gets these views. Tree, Raw, and Table are free.

| View          | What it shows                                                           |
| ------------- | ----------------------------------------------------------------------- |
| Tree          | A collapsible tree of elements, attributes, and text. The default view. |
| Raw           | The pretty-printed XML, with line numbers and inline problems.          |
| Table         | Repeated elements as rows and columns.                                  |
| Diagram (Pro) | A node graph with collapsible nodes.                                    |
| Feed (Pro)    | RSS and Atom items as articles. Only for a feed document.               |

The Feed view appears only when the document is an RSS, Atom, or RSS 1.0 feed, and a feed opens on it by default. See [RSS and Atom feeds](https://prettify.tools/docs/rss-feeds), [Diagram view](https://prettify.tools/docs/diagram-view), and [Views](https://prettify.tools/docs/views).

## Formatting

Prettify pretty-prints XML with two-space indentation. The Raw view shows this formatted text. Copy Formatted copies it, and Download saves it.

## Validation and error messages

Prettify checks that the XML is well formed. A parse error carries a line and column, read from the browser parser. The Problems panel also shows lint notes:

- An information note when the XML declaration (`<?xml version="1.0"?>`) is missing.
- A warning for a duplicate attribute in the same tag.

## Query with XPath

XPath (Pro) selects nodes with the browser XPath engine (XPath 1.0). It supports namespace prefixes.

```xpath
//book[@id='b1']/title
```

See [XPath queries](https://prettify.tools/docs/xpath). jq is for JSON and SQL is for CSV, so XML uses XPath.

## Convert

Convert turns XML into [JSON](https://prettify.tools/docs/json), [JSONL](https://prettify.tools/docs/jsonl), YAML, or CSV. XML to JSON writes each attribute as an `@attribute` key, which Prettify notes in the warning.

Converting other data to XML has two rules. A key that is not a valid XML element name is renamed, and Prettify lists the renamed keys. A single-item array becomes one element and reloads as a single value, not an array, which Prettify also notes. See [Conversion](https://prettify.tools/docs/conversion).

Diff / Compare (Pro) compares two documents; see [Diff](https://prettify.tools/docs/diff). Pro is a one-time purchase of US$19.99. See [Pro](https://prettify.tools/docs/pro).

## Privacy

Parsing, formatting, and conversion run on your device. Prettify does not upload your XML unless you share it. See [Privacy](https://prettify.tools/docs/privacy) and [Sharing](https://prettify.tools/docs/sharing).

## Try it online

Tool pages for this topic. Each one runs in your browser.

- [XML Formatter](https://prettify.tools/xml-formatter)
- [XML Viewer](https://prettify.tools/xml-viewer)
- [XML to JSON](https://prettify.tools/xml-to-json)
- [JSON to XML](https://prettify.tools/json-to-xml)
- [XPath Tester](https://prettify.tools/xpath-playground)

* [PreviousCSV and TSV](https://prettify.tools/docs/csv)
* [Next RSS and Atom feeds](https://prettify.tools/docs/rss-feeds)

## 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"
  }
}
```
