Syntax-check XML in the browser
You can parse pasted XML or XML-based files with DOMParser, check errors with line and column information, then format or minify them.
Open the XML Formatting, Minification, and Syntax Check ToolConclusion: Fix from the first parsererror and the preceding structure
The error representation returned by DOMParser differs by browser. The tool normalizes known line and column representations and displays the applicable line and caret. Go back not only to the displayed position but also to the previous line, the matching start tag, and attribute quotation marks.
XMLSerializer re-output may change lexical representation. Do not consider syntax success alone complete; check the difference from the original XML and the loading result at the destination.
This tool does not automatically repair syntax, validate XSD or DTD validity, run XSLT, or retrieve external Resources.
Cause and decision criteria: Difference between the error location and the cause location
The Parser stops not only when it finds an invalid character, but also where it can no longer close an element. A Mismatched Tag or unclosed Quote may be detected at a later tag.
Zero errors only indicates that the format is well-formed; it does not indicate that required elements, order, types, or Business Rules are correct.
| Account to check | What to Verify | Actions after the decision |
|---|---|---|
| tag | Start name and end name; case sensitivity | Align support |
| Attributes | Quotation marks and duplicate names | Close one at a time |
| characters | &, <, and control characters | Consider an entity or CDATA |
| Namespace | Prefix declaration scope | Add or modify xmlns |
Checklist to check after the fix
- Matching start and end tags
- Attribute values and entity references
- Namespace prefix and URI
- Preserve CDATA, comments, and processing instructions
- The destination schema or business specification
What can be checked with DevelopTools' XML Formatter
XML Formatter converts entered XML into a Document with the browser-standard DOMParser, then formats or minifies it using XMLSerializer. It processes pasted XML and .xml, .xsd, .wsdl, .svg, .xsl, and .xslt files. Input content is not sent to the server.
| Item | Support in the current Tool |
|---|---|
| processing | Formatting, minification, and syntax checks. Check whether it can be parsed as a DOM |
| Formatting settings | 2 or 4 spaces or tabs; preserve line endings, LF, or CRLF; preserve, add, or remove the XML declaration |
| Retention settings | Comments, CDATA, processing instructions, blank lines, and trailing newlines. Sorting attribute names is also available |
| Structure to preserve | Namespace-qualified attributes, mixed content, xml:space="preserve", DOCTYPE |
| Diagnostics | Syntax error line, column, and surrounding excerpt; counts of elements, attributes, namespaces, comments, CDATA, and maximum depth |
| Unsupported | Validation with XSD / DTD, XSLT execution, XPath evaluation, fetching external DTDs / external Entities |
When XMLSerializer re-outputs XML, lexical representation such as empty-element notation, attribute quotes, and areas around declarations may not exactly match the input. Differences can appear even when the meaning is the same, so preserve the original file and compare the result.
Consider well-formed XML and schema validity separately
What DOMParser can parse means that start and end tags, attributes, entity references, namespaces, and similar elements meet XML well-formedness requirements. It does not determine whether element names or order match business specifications, required attributes exist, or values conform to XSD types.
XSD, DTD, WSDL, SVG, and similar formats have use-specific rules. First fix XML syntax, then validate correctness in the actual application, an XSD Validator, Build process, or similar tool to separate syntax errors from specification violations.
"Can be parsed as XML" and "conforms to an XSD or the destination specification" are not the same determination.
Common procedure for safely isolating XML syntax errors
- Duplicate the original XML and replace Tokens, Passwords, personal information, connection destinations, and similar data with test values.
- First run syntax checking, then check the displayed line and column and the preceding start tag.
- Fix closing tags, attribute quotation marks, & and <, namespace Prefixes, and CDATA endings one item at a time.
- Recheck after the fix, then proceed to the first remaining error.
- Format only after syntax is valid, then check differences from the original XML and counts of elements and attributes.
- Finally, validate semantics and constraints with XSD or the destination application.
The position shown by the Parser may not be the cause itself, but where it could no longer continue reading the structure. Go back to the preceding tags and attributes and check them.
Notes for confidential XML, external references, and large files
Pasting, file loading, parsing, formatting, minification, copying, and saving are completed in the browser. LocalStorage stores settings such as indentation, line breaks, theme, font, and editor size, not the XML body or processing history.
Do not retrieve or expand external DTDs or external entities; display a warning when a SYSTEM or PUBLIC identifier is detected. This does not guarantee safety if saved XML is passed to another parser. At the receiving end, also disable DTDs, external entities, and XInclude, and limit expansion counts and input size.
For input over 500,000 characters, omit editor syntax highlighting but continue conversion. Because the DOM uses more memory than the input string, the processable size depends on available device and browser memory.
- Mask signatures, secrets, tokens, and personal information before sharing
- Keep the original XML and save the formatted result under a different name
- For XML containing DOCTYPE, also check the receiving parser's XXE protections
- Split the target range for large XML and close other heavy tabs
Primary sources for XML specifications and safe parsing
Use W3C XML 1.0 for well-formedness conditions, Namespaces in XML for the relationship between prefixes and namespace URIs, and DOM Parsing and Serialization for browser APIs. Also check OWASP XXE Prevention for external entity security measures.
Example: Find an unclosed attribute before the error line
In
Frequently asked questions
- Is the entered XML sent to a server?
- It is not sent. XML loading, parsing, formatting, minification, syntax checks, copying, and saving are processed in the browser. Only display and formatting settings are saved.
- If syntax checking succeeds, does it also conform to XSD?
- Not guaranteed. This tool checks well-formedness using DOMParser, but does not validate XSD/DTD validity or destination-specific fields.