Saltar al contenido

Formateador XML

Embellece o compacta XML con indentación correcta - en tu navegador.

Funciona en tu navegador

Pega XML, obtén una versión indentada limpia - o compacta a una línea. Self-closing, CDATA y comentarios preservados.

Cómo usarla

  1. Paste your XML

    Any well-formed XML, with or without an XML declaration.

  2. Pick pretty-print or minify

    Pretty-print uses 2 spaces by default; switch to 4 spaces or tabs if your codebase prefers.

  3. Copy the result

    Output appears in the right pane. Hit Copy to grab it.

¿Qué es?

An XML formatter rewrites a string of XML in a canonical form - either indented for reading or stripped to a single line for storage / transport. The structural facts (elements, attributes, text, CDATA, comments) are preserved; only whitespace between nodes changes. Pretty-printing is the most common use; minifying is occasionally needed for shaving bytes off a payload.

Cuándo usarla

Reading a one-line XML response from an API. Comparing two XML files in a diff tool that doesn't ignore whitespace. Pasting an SVG into source control after a graphics tool wrote it as a single line. Stripping pretty-printed XML before embedding in an attribute or generating a small QR code.

Errores comunes

Treating the result as canonical XML for signature purposes - real XML canonicalisation (c14n) is a separate spec and this tool doesn't implement it. Assuming attribute order is preserved across parser implementations (it is here, but XML technically doesn't guarantee it). And running the minifier on XML that contains significant whitespace in <pre>-like content - any whitespace-sensitive content needs CDATA or escaped runs.

Preguntas frecuentes

Does it validate the XML?
It uses the browser's DOMParser, which surfaces malformed XML as a parser error. Validation against a schema (XSD, DTD, RelaxNG) is out of scope.
What about XML namespaces?
Namespaces are preserved on the tags that declare or use them. The formatter doesn't re-prefix or normalise them.

Más en esta categoría