Format XML instantly
Paste XML, choose indentation and collapse behavior, then copy the formatted output

<hello> <world>foo</world> <world>bar</world> </hello>
The XML formatter takes raw XML on the left and produces a consistently-indented, easy-to-read version on the right. It’s ideal for debugging, code reviews, and quickly understanding a nested document.
Use it when your XML is hard to scan — especially when tags are nested several levels deep or when you need clean diffs in git.
What the options mean
If your next step is converting data formats, try our JSON prettify tool for readable payloads.
Paste your XML
Paste raw XML into the left input. You can format tiny snippets or full documents.
Choose options
Set the indent size and decide whether to collapse text content.
Copy the formatted output
Use the copy button on the right to paste the result into your editor, ticket, or PR comment.
A quick way to reason about indentation
If your indent size is spaces and a tag is nested levels deep, the leading spaces are roughly:
This isn’t “math you must do” — it’s just a mental model for why a larger indent can make deep XML very tall.
Input:<hello><world>foo</world><world>bar</world></hello>
Set Indent size to and keep Collapse content enabled. The output becomes easy to scan line-by-line.
If you choose spaces and your data is nested levels, you’ll see up to leading spaces at the deepest level.
Practical takeaway: for very deep documents, a smaller indent usually stays more readable.
Background: you receive a dense XML response in logs. Inputs: paste the response, set . Result: the formatted XML reveals the exact nested field that differs.
Background: a config file was edited by multiple people. Inputs: format both versions to normalize whitespace. Result: diffs focus on semantic changes, not messy formatting.
Background: you’re writing a README or a support article. Inputs: format snippets so indentation is consistent. Result: readers understand structure faster.
Background: you want to compare XML data with JSON. After formatting, it’s often easier to extract fields or copy segments into other tools like JSON prettify.
Not a good fit: if you need to validate against an XSD schema or canonicalize XML for cryptographic signatures, you’ll need specialized tooling.
Formatting is mainly about whitespace: newlines and indentation. The formatter reads the XML structure (elements, nesting, and text nodes) and then outputs the same structure with consistent spacing.
Indentation model
For a given nesting level and indent size :
Where is the count of leading spaces before the tag.
What “collapse content” does (in plain terms)
When enabled, simple text-only nodes are kept compact so you don’t get extra whitespace in places where it doesn’t help readability.
Whitespace in XML
In many XML contexts, whitespace between elements is not semantically important — but in mixed-content documents it can be. That’s why “collapse content” is a preference: it optimizes for readability, not every edge case.
It changes whitespace and line breaks. The tag structure and text content should remain the same for typical XML.
Common causes include missing closing tags, unescaped characters like , or an incomplete copy/paste.
Most teams use or spaces. Smaller indents can be easier for deep XML.
Yes — use the Share button below the calculator. You can choose whether to include your inputs/results.
This formatter runs locally in your browser for formatting. Avoid sharing sensitive data in public links.
Edit rich text in a simple WYSIWYG editor and copy Prettier-formatted HTML instantly. Runs locally in your browser.
Parse, validate, and format phone numbers. Get the country, calling code, type, and common formats like E.164 and RFC3966. Runs locally in your browser.
Verify the signatures of a PDF file locally in your browser and inspect certificate details. No data is sent to any server.
Convert fractions to percentages and vice versa instantly
Convert grams to tablespoons for any ingredient instantly. Perfect for cooking and baking with support for multiple ingredients.
Convert decimal numbers to percentages with real-time bidirectional conversion