OFFLINE TOOL / JSON & XML V1.5
DATA / 031OFFLINE

JSON and XML tools

Format, minify and check JSON and XML with line and column of every error, validate JSON against a JSON Schema and XML against an XSD (documented subsets), query with JSONPath (RFC 9535) and XPath 1.0, and convert XML ↔ JSON and JSON ↔ CSV. Numbers are never rounded. Everything runs in your browser; nothing is uploaded.

Tool

Everything runs in this browser: texts and files are never uploaded or stored. Fields take up to 5 MB each; above 200 KB the results follow when typing stops. JSON is strict RFC 8259 (no comments, trailing commas or JSON5); numbers are copied exactly as written. XML: no external DTD or entity is ever loaded.

JSON text

Example dataIllustrative: replace with your own JSON

Runs in this browser. Data is not uploaded or stored.

Check and format

—JSON
—Values
—Depth
—Numbers a double changes

    Document and schema

    Example dataIllustrative: replace with your own document and schema

    “format” is only an annotation in draft 2020-12, so it is not checked unless you ask. Keywords this tool does not check are listed with the results, never skipped silently. $ref follows local JSON pointers (#/$defs/…, #/definitions/…); remote schemas are never loaded.

    Runs in this browser. Data is not uploaded or stored.

    Validation

    —Document
    —Errors
    —Not checked
    —Draft

      Document and query

      Example dataIllustrative: replace with your own document and query
      • $.store.book[0].title child names and indices; $..author anywhere below; [*] every child
      • [-1] last item, [0:2] slice, [::-1] reversed, ['a','b'] several names
      • [?@.price < 10 && @.isbn] filters; length(), count(), match(), search(), value()

      Runs in this browser. Data is not uploaded or stored.

      Matching nodes

      —Nodes
      —Query

        XML document

        Example dataIllustrative: replace with your own XML

        Well-formedness as XML 1.0 with namespaces: one root, matching tags, quoted attributes, declared prefixes, valid characters and references. Entities: the five predefined ones, character references and text entities declared in the document's DOCTYPE (expanded up to 1,000,000 characters); external DTDs and entities are never loaded. Formatting changes only the white space between elements; mixed content, CDATA and xml:space="preserve" stay as written.

        Runs in this browser. Data is not uploaded or stored.

        Check and format

        —XML
        —Elements
        —Attributes
        —Depth

          Document and expression

          Example dataIllustrative: replace with your own document and expression

          XPath 1.0 has no default namespace: elements in a namespace (xmlns="…") need a prefix in the expression, mapped here. Axes child, descendant, parent, ancestor, following(-sibling), preceding(-sibling), attribute, self and the -or-self forms; predicates; the whole function library (id() finds xml:id).

          Runs in this browser. Data is not uploaded or stored.

          Result

          —Result
          —Nodes or value

            Document and schema

            Example dataIllustrative: replace with your own document and schema

            A documented subset of XML Schema 1.0 (see the Method): elements, sequence / choice / all, groups, any, occurrences, attributes, simple and complex content, derivation, and simple types with their facets. Imports, includes, list / union types, identity constraints, xsi:type and xsi:nil are listed as not checked; such a result is not a full validation.

            Runs in this browser. Data is not uploaded or stored.

            Validation

            —Document
            —Errors
            —Not checked
            —Elements

              Convert

              Example dataIllustrative: replace with your own data
              • XML ↔ JSON as xmltodict: attributes “@name”, text “#text”, repeated elements become arrays; XML values stay text. Comments, processing instructions, the DOCTYPE and the place of text between child elements are lost.
              • JSON → CSV: an array of objects, one row each; nested objects become dotted columns (pos.x), arrays their JSON text. CSV → JSON: the first line names the fields.

              Runs in this browser. Data is not uploaded or stored.

              Result

              —Direction
              —Lines or rows
              —Notes

                How the checks work

                Seven small tools for the JSON and XML that machines, MES, ERP and APIs exchange. Every part runs in this browser on the main thread (the page's security policy allows no separate worker in the offline file), so each field takes up to 5 MB of text; above 200 KB the results are recomputed when typing stops, and result tables show the first 500 rows (the CSV has all of them).

                JSON: check, format, minify

                JSON Schema

                JSONPath (RFC 9535)

                XML: well-formedness and formatting

                XPath 1.0

                XSD: the subset that is checked

                Conversions

                Worked examples (the tool's examples)

                1. JSON: an illustrative machine status message on one line has 25 values, depth 3; the counter 12345678901234567890 is listed (a double reads 12345678901234567000) and the formatted text keeps it, as it keeps 41.50.
                2. JSON Schema: the same message with three mistakes gives 3 errors: “Runing” is not one of the allowed states (line 5), quality 1.02 is above the maximum 1 (line 7), unit “kpa” is not allowed (line 10), as jsonschema reports them.
                3. JSONPath: $.readings[?@.value > 0].sensor finds head-1-temp and feeder-07-count (the vacuum reading is negative).
                4. XML: the illustrative bill of materials on one line is well-formed: 20 elements, 12 attributes, depth 3, one namespace.
                5. XPath: with b = urn:factokit:bom, //b:item[b:qty > 2]/b:pn selects R-0402-10K and C-0603-100N.
                6. XSD: with one quantity changed to −4 the document is not valid: 1 error on line 8 (“−4” must be above 0), as libxml2 reports it; the original document is valid.
                7. Convert: XML → JSON with item always an array gives three items; the four ref elements of the first become an array, and the comment is left out.

                Common mistakes

                Files

                How it was checked

                Not verified

                Questions

                Is my JSON or XML uploaded anywhere?
                No. Formatting, validation, queries and conversions run in your browser; the texts and files you open are not sent anywhere and are not stored. The results leave the page only as the files you download or the text you copy.
                Why does formatting not change my numbers?
                Many tools format JSON by reading it into JavaScript numbers and writing it back, which rounds integers beyond 2^53 (9007199254740993 becomes 9007199254740992) and long decimals, and rewrites 1.50 as 1.5. This tool formats from the text itself: only the white space between the tokens changes. It also lists the numbers that a reader using 64-bit doubles would change, so you can decide to send them as strings.
                Are comments or trailing commas allowed in the JSON?
                No. The tool reads strict JSON as RFC 8259 defines it, as most APIs and message brokers do: no comments, no trailing commas, no single quotes and no JSON5. The error message gives the line and column where a reader stops, at the same place as Python’s json module.
                Why does my XPath find nothing although the element is there?
                Usually because of a default namespace. In <bom xmlns="urn:factokit:bom"> every element is in that namespace, and XPath 1.0 has no default namespace, so //item looks for elements without a namespace. Map a prefix to the namespace URI (b = urn:factokit:bom) and write //b:item; the button “Use the document’s namespaces” fills the mapping for you.
                Is the XSD validation complete?
                It checks a documented subset of XML Schema 1.0 that covers most interface and configuration files: element structure, occurrences, attributes, simple types with facets, extension and restriction. Constructs outside the subset (xs:import, list and union types, keys and key references, xsi:type) are listed as not checked, so a “valid” result then means valid for the checked part only. For a final check use a full validator such as xmllint or your integration platform.
                How is XML converted to JSON?
                With the convention of the widely used xmltodict library: attributes become members named "@name", the text of an element with attributes or children becomes "#text", a repeated element becomes an array, and values stay text. Comments, processing instructions and the order between different child elements are not kept, so a round trip back to XML gives the same data but not always the same document.