Developer 도구 업데이트됨 6시간 전

XML Minifier

XML Minifier strips indentation and whitespace-only nodes from valid XML, collapsing a formatted document onto one line. Comments, CDATA, the DOCTYPE, namespaces and text content are kept as they are. Paste or load a file, minify, then copy the result or download it as minify-output.xml.

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

사용법 XML Minifier

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

출력

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

내용 읽기

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

What this XML minifier actually removes

Paste a formatted XML document and the tool parses it, then writes it back without the indentation. Sibling elements end up on the same line, the ASCII whitespace that only existed to make the file readable is dropped, and the result is a compact document that carries the same data.

"Minify" here has a narrow meaning. The tool removes whitespace-only nodes between elements and disables pretty printing. It does not strip comments, does not rewrite text content, does not shorten element or attribute names, and does not remove CDATA. If you need those things, this is not the tool for that job.

Before and after

Input:

<root>
  <!-- keep -->
  <a>  x   y  </a>
  <b><![CDATA[  raw  <tag>  ]]></b>
  <c attr="one two" />
  <d></d>
</root>

Output:

<?xml version="1.0"?>
<root><!-- keep --><a>  x   y  </a><b><![CDATA[  raw  <tag>  ]]></b><c attr="one two"/><d/></root>

The comment survived, the CDATA block survived, and the spaces inside the text element survived exactly as typed. Only the line breaks and indentation between elements disappeared.

What is removed and what is kept

ItemMinify behaviour
Indentation and line breaks between elementsRemoved
Whitespace-only text nodesRemoved, including spaces between inline child elements
CommentsKept
CDATA sectionsKept, contents untouched
Text content whitespaceKept exactly
DOCTYPEKept
XML declarationKept, or added if missing
Empty element pairsRewritten as self-closing tags
Attribute valuesKept, with newlines normalised to spaces per the XML spec
Namespaces and prefixesKept

The mixed-content trap

Whitespace between elements is usually insignificant, which is why removing it is safe for data documents. It becomes significant in mixed content, where text and inline elements share a parent. The parser treats an element that contains only child elements as element-only content, so whitespace-only nodes there are discarded:

<p><b>a</b> <b>b</b></p>

becomes

<p><b>a</b><b>b</b></p>

which renders as "ab" rather than "a b". If a sentence contains inline markup separated by spaces, or if you are minifying XHTML, SVG text or any document where layout depends on inter-element whitespace, check the output before publishing it. This is the one behaviour that can change meaning rather than just appearance.

What it does not do

  • It does not remove comments. A comment-heavy file stays comment-heavy.
  • It does not collapse spaces inside text. Runs of spaces in a text node are preserved.
  • It does not shorten names. No element or attribute is renamed.
  • It does not drop namespaces or unused declarations.
  • It does not validate against a schema or DTD, and it does not check that the data makes sense.
  • It does not repair invalid XML. A missing close tag or a bare ampersand fails the parse and produces no output.
  • It does not guarantee the smallest possible file. A dedicated minifier that also strips comments will usually do better.

How to use the page

  1. Make sure the language selector says XML and the mode is Minify.
  2. Paste the document into the Manual tab, or fetch a text file through the From URL tab.
  3. Press Minify. The compact document appears in the output panel, or an error appears if the input is not well-formed.
  4. Compare the output character count with the input count in the footer badges. On a typically indented file, most of the saving comes from indentation, not from content.
  5. Copy the result or download it as minify-output.xml.
  6. Run a validator or your application's parser over the result once, especially if the source had mixed content.

Where it is useful

  • Payload size. Removing indentation from a generated XML response reduces bytes, though a compression layer usually achieves more.
  • Logs and trace files. A pretty-printed request body becomes a single line that is easier to paste into a log entry or a chat message.
  • Configuration snapshots. Compact XML is easier to store in a database column or compare as one string.
  • Diff noise. When two files differ only in indentation, minifying both makes the real difference visible.
  • Embedding XML. A compact document is easier to place inside a JSON string or an environment variable.

It is a poor fit for XHTML pages, SVG artwork with text, documentation in XML, and anything that will be read by a person afterwards. Readability is the thing minification removes.

How much smaller does the output get?

The saving comes almost entirely from indentation, so it depends on how deeply the source was indented. In a test with a 20-item product catalog written with two and four space indentation, the input measured 2,344 characters and the minified output 1,946 characters, a reduction of about 17 percent. The output also gained the XML declaration, which offsets a few bytes.

A document with one tab per level and dozens of nested elements saves more. A file that was already written on a single line saves almost nothing, because only the declaration, self-closing tags and attribute normalisation change. If bytes matter enough to measure, compare the input and output counters in the footer before deciding that minification is worth the loss of readability.

What it does to already-compact XML

Running the minifier on a file that has no indentation still produces changes: the XML declaration is ensured, empty element pairs become self-closing tags, and attribute values are normalised. Comments and CDATA remain. If your input is already one line, expect the output to look nearly identical apart from those details, and expect the character count to move slightly rather than drop.

Limits

Input is capped at 200,000 characters per request. The document is parsed into memory on the server, so a deeply nested file near the limit can be slower than its size suggests. The tool handles one document per request, does not stream, does not batch files and does not preserve the original line endings because it rewrites the whole serialisation. A file with multiple root elements is invalid and is rejected.

Privacy

Your XML is sent to the server. Remove tokens, passwords, personal data and internal hostnames before pasting, particularly from SOAP envelopes, SSO assertions and configuration exports. The page does not keep a history, but the document does leave the browser during processing.

Common mistakes

  • Expecting comments to disappear. They are kept; this is not a full compressor.
  • Minifying XHTML with inline spacing. Whitespace between inline elements can be removed, changing the rendered text.
  • Minifying a signed document. Any byte change invalidates the signature.
  • Pasting HTML. Optional end tags and bare ampersands are not valid XML and fail the parse.
  • Assuming the output is airtight. Validate it once before replacing a production file.
  • Using it for archival. Keep the readable original; the compact version is for transport.

Frequently Asked Questions

자주 묻는 질문

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

No. Comments, CDATA sections, the DOCTYPE and the XML declaration are all preserved. Only indentation and whitespace-only nodes between elements are removed.

It can, in mixed content. Whitespace between inline elements inside an element that has no text of its own may be removed, so a space that separated two words can disappear.

Yes. Parsing and serialisation run on the server, so the document is sent with the request. Strip secrets first.

The tool has to parse the document before it can write it. If parsing fails, there is nothing to serialise, so the request returns an error instead of a partial result.

No. Runs of spaces in text content are preserved exactly; only whitespace-only nodes between elements are dropped.

No. Changing bytes invalidates the signature. Minify before signing, or leave signed documents untouched.

200,000 characters per request. Larger documents are rejected rather than truncated.

댓글 (0)

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

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

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