Free XSLT 1.0 stylesheet to transform XML data to JSON

While looking for an XSLT 1.0 stylesheet, which is able to transform XML to JSON, I had to realize that none of the existing stylesheets generate valid JSON code.
Most of them have problems if a node has sub-nodes and attributes at the same time, others don't handle arrays correctly. But both are essential requirements for me, so I've decided to write my own XML to JSON transformation stylesheet.

Features & Limitations


This work is licensed under the "Creative Commons — Attribution-Share Alike 3.0 Germany" license.

That means you are free:

to Share
to copy, distribute and transmit the work
to Remix
to adapt the work

Under the following conditions:

You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
Share Alike.
If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.
For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
Any of the above conditions can be waived if you get permission from the copyright holder.
The author's moral rights.


Filename Version Release Date Size
xml2json.xsl v1.0.0 2009-08-09 3.52 KiB v1.0.0 (ZIP archive) 2009-08-09 1.07 KiB


This output is formatted to give you an overview about the object layout. The code which is returned by the stylesheet doesn't contain spaces and line-feeds to get the object code as small as possible.

Move the mouse cursor above a key name, to get more details about it.

Test your own XML file (max. 256 KiB):


If you have questions, improvement ideas, bug reports or anything else, feel free to contact me at