XML Formatter
Make an XML document easier to read, or remove selected layout whitespace with Compact. Processing stays in your browser; formatting can change whitespace and is not schema validation or canonical XML.
How to format XML
- Paste one XML document or open one UTF-8 file up to 2 MiB. The tool supports XML 1.0 without a DOCTYPE; it does not open URLs or fetch schemas.
- Choose Pretty with two spaces, four spaces or tabs, or deliberately choose Compact. Read the whitespace warning, then run the selected action.
- Review the current checked output and any preview-truncation notice. Copy XML or download the complete UTF-8 file; edits and setting changes retire the previous result.
What the formatter checks and changes
Well-formedness checks document structure, legal characters and namespace bindings, including attributes that resolve to the same expanded name. It does not establish that an XML document follows a schema or means what an application expects.
Pretty replaces direct whitespace around child elements only in eligible containers. Compact removes the same whitespace without adding indentation. Without a schema, that whitespace cannot generally be proved insignificant, so neither operation promises semantic equivalence.
Subtrees rooted at elements with direct mixed text, direct CDATA or xml:space="preserve" keep their text layout, even across a descendant default reset. Whitespace-only leaves are retained. Comments, processing instructions, namespace declarations and child order are not discarded.
Output always uses an XML 1.0 UTF-8 declaration, no BOM and a final LF. Quote style, references, empty tags, line endings and processing-instruction separators can change. Escaping preserves parsed attribute controls and text carriage returns rather than accidentally changing them on the next parse.
Examples worth checking
The document <r> <a/> </r> gains line breaks and indentation in Pretty; Compact writes <r><a/></r> after the normalized declaration. Those layout changes alter character data even when the elements look unchanged.
In <p>Hello <b>world</b> !</p>, the spaces belong to mixed text. Its entire subtree keeps that text layout instead of splitting the sentence across new lines.
The attributes a:id and b:id conflict when both prefixes name the same namespace. An unprefixed id, however, is not put into an element's default namespace. Changing a prefix's spelling alone does not resolve an expanded-name duplicate.
Important limits
Only XML 1.0 and UTF-8 file input are supported. XML 1.1, other encoding declarations, every DOCTYPE and custom entities are rejected. Namespace URIs and stylesheet instructions are never opened.
This is not DTD or XSD validation, canonical XML, a signature checker, an XML-to-JSON converter or a repair tool. Do not substitute its normalized output for an original whose exact bytes or signature must be retained.
Input is limited to 2 MiB, depth 128, 100,000 records and 128 attributes per element; token limits also apply. Output is limited to 8 MiB. A near-line error marks where checking noticed a problem, not necessarily where the malformed token began.
The visible preview is capped, but current Copy and download contain the complete verified output. A cancelled, failed or timed-out operation has no downloadable partial result; resource limits are not a guarantee about every browser's memory use.
Local document processing
The tool processes your XML locally and does not upload or retain the source or result. Copy and download are explicit actions; downloaded files and clipboard contents remain under your browser and operating system's controls.
XML formatting questions
Sources
These references describe the XML profile and parser dependencies; they do not certify this implementation or validate your document against a schema.
- W3Cw3.orgXML 1.0, Fifth EditionDocument grammar, characters, references and whitespace.
- W3Cw3.orgNamespaces in XML 1.0Namespace bindings and expanded attribute names.
- WHATWGencoding.spec.whatwg.orgEncoding StandardUTF-8 decoding and encoding.
- W3Cw3.orgCanonical XML 1.1Canonicalization is a separate process, not an output of this tool.
- raw.githubusercontent.comsaxes parser documentationParser events and namespace-aware processing.
- registry.npmjs.orgsaxes 6.0.0 packageThe pinned XML parser package.
- registry.npmjs.orgxmlchars 2.2.0 packageCharacter definitions used by the parser.
The tool rejects DOCTYPE and does not fetch external resources or validate schemas.
References reviewed 2026-11-08.
Related tools
JSON to YAML
Convert JSON to YAML locally while preserving number text and quoted strings; copy or download the complete result.
Open tool — JSON to YAMLYAML to JSON
Convert one YAML document locally to JSON with exact number text and bounded aliases, then copy or download the complete result.
Open tool — YAML to JSONHTML to Markdown
Convert pasted or local HTML into Markdown, review conversion notes, and copy or download the result.
Open tool — HTML to MarkdownJavaScript Regex Tester
Test a JavaScript pattern locally and inspect matches, captures, and UTF-16 positions.
Open tool — JavaScript Regex TesterMarkdown to HTML
Convert a Markdown draft to an HTML fragment, inspect the source and inert preview, then copy or download it.
Open tool — Markdown to HTMLText Sorter
Sort lines alphabetically by a chosen language or by Unicode code point, keeping duplicates, blank rows and complete line contents.
Open tool — Text SorterRemove Duplicate Lines
Keep the first copy of each exact text line, preserving order, significant spaces and blank rows, then copy or download the result.
Open tool — Remove Duplicate LinesText Diff Checker
Compare two drafts locally, with exact whole-line changes, visible whitespace rules and clear final-newline handling.
Open tool — Text Diff CheckerCase Converter
Convert text to uppercase, lowercase, capitalized words or sentence case with explicit letter rules.
Open tool — Case ConverterHTML Entity Encoder/Decoder
Encode or decode literal HTML references with explicit context, Unicode options and LF output, without parsing or rendering markup.
Open tool — HTML Entity Encoder/DecoderMarkdown Table Generator
Edit a small literal-text table, set alignment and copy GFM Markdown or import tab-separated text.
Open tool — Markdown Table GeneratorQuery String Parser & Builder
Edit ordered URL parameters, retain repeated names and copy a normalized query or HTTP(S) URL.
Open tool — Query String Parser & BuilderURL Encoder & Decoder
Convert a UTF-8 URL component or form value with explicit space and plus rules, then copy or download the result.
Open tool — URL Encoder & DecoderBase64 Encoder & Decoder
Encode UTF-8 text as standard or URL-safe Base64, or decode either format with clear errors and complete text output.
Open tool — Base64 Encoder & DecoderJSON Formatter & Validator
Check JSON syntax, format or minify locally, and copy or download output while preserving original data tokens.
Open tool — JSON Formatter & ValidatorSMS Character Counter & Segment Calculator
See how your message is encoded, where its segments end and what it may cost. Your text stays in your browser.
Open tool — SMS Character Counter & Segment CalculatorSocial Media Character Counter
Check platform-specific limits and split posts without losing text.
Open tool — Social Media Character CounterCharacter Counter
Count characters, words, sentences and paragraphs. Check word density, reading time and UTF-8 size, all in your browser.
Open tool — Character CounterText Size Calculator
Compare text encodings and payload sizes in your browser.
Open tool — Text Size CalculatorPDF Text Cleaner
Fix line breaks and spacing in text copied from a PDF. Preserve your original and review ambiguous hyphens before copying the cleaned text.
Open tool — PDF Text CleanerFancy Text Converter
Convert supported fancy Unicode letters to normal text locally. Keep case, accents, emoji and your original text.
Open tool — Fancy Text ConverterGarbled Text Fixer
Fix garbled text and repair broken accents with a browser-based mojibake fixer. Review each possible UTF-8 reversal before applying it.
Open tool — Garbled Text FixerGmail Clipping Checker
Measure email HTML bytes in UTF-8, compare them with an advisory 102,000-byte Gmail reference, and inspect size contributors locally.
Open tool — Gmail Clipping Checker