How to Format and Validate JSON and XML
Find common JSON and XML syntax errors, format nested data, and interpret parser feedback.
Formatting and validation are separate steps
Formatting adds indentation and line breaks to make nested data readable. Syntax validation checks whether a parser can read the document. A valid document can still contain the wrong fields or values for an application, which requires schema or business-rule validation.
Common JSON problems
JSON requires double-quoted property names and strings, correct commas, balanced braces or brackets, and valid escapes. It does not allow comments or trailing commas in the standard syntax. Minification removes insignificant whitespace without deleting represented values.
Common XML problems
XML requires one root element, matching case-sensitive tags, quoted attributes, and escaped reserved characters. Namespaces affect element identity. A well-formed XML file is not necessarily valid against an XSD or another document-specific schema.
A useful workflow
- Paste only data you are permitted to process.
- Validate before formatting so errors remain easy to locate.
- Use reported line and column details to inspect nearby delimiters.
- After conversion to C# models, review inferred nullability, arrays, numbers, and inconsistent sample values.