# XML Formatter

> Format, validate and minify XML with exact error lines. Keeps comments and CDATA. Runs entirely in your browser, so nothing is uploaded.

Source: https://toffeekit.com/tools/xml-formatter

**Category:** [Developer](https://toffeekit.com/category/developer) · **Price:** Free · **Runs:** in your browser, nothing is uploaded

Open the tool: https://toffeekit.com/tools/xml-formatter

**Also useful for:** xml formatter, xml beautifier, xml validator, pretty print xml, xml minifier, format xml, svg formatter, xml viewer

## What you can do

- **Format and validate XML** — Indent a one-line XML file and check it's well-formed. ([open with this preset](https://toffeekit.com/tools/xml-formatter?preset=format))
- **Minify XML** — Remove whitespace between tags for a smaller file. ([open with this preset](https://toffeekit.com/tools/xml-formatter?preset=minify))

## How it works

1. Paste XML into the input, or click Open to load an .xml or .svg file.
2. Choose Format or Minify, and an Indent of 2 spaces, 4 spaces or Tab.
3. Set Empty elements, Attributes one per line and Keep comments to taste.
4. Read the status line to confirm the XML is valid, then Copy or Save the result.

## FAQ

### How do I check if my XML is valid?

Paste it in. The status line shows Valid XML with the root element and element count, or the exact line, column and reason for the first error.

### Does it validate against an XSD or DTD schema?

No. It checks that the XML is well-formed, meaning tags match, attributes are quoted and entities are defined. Schema validation needs the schema file and is not done here.

### Will formatting change my text content?

Elements that contain only text keep it exactly as written, and elements that mix text with child tags stay on one line, so spaces aren't added inside sentences.

### Are comments and CDATA kept?

Yes. CDATA sections, processing instructions and the DOCTYPE are kept as written. Comments are kept unless you turn off Keep comments.

### What does xml:space="preserve" do here?

Any element with xml:space="preserve" is printed exactly as it was, including its whitespace, in both Format and Minify modes.

### Is XML Formatter free and private?

Yes. It's free with no sign-up or limits, and it runs entirely in your browser, so what you type or paste never leaves your device. It works on phones and computers alike.

## Privacy

XML Formatter runs entirely in your browser. Your files and text are processed on your device and are never uploaded.

## Related tools

- [JSON Formatter](https://toffeekit.com/tools/json-formatter) — Format, minify and validate JSON with clear errors.
- [Base64 Encode / Decode](https://toffeekit.com/tools/base64-encoder) — Encode text to Base64 or decode it back, UTF-8 safe.
- [URL Encode / Decode](https://toffeekit.com/tools/url-encoder) — Percent-encode query values or whole URLs.
- [HTML Entities](https://toffeekit.com/tools/html-entity-encoder) — Escape < > & and quotes, or decode entities.
- [JWT Decoder](https://toffeekit.com/tools/jwt-decoder) — Read a token's header, claims and expiry.
- [Hash Generator](https://toffeekit.com/tools/hash-generator) — MD5, SHA-1, SHA-256, SHA-384 and SHA-512 at once.

