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
Audio Tools Font Tools Image Tools Subtitle Tools Video Tools
Archive Tools Document Tools Ebook Tools File Management Tools PDF Tools Presentation Tools
Config Tools Database Tools Dataset Tools JSON Tools Parser Tools Spreadsheet Tools XML 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 XML to JSON Converter changes

Choose one or more XML files, set how attributes and text are written, and download the JSON results. The XML to JSON Converter processes the files in your browser. It also lets you select a repeated element as the JSON root, choose an output format, and set the input encoding.

How to convert XML to JSON

  1. Drop one or more XML files into "Drop XML files here", or click "browse files".
  2. Choose Input encoding. Leave Auto-detect selected or choose a listed encoding.
  3. Select Attribute handling, then set Attribute prefix when Prefix keys (@_id) is selected.
  4. Set Text content key and decide whether to keep Trim whitespace in text checked.
  5. Choose a JSON root when repeated direct child elements are detected.
  6. Set Output format and Indent size, review JSON preview, then click Download converted files.

How XML attributes become JSON keys

Attribute handling sets where each XML attribute goes. With Prefix keys (@_id), the value of id becomes @_id. Attribute prefix changes the characters placed before the attribute name.

<user id="42" role="admin"><name>Alice</name></user>

{
  "user": {
    "@_id": "42",
    "@_role": "admin",
    "name": "Alice"
  }
}

Group under @attributes places attributes inside an @attributes object. Merge with elements writes them as ordinary keys beside child elements. Ignore attributes omits them from the JSON.

How to choose a JSON root for repeated elements

JSON root appears when a parent has repeated direct child elements. A document with two book elements under catalog can show /catalog/book as a selectable path. Selecting it returns those book elements as an array under the book key.

What text and XML declarations become

Trim whitespace in text starts checked, so surrounding whitespace is removed before text is written. An element with only text becomes a JSON string. Text alongside child elements is stored under Text content key, which defaults to #text. CDATA is read as text too.

Leave Ignore XML declaration unchecked to include declaration attributes under ?xml when the input has an XML declaration. Check it to omit that metadata. Pretty (indented) uses Indent size. Compact (minified) removes JSON formatting whitespace.

Which input encodings and XML errors are handled

Input encoding includes Auto-detect, UTF-8, UTF-16 LE, ISO-8859-1 (Latin-1), and Windows-1252. Auto-detect can read an encoding named in the XML declaration. Choosing a listed encoding overrides it. Unsupported declared encodings and malformed XML produce a warning from the parser.

Where XML to JSON conversion comes up

For a catalog export, select a repeated product path as JSON root and download the resulting array. For an XML configuration file, use JSON preview to inspect attribute names, text keys, and declaration metadata before saving it.

Add several XML reports together when they need separate JSON files. The file list shows each file, its node count, and its size. Download converted files saves one JSON file or a ZIP when several files are ready.

When to use XML Convert Tools

Use XML to JSON Converter when the destination expects JSON and you need control over attributes, text, encoding, or the root path. For another XML conversion task, open the XML Convert Tools category and choose the matching page.

Frequently asked questions

How do I convert an XML file to JSON with attributes?

Select the XML file, then choose an Attribute handling mode. Prefix keys (@_id) adds the selected Attribute prefix, Group under @attributes nests attributes, Merge with elements uses ordinary keys, and Ignore attributes omits them.

Can I convert multiple XML files to JSON?

Yes. Add multiple files through Drop XML files here or browse files, and the converter creates a separate JSON result for each file. The file list provides individual download buttons, and Download converted files handles the set.

How does the XML to JSON Converter handle repeated elements?

Repeated sibling elements with the same name become a JSON array. If they are direct children in a detected path, choose that path in JSON root to convert those elements as the selected root.

Can I convert XML encoded as UTF-16 or Windows-1252?

Yes. Choose UTF-16 LE or Windows-1252 under Input encoding, or leave Auto-detect selected when the XML declaration identifies the encoding.

Does the XML to JSON Converter upload my files?

No. The page reads the selected files and builds the JSON in your browser; its conversion code does not send the XML content to a server.

Related Tools

55 views