About the XML Pretty Print
Machine-written XML arrives as a single enormous line. Indenting it is only half the job: an element carrying eight attributes still runs off the right edge of the screen, and a file with thirty sibling records becomes a wall of text with no visual breaks. This prettifier handles all three problems from one toolbar.
Indent size is the usual two spaces, four spaces or a tab. Tick One attribute per line and every tag with more attributes than the threshold you set is broken apart, with each attribute on its own indented line and the closing bracket lined up underneath, the layout most style guides use for Android layouts and Spring configuration. Tick Blank line between top-level blocks to separate the direct children of the root, which makes a long list of records far easier to scan.
Attribute values are never touched, so a value that contains spaces, angle brackets or newlines survives the reflow byte for byte. Comments, CDATA sections, the XML declaration and any DOCTYPE stay where they were. The document is parsed first, so malformed input reports a line and column rather than producing a mangled file. If you only want a compact result instead, the XML Minifier goes the other way, and XML Formatter covers the plain indent case.
How to use
- Paste minified or badly indented XML into the left pane.
- Choose the indent size your project uses.
- Turn on attribute wrapping and set the threshold if long tags are the problem.
- Copy the pretty printed document or download it as a file.
Common questions
- What does the attribute threshold do?
- Tags with fewer attributes than the number you set stay on one line. Set it to 1 to wrap every tag that has any attribute at all.
- Will pretty printing break my file?
- No. Only whitespace between markup is changed. Attribute values, text inside CDATA and the declaration are copied unchanged.
- Can I pretty print an SVG?
- Yes, and attribute wrapping is especially useful there because path elements often carry many attributes.
- Does it add a trailing newline?
- The output ends after the closing root tag with no extra blank line, so it pastes cleanly into an existing file.