SmartTechnology solutions for business

XML and JSON Converter

Convert structure with options for attributes and repeated values. It does not promise identical conversion for every XML file.

Convert

Attributes become "@name" keys, text next to child elements becomes "#text", and repeated elements become a list. Values stay text. DOCTYPE and custom entities are refused.

Your result

Paste XML or JSON and the converted text appears here.

How to use it

  1. Choose the direction.
  2. Paste the text or press Try a sample.
  3. Copy the result or download it as a file.

Examples

  • An attribute and text<book id="1"><title>Kalila</title></book> {"book": {"@id": "1", "title": "Kalila"}}
  • A repeated element<a><b>1</b><b>2</b></a> {"a": {"b": ["1", "2"]}}
  • From JSON{"note": {"@lang": "ar", "#text": "مرحبا"}} <note lang="ar">مرحبا</note>
Tool details and privacy

Paste XML to get tidy JSON, or paste JSON to get indented XML with its declaration. Swap converts the result back again.

Many older services speak XML while modern code reads JSON.

Options

  • Attributes become keys starting with @, text next to other elements becomes "#text", and repeated elements become a list.
  • Comments, the <?xml?> line, CDATA, and standard and number entities are read.
  • JSON with several keys, or a list, is wrapped in a <root> element.

Limits

  • Values stay text in JSON (such as "120").
  • DOCTYPE and entity declarations are refused for safety, and errors show line and column.

Privacy

What you type stays in your browser. Nothing is uploaded or saved on the server.

Questions

Why is "120" quoted?

XML does not tell numbers from text, so it stays text.

Are namespaces such as x:price kept?

Yes, as part of the name.

Does a file survive converting twice?

Mostly, apart from comments and the order of text among elements.

Is anything uploaded?

No.

Related tools

All tools