Pixuna

Pixuna Guide

How to Format and Validate JSON and XML

Pretty-print or minify JSON and XML, find syntax errors, and learn what a browser-based validator can and cannot check.

Published · 2 min read

Open JSON Formatter

Formatting versus validating

Formatting changes whitespace to make data readable, or removes it to make data smaller. Validating checks that the text follows the language’s grammar. Pixuna’s JSON Formatter and XML Formatter do both: they parse your input first and only then re-print it, so a successful format also means the syntax is valid.

Common JSON mistakes

The most frequent JSON errors are trailing commas, single quotes instead of double quotes, unquoted keys, comments, and a missing closing bracket. The formatter reports the parser’s message so you can locate the problem.

You can choose 2 spaces, 4 spaces, or tabs, minify the output, or sort object keys alphabetically. Sorting is helpful for comparing two files but changes key order, so do not use it where order matters to you.

  • Whole numbers beyond JavaScript’s safe integer range can lose precision when parsed in a browser.
  • Duplicate keys in one object are collapsed to the last value by the parser.

What the XML formatter checks

The XML Formatter uses your browser’s XML parser to confirm the document is well-formed: matching tags, one root element, and properly escaped characters. It does not validate against a schema (XSD) or DTD, so a well-formed file can still be wrong for the system that will consume it.

Formatting trims whitespace around text and puts child elements on their own lines. In documents where text sits next to child elements (mixed content, as in some markup languages), that whitespace can be meaningful, so use Validate only or Minify instead of Format for such files.

Keeping data private

Both formatters run in your browser tab and do not send your data to a server. Even so, avoid pasting live secrets such as API keys or passwords into any web page when you can use sample data instead.