View XML and JSON documents
A practical review of XML and JSON viewers: what formatting and tree views change, when they keep meaning intact, and when you need the raw text.
An XML or JSON viewer takes a structured document and shows it in a form people can scan: indented text, syntax colors, collapsible trees, and often a validation message when the document is malformed. This review covers what that transformation does and does not change, and how to tell whether the viewed or reformatted output is safe for your purpose. No specific product was tested. The points below are general principles of the two formats and of common viewer designs, not measurements of any tool.
Is a viewer suitable for what you need?
For reading, debugging and checking that a document parses, a viewer is usually the right tool. The main benefit is legibility. A single minified line of JSON or a deeply nested XML payload becomes a structure you can navigate, and a parse error points you to a location instead of leaving you to hunt for it.
The key tradeoff is that the friendly view is not always identical to the source. Pretty-printing adds whitespace. A tree view may re-serialize values after parsing them. Some viewers sort keys, drop comments or normalize formatting. For JSON these changes rarely alter meaning. For XML, and for some JSON edge cases covered below, they can.
Keep the original plain text, and work from it, in these cases:
- You need byte-exact content, for example when computing or verifying a hash, signature or checksum.
- The document will be compared with a diff tool, and the formatting changes would bury the real differences.
- The XML contains mixed content (text and elements together) or relies on whitespace being preserved.
- The JSON contains very large integers, high-precision decimals or duplicate keys.
- The content is sensitive and you have not confirmed where the viewer processes it.
What the transformation actually changes
Several kinds of change are lumped together under "viewing", and they differ in whether they touch the stored characters at all.
| Operation | Changes stored characters? | Typical risk to meaning |
| Syntax highlighting | No, presentation only | None to the data. Colors may not survive plain-text copy. |
| Collapsible tree display | No, presentation only | None to the data. Hidden nodes may be missed when reading or searching. |
| Pretty-printing (indentation and line breaks) | Yes, whitespace is added | Usually none for JSON. Can matter for XML text content. |
| Minifying | Yes, whitespace is removed | Usually none for JSON. Can matter for XML text content. |
| Parse and re-serialize | Possibly: number formatting, escaping, key order, comments | Depends on the parser. See the edge cases below. |
| Validation | No, it only reports | False confidence if "well-formed" is mistaken for "valid against a schema". |
Formatting JSON
JSON treats whitespace between tokens as insignificant, so indenting or minifying a document leaves the data unchanged. These two forms describe the same object:
{"id":7,"tags":["a","b"]}
{
"id": 7,
"tags": [
"a",
"b"
]
}
Risk appears when a viewer parses the JSON into native values and then writes it back out. In environments that store numbers as double-precision floating point, which includes standard JavaScript parsing, integers larger than 2^53 cannot all be represented exactly. A viewer built that way could display or re-emit a different number than the source contains:
Source: {"order_id": 12345678901234567890}
After JS parse: {"order_id": 12345678901234567000}
Duplicate keys are another edge case. The JSON specification leaves their handling unclear, and many parsers silently keep only the last value. A tree view built on such a parser would show one entry where the source has two. Unicode escape sequences may be shown decoded or kept escaped. Key order may also be rearranged if the viewer sorts keys, which does not change meaning for most consumers but does affect diffs.
Formatting XML
XML is less forgiving. Whitespace inside elements that contain text is part of the document's character data, so adding indentation can change the text a consumer reads. Compare:
<p>Hello <b>world</b></p>
<p>
Hello
<b>world</b>
</p>
The second version contains extra newlines and spaces in its text content. Many applications ignore that whitespace, but some do not, and an xml:space="preserve" attribute explicitly asks that whitespace be kept. Re-serializing XML can also change details that are equivalent to an XML parser but not to a byte comparison: attribute order and quoting style, empty-element syntax, CDATA sections becoming escaped text, entity references being expanded, and, depending on the tool, comments or processing instructions being dropped. Namespace prefixes should be preserved by a careful tool, but that is worth checking rather than assuming.
What "validation" means
A JSON validator usually confirms that the text parses. For XML, "well-formed" means the markup is syntactically correct, while "valid" means it also conforms to a DTD or schema. A viewer that reports no errors has only confirmed well-formedness unless it states that it checked against a schema you supplied. The same applies to JSON Schema: parsing successfully is not the same as matching a schema.
Will the result stay usable after copying or sharing?
Pretty-printed text copied as plain text generally remains valid JSON or XML, subject to the whitespace caveats above for XML. Copying from a tree view is less predictable. Depending on the implementation, a copy may capture the rendered labels, the toggle symbols, only the expanded nodes, or a re-serialized fragment instead of the original source. If a viewer offers an explicit "copy raw" or "copy formatted" action, that is more dependable than selecting text from the tree. When pasting into email or rich-text editors, syntax colors may come along as formatting, and the editor may then replace straight quotes with curly ones. That breaks JSON and XML.
Search is affected too. Browser find-in-page typically cannot match text inside collapsed nodes that are not rendered. Expanding the whole tree, or searching the raw text, avoids missed matches.
Accessibility depends entirely on how a particular viewer builds its interface. A tree that exposes proper tree roles and keyboard navigation can be workable with a screen reader. A tree built from generic elements with click-only toggles may not be. No assistive technology testing was available for this review, so no specific viewer can be described as accessible. Raw or pretty-printed plain text in a standard text area is the safer equivalent to offer anyone relying on a screen reader or keyboard navigation.
Privacy is a separate question from appearance. Whether a web-based viewer processes documents locally in the browser or sends them to a server cannot be inferred from its design or its marketing copy. Look for documentation that states this, or assume the data may leave your machine. Configuration files, API responses and logs often contain tokens or personal data, so redact them or use a local tool.
A quick check before relying on the output
- Decide whether you need to read the document or reuse the output. For reading, any reliable viewer works. For reuse, keep the original source.
- If the output will be reused, confirm whether the tool only adds whitespace or parses and re-serializes.
- Test with a sample that includes your edge cases: large numbers, duplicate keys, mixed-content XML, comments, CDATA and namespaces.
- Confirm whether validation means parsing only or checking against a schema.
- Check how copying from the view behaves before sharing a fragment.
- Find documented information on where the data is processed before pasting anything sensitive.
Evidence gaps
No specific viewer, version or destination application was examined for this review. Behaviors described as possible, such as number precision loss, dropped duplicate keys, comment removal and tree-copy quirks, are general properties of the formats and of common parsing approaches. Whether a given tool shows them has to be confirmed by testing that tool with representative input.