Developer 도구 업데이트됨 1일 전

XML Beautifier

XML Beautifier reformats XML with clean two-space indentation, one element per line and a proper XML declaration. Comments, CDATA, DOCTYPE and namespaces are kept, while whitespace and attribute quoting are normalised. Input must be well-formed XML. Copy the result or download it as a .xml file.

항상 무료 사용하기 쉬움 즉각적인 결과 비공개이며 안전합니다

사용법 XML Beautifier

코드 파일의 직접 URL을 붙여넣으면 해당 내용이 편집기에 불러옵니다.

출력

완료
도구 링크
클립보드에 복사되었습니다.
이 도구를 개선하는 데 도움을 주세요

내용 읽기

이 도구의 작동 방식과 사용 시기를 알아보세요.

What this XML beautifier does

Paste an XML document and the tool parses it, then writes it back out with consistent indentation and line breaks. It is a real parse-and-reserialise step, not a search-and-replace: the file must be well-formed XML before anything is formatted, and the output is generated from the parsed tree rather than from the original characters.

That approach gives predictable results. Elements that contain only other elements are placed on separate lines and indented by two spaces. Elements that contain text keep their content inline, because breaking text across lines would change what the document says. Empty elements are collapsed, the XML declaration is ensured, and attributes are written with double quotes.

Before and after

Input:

<root><p>Hello <b>bold</b> <i>it</i></p><empty></empty><c><![CDATA[a < b]]></c><!-- note --><x a="1" /></root>

Output:

<?xml version="1.0"?>
<root>
  <p>Hello <b>bold</b> <i>it</i></p>
  <empty/>
  <c><![CDATA[a < b]]></c>
  <!-- note -->
  <x a="1"/>
</root>

Note that the paragraph stays on one line. Mixed content, where text and elements share a parent, is deliberately left alone so the sentence still reads correctly.

What is preserved

ItemBehaviour
CommentsKept, and placed on their own indented line where possible
CDATA sectionsKept as CDATA; the contents are not escaped or altered
DOCTYPE declarationKept, including a SYSTEM identifier
Namespaces and prefixesKept as written
Attribute valuesKept, with quotes normalised to double quotes
Attribute orderNormally preserved as parsed
Text whitespaceKept exactly, including runs of spaces
Empty elementsRewritten as self-closing tags such as <empty/>

What changes

  • Indentation becomes two spaces per nesting level, replacing whatever the file used before.
  • Line breaks are inserted between sibling elements where the parent holds only elements.
  • The XML declaration is added if the input has none; an existing declaration is kept.
  • Whitespace-only text nodes between elements are consumed and replaced by the new indentation, so the visual layout of the source is not preserved.
  • Attribute quoting is normalised, so single-quoted attributes come back double-quoted.
  • Entities and escapes are written in the canonical form produced by the XML writer, which may differ from how they were typed (for example a numeric escape for the same character).

None of these changes affect the document's meaning. They do affect diffs: running the formatter over a file in version control will rewrite every line that gained indentation.

Encoding and entities

The writer follows the encoding named in the XML declaration. A UTF-8 document stays UTF-8, and accented or non-Latin characters are normally written as themselves rather than as escapes. If the declared encoding cannot represent a character, the writer falls back to a numeric character reference so the document remains valid. A document that declares no encoding is treated as UTF-8 and gains the plain declaration line described above.

Entity references, written as an ampersand plus a name or number and a closing semicolon, are handled by the parser. The five predefined XML entities are always safe. A named entity defined only in an internal DTD subset depends on how the parser resolves it, and an entity defined in an external DTD is not fetched at all, which can leave a reference unresolved or fail the parse. If a document relies on a custom entity set, check the output before using it.

Namespaces are not rewritten. A default namespace stays default, prefixes stay as written, and no prefix is invented or removed. That matters for documents that mix vocabularies, such as an SVG fragment inside an XHTML wrapper.

Well-formedness is mandatory

The parser is strict. A tag that is not closed, an unquoted attribute, two root elements, a stray ampersand, a mismatched case in a tag name or an undeclared namespace prefix all cause the parse to fail. When that happens the tool returns an error and produces no output at all, not even a partially formatted document.

This is why HTML usually fails here. HTML tolerates unclosed <br> and <img> tags, optional end tags and bare ampersands; XML does not. If you need to tidy HTML, use an HTML formatter. If you need to turn HTML into XML, fix the structure first.

How to use the page

  1. Check that the language selector reads XML. The editor is shared with the other code tools, and the selected language decides which service runs.
  2. Paste the document into the Manual tab, or fetch a text file through the From URL tab.
  3. Press Beautify. The formatted document appears in the output panel.
  4. If an error appears instead, the input is not well-formed; fix the structure and try again. The error message is generic, so an XML validator with line numbers is more useful for large files.
  5. Use Copy or Download to take the result as beautify-output.xml.
  6. The footer badges report input and output character counts, which shows how much indentation was added.

Minify mode

The page also offers a Minify button. For XML it parses the document, disables pretty output and saves it without indentation, so the tree collapses onto fewer lines. It keeps the XML declaration, comments and CDATA sections; it is a whitespace removal pass, not a content compressor. If your goal is the smallest possible payload, a dedicated XML minifier that also strips comments will do more.

When it is useful

  • API payloads. A SOAP or REST response pasted from a log becomes readable in one step.
  • Configuration files. Maven, Ant, Spring, Android layout and many build files are XML and benefit from consistent indentation.
  • SVG source. A one-line exported SVG becomes an editable tree. Be careful with <text> and <tspan>: the formatter preserves text content, but reindenting can still change whitespace between elements in ways that affect rendering.
  • Code review. A formatted diff is easier to read than a single 4,000-character line.
  • Well-formedness check. If the tool rejects the file, it is not valid XML, which is itself a useful signal.

Limits and caveats

Input is capped at 200,000 characters per request, and the conversion runs on the server. The service does not fetch external DTDs, so a document that depends on an external entity definition may fail or keep the reference unresolved. Very deep nesting can hit parser limits. The formatter does not validate against a schema, does not check business rules, does not fix broken markup and does not reorder attributes or elements. It also cannot preserve your original line wrapping, because wrapping is exactly what it recomputes.

Privacy

Your XML is sent to the server for parsing. Remove credentials, tokens, personal data and internal endpoint names before pasting, especially from SOAP envelopes and configuration files. The tool does not store a document history or return anything except the formatted text.

Common mistakes

  • Pasting HTML. Optional end tags and bare ampersands fail the strict XML parser.
  • Expecting comments to be removed in Beautify. They are preserved; Minify keeps them too.
  • Expecting the original indentation to survive. Indentation is recalculated from scratch.
  • Assuming a failure means the tool is broken. It usually means the document is not well-formed.
  • Formatting a signed document. Any byte change invalidates XML signatures; format before signing, never after.
  • Pasting secrets. The request leaves your browser.

Frequently Asked Questions

자주 묻는 질문

사용자가 결과를 신뢰하기 전에 자주 묻는 질문에 대한 간결한 답변.

It checks well-formedness, because it has to parse the document. It does not validate against a DTD or schema and does not check that element names or values are correct.

Yes. Comments, CDATA sections and the DOCTYPE declaration survive both Beautify and Minify. Only whitespace and indentation are recalculated.

HTML allows unclosed tags and bare ampersands; XML does not. Convert it to well-formed XHTML or use an HTML formatter instead.

The writer always emits one, so a document without a declaration gains the standard XML declaration line.

Yes. Formatting runs on the server, so the XML is sent with the request. Strip secrets and personal data first.

Not safely. Reformatted bytes no longer match the signature, so format before signing or leave signed files untouched.

200,000 characters per request. Larger documents are rejected.

댓글 (0)

사용자 토론, 예외적인 사례 및 추가 팁을 위한 공간입니다.
댓글 남기기
댓글을 제출하면 공개적으로 표시됩니다.
아직 댓글이 없습니다. 가장 먼저 댓글을 남겨보세요!
저희에게 알려주세요!
이 도구와 관련된 문제를 신고하기

발생한 문제를 자세히 설명해 주시면, 저희가 이를 조사하고 도구를 개선할 수 있습니다.

가장 도움이 되는 것은 무엇인가
입력 내용, 예상 결과, 실제 결과, 브라우저/기기 정보를 기재해 주시고, 도움이 될 경우 스크린샷도 첨부해 주세요.
스크린샷 버튼은 브라우저에 표시된 페이지를 캡처하여 생성된 이미지를 이 양식에 첨부합니다.
전체 화면 스크린샷
newisty를 통해 브라우저에서 캡처되었습니다.
아직 스크린샷을 찍지 않았습니다.
도구 보고서