Pular para o conteúdo

Formatador XML

Embeleze ou compacte XML com indentação adequada - no seu navegador.

Roda no seu navegador

Cole XML, obtenha uma versão indentada limpa - ou compacte para uma linha. Self-closing, CDATA e comentários preservados.

Como usar

  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.

O que é?

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.

Quando usar

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.

Erros comuns

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.

FAQ

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.

Mais nesta categoria