XML Formatter and Validator

Errors by line and column.

Paste XML to format it and check it is well-formed, with every problem listed by line and column. Paste JSON instead and it is converted to XML automatically.

Zero retention: your data never leaves this browser. Verify it yourself in DevTools

Loading the toolbox.

About 2xml

How Can You Verify That Nothing Leaves This Browser?

You do not have to take our word that your data stays here. Developer tools show every request a page makes, so you can watch this page work and confirm that nothing is sent. The check takes under a minute.

  1. Open your browser developer tools with F12, or Cmd+Option+I on a Mac, and select the Network tab.
  2. Reload the page and let it finish. You will see the page's own files, its web fonts, and one anonymous page-view request. Nothing has been typed yet, so none of them can contain your data.
  3. Click the clear icon in the Network tab so that the log is empty.
  4. Use the tool with your own input.
  5. Look at the Network tab again. It is still empty. For extra proof, turn on offline mode after the page loads and the tool keeps working.

Only two things can add a line to that log, and neither carries your data. Submitting the feedback form sends the vote and comment you typed. Typing characters in a script the page has not displayed yet, such as Cyrillic or Greek, can make the browser fetch the matching font file, and that request names only the font.

The production site also sends a Content-Security-Policy header that tells your browser to refuse connections to anywhere except this site and the anonymous analytics endpoint, so a coding mistake could not quietly send your data elsewhere.

What Makes XML Well-Formed?

Well-formed XML has exactly one root element, every start tag closed by a matching end tag in the right order, every attribute value in quotes, no unescaped < or & in text, and properly declared namespace prefixes. A parser must stop at the first violation, which is why a single stray character can make a feed or SOAP response unreadable.

2xml uses your browser's own XML parser as the final authority, and runs its own scanner alongside it so that it can report several problems at once, each with a line and column.

What Does the Linter Check?

  • Unclosed, stray, and mismatched tags, with the line where the open tag started.
  • Unclosed comments, CDATA sections, and processing instructions.
  • Attributes without quoted values, multiple root elements, and text outside the root.
  • Namespace problems: undeclared element and attribute prefixes, empty namespace URIs, duplicate declarations, and misuse of the reserved xml and xmlns prefixes.
  • Duplicate sibling elements, reported as warnings because they are legal and common in RSS and Atom, but often a copy-paste bug elsewhere.

How Does the Formatter Keep Your Document Intact?

Many formatters rebuild XML from a parsed tree, which reorders attributes and can drop comments. 2xml pretty-prints from the original source, so attribute order, comments, CDATA sections, processing instructions, and the XML declaration are kept exactly. Elements that hold only text stay on one line.

How Does XML to JSON Conversion Work?

There is no single standard mapping, so 2xml uses a common convention: attributes go under an @attributes key, text mixed with child elements goes under #text, and repeated child elements become an array. Converting JSON to XML reverses the convention, escapes the five XML special characters, and replaces any key that is not a legal element name with item, so the output is always well-formed.

What Other Tools Are in the Checkers Lane?

  • 2jq: Try jq-style paths, pipes, select, length, and keys against JSON. A labeled subset, not full jq.
  • 2ssh: Validate ssh_config or sshd_config, copy a hardened block, and compose the right ssh-keygen command.
  • 2dotenv: Find duplicate keys, empty values, and quoting bugs, diff against .env.example, and generate one.
  • 2kbd: Press any key to see key, code, keyCode, location, and modifiers, with a copy-ready handler.

Elsewhere in the toolbox: 2uuid, 2gitignore, 2csp, 2htaccess, and more on the 2toolbox home page. Part of the 2suite.io privacy-first ecosystem.

Frequently Asked Questions

Does 2xml validate against a schema?

No. It checks well-formedness and namespaces, not XSD or DTD rules.

Why is a duplicate sibling only a warning?

Repeated elements are legal XML and normal in feeds and lists. The warning helps catch accidental copies.

Is my XML uploaded?

No. Parsing uses the browser's DOMParser on this page. Nothing is sent anywhere.

Can it handle large files?

Documents of a few megabytes format quickly. Very large files depend on your device's memory.

Was this helpful?