XML Minifier
XML Minifier performs one regex replacement: whitespace in a > whitespace < sequence becomes ><, then outer whitespace is trimmed. It does not parse XML, remove comments, collapse text-node spaces, shorten names, validate entities, or know whether inter-element whitespace is semantically significant. In mixed-content or xml:space-sensitive documents, removing those characters can change content; signed XML bytes will also change.
Runs locally — files stay on your deviceDoes this remove all XML whitespace?
No. It removes only whitespace directly between a closing angle bracket and the next opening angle bracket, plus outer whitespace.
Inter-element whitespace can be data
XML applications and schemas decide whether whitespace-only text nodes are ignorable. A generic regex cannot know that context.
How it works
The input is transformed with />\s+</ to >< globally and trim removes leading/trailing text whitespace.
Key concepts
Narrow removal rule
Spaces inside text and attributes remain.
Semantic risk
Whitespace-only text nodes may matter to the consumer.
When to use it
- Compact a simple element-only document where whitespace is known insignificant.
- Inspect the effect of removing inter-tag gaps.
- Prepare a small non-signed fixture.
When not to use it
- Do not minify mixed content.
- Do not alter signed or canonical XML.
- Do not treat output as validated XML.
Worked examples
Element-only
- Input
<a>\n <b/>\n</a>- Expected output
<a><b/></a>
Inter-tag whitespace disappears.
Text
- Input
<a>Hello world</a>- Expected output
Unchanged internally
Text space is not between tags.
Mixed
- Input
<p>Hello <b>x</b> world</p>- Expected output
Potentially changed spacing around b
Those gaps can be removed.
Common mistakes
Assuming schema knowledge
No schema is loaded. Correction: Use an XML-aware optimizer.
Signed document
Bytes change. Correction: Preserve canonical signed input.
Calling it compression
Only some characters are deleted. Correction: Use transport compression for size.
Best practices
- Confirm element-only content.
- Keep the source.
- Validate semantic output with the consuming application.
Related operations and differences
JSON Minifier
Choose JSON Minifier when you need to remove unnecessary JSON whitespace.; use XML Minifier specifically for xml minify.
JSON to XML
Choose JSON to XML when you need to convert JSON objects into formatted XML.; use XML Minifier specifically for xml minify.
XML Formatter
Choose XML Formatter when you need to indent XML markup for readability.; use XML Minifier specifically for xml minify.
XML to JSON
Choose XML to JSON when you need to convert XML elements and attributes into JSON.; use XML Minifier specifically for xml minify.
Compare JSON
Choose Compare JSON when you need to show value differences between two JSON documents.; use XML Minifier specifically for xml minify.
CSV Column Extractor
Choose CSV Column Extractor when you need to extract one CSV column by header name.; use XML Minifier specifically for xml minify.
Limitations and privacy
- One whitespace regex and trim only.
- No parser, validity, comments, namespaces, DTD/schema, canonicalization, mixed-content safety, signature preservation, or compression.
The pasted data is parsed and transformed locally in this browser.
Frequently asked questions
Are comments removed?
No.
Are text spaces removed?
Not generally, except spaces located directly between tags.
Does it validate XML?
No.
Can it change meaning?
Yes.