Convert XML to JSON without uploading the document
XML converts to JSON locally. The two formats do not map cleanly, because attributes, namespaces, ordering and repeated elements each need a convention, so read the result rather than assuming it round-trips.
At a glance
- Tool
- /tools/xml-to-json
- Input
- XML
- Output
- JSON
- No natural JSON equivalent
- Attributes, namespaces, comments, processing instructions
- Main ambiguity
- One repeated element can become an object or an array of one
- Usual sources
- Accounting and banking exports, filings, product feeds, integration payloads
In detail
XML lives in the boring, high stakes places: bank and accounting exports, statutory filings, health and insurance integrations, product feeds between suppliers and marketplaces. Those documents carry account numbers and personal records, and the reason somebody is converting one at speed is usually that two systems have to talk by the end of the day. That is exactly the pressure under which a live payload gets pasted into the first tool that appears.
The mapping is genuinely ambiguous, so look at what you got. XML distinguishes an attribute from a child element and JSON has one kind of key. XML has namespaces and prefixes and JSON has none. XML preserves the order of sibling elements and a JSON object makes no promise about key order. Whatever convention the conversion used, your consumer has its own expectation, and the two need to agree.
The repeated element trap deserves a test of its own. A document containing one line item and a document containing three can produce different shapes, an object in one case and an array in the other, which breaks any consumer that was built from a single sample. Convert both cases before you write code against the result.
Verify locality by converting with the network off. It works, and for an integration payload full of customer records that is not a small thing: the document went from a file on your disk to a shape you can read without any third party seeing a single account number.
Things that catch people out
- A sample with one repeated element and a sample with several can produce different shapes. Test both.
- XML supports references to external documents. Treat XML from an unknown sender as untrusted input everywhere downstream, not just here.
- Comments and processing instructions are not carried into JSON, so anything a colleague explained in a comment is gone.
- Numbers in XML are text like everything else in the document. A leading zero or a trailing decimal that carried meaning can be normalised away once the value becomes a JSON number.
Try it: Hash Generator
The file hasher is on every page here because it takes any file at all and proves the point: disconnect from the network, drop a file in, and it still returns a checksum you can compare against a published one.
Hash Generator
LOCAL · Browser-OnlyGenerate MD5, SHA-1, SHA-256, SHA-384, SHA-512, SHA3-256, SHA3-512, Keccak-256, CRC32, and HMAC hashes from text or files
MD5 is cryptographically broken and should not be used for security purposes. Use SHA-256 or SHA-512 instead.
Related Working without uploading
All working without uploading →Convert YAML to JSON without uploading the file
Convert YAML and JSON both ways in your browser. Infrastructure YAML is configuration, and configuration is where credentials sit.
Format and validate JSON without uploading it
Tidy and check JSON in your browser. The JSON people paste into a formatter is usually a live API response full of real records.
View a file as a hex dump without uploading it
Inspect any file's raw bytes in your browser. If you cannot identify a file, uploading it to find out is the wrong first move.
Compare two files without uploading either of them
Diff two versions of a document or a config in your browser. A hosted comparison receives both files, which doubles the exposure.
Minify JavaScript without uploading your source
Minify scripts and stylesheets in your browser. Source carries comments, endpoints and internal names, and minifying is not obfuscation.
Hash a file without uploading it
Checksum a file in your browser with SHA-256 and eight other algorithms. A hash proves the bytes match; it keeps nothing secret.
Tools for this
- XML to JSON Converter Free online XML to JSON converter - convert XML documents to JSON format
- JSON Formatter JSON formatter and validator online - format, beautify, and validate JSON data instantly in your browser
- Code Formatter Free online code formatter - beautify and format JavaScript, CSS, HTML, and more