All Over Tools logo
Tool Combiner
Analyze Tools Clean Tools Compare Tools Convert Tools Data Validation Extract Tools Format Tools Generate Tools Organize Tools Transform Tools
Image Tools Video Tools Audio Tools Subtitle Tools Font Tools
Analyze Tools Clean Tools Compress Tools Convert Tools Edit Tools Extract Tools Generate Tools Merge Tools Organize Tools Redact Tools Repair Tools Split Tools
Analyze Tools Clean Tools Compare Tools Convert Tools Extract Tools Generate Tools Merge Tools Transform Tools Validate Tools
Business Calculators Construction Calculators Date And Time Calculators Education Calculators Financial Calculators Food Calculators Health Calculators Math Calculators Science Calculators Sports Calculators Statistics Calculators
Blog About Us Contact Us

XML to JSON Converter

Convert XML files into JSON - choose how attributes are represented, pick which element becomes the JSON root, output pretty-printed or compact JSON, and handle non-UTF-8 encodings. Invalid XML is flagged with a clear, readable error. Everything runs locally in your browser.

Drop XML files here

or

XML

What This Tool Does

The XML to JSON Converter converts XML files in your browser. Use the controls to choose how attributes, text, the JSON root, encoding, and output formatting are handled, then review the JSON preview before downloading.

How to Convert XML to JSON

  1. Drop one or more XML files into Drop XML files here, or click browse files.
  2. Set Input encoding to Auto-detect or choose UTF-8, UTF-16 LE, ISO-8859-1 (Latin-1), or Windows-1252.
  3. Choose an Attribute handling mode and edit Attribute prefix if you use Prefix keys.
  4. Set Text content key if you want a key other than #text for mixed text content.
  5. If repeated direct child elements are detected, choose a JSON root.
  6. Choose Output format. For Pretty (indented), select 2 spaces, 4 spaces, or Tab under Indent size. Choose Compact (minified) for unformatted JSON.
  7. Choose whether to Trim whitespace in text. Leave Ignore XML declaration unchecked to include declaration metadata under ?xml when present, or check it to omit that metadata.
  8. Review the automatically generated JSON preview, then download each JSON file or click Download all as ZIP.

Attribute Handling Options

Choose how XML attributes become JSON keys:

  • Prefix keys uses the editable Attribute prefix, which defaults to @_.
  • Group under @attributes places attributes in an @attributes object.
  • Merge with elements writes attributes as plain keys alongside element keys.
  • Ignore attributes leaves attributes out of the JSON.

JSON Roots, Text, and Repeated Elements

The JSON root selector appears when the tool detects repeated direct child elements. Repeated sibling elements with the same tag name become a JSON array. When an element contains both text and child elements, its text is stored under #text by default or under the chosen Text content key. CDATA is treated as regular text content.

Output Format and XML Declaration

Pretty (indented) uses 2 spaces, 4 spaces, or a tab. Compact (minified) removes formatting whitespace. These formatting choices are separate from Ignore XML declaration: leaving that checkbox unchecked includes parsed XML declaration metadata under ?xml when present, while checking it omits the metadata.

Input Encoding and XML Validation

Auto-detect reads the encoding from the XML declaration for input decoding. This is separate from whether declaration metadata appears in the output. To override decoding, choose UTF-8, UTF-16 LE, ISO-8859-1 (Latin-1), or Windows-1252. Malformed XML produces a readable validation error and may include line and column details.

Batch Conversion and Downloads

Add multiple XML files together. Each converted file has its own JSON output and download action. After successful conversions, Download all as ZIP becomes available.

Privacy and Practical Limits

Files are processed locally in your browser and are not uploaded to a server. Available device memory is the practical limit for processing. For very large generated JSON, the live preview shows the first 20,000 characters, while the downloaded file contains the full JSON.

Frequently Asked Questions

What happens to XML text content mixed with child elements?

When an element has both text and child elements (mixed content), the text is stored under a dedicated key - #text by default, or a key you choose - alongside the child elements.

Are CDATA sections supported?

Yes. CDATA content is treated the same as regular text content and included in the element's text or value.

What if an element repeats multiple times under the same parent?

Repeated sibling elements with the same tag name are automatically collected into a JSON array.

Is there a file size limit?

The practical limit is your device's memory. The live preview shows the first 20,000 characters of the generated JSON for very large documents, but the full JSON is still included in the downloaded file.

Can I convert multiple XML files at once?

Yes. Drop as many files as you like, convert them into separate JSON files, and download them individually or as a ZIP.

Related Tools

12 views