PHPackages                             extphp/xml-to-json - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. extphp/xml-to-json

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

extphp/xml-to-json
==================

An XML to JSON converter that will properly preserve attributes.

v0.2.0(6y ago)022.4k↓27.3%MITPHP

Since Aug 21Pushed 6y agoCompare

[ Source](https://github.com/extphp/xml-to-json)[ Packagist](https://packagist.org/packages/extphp/xml-to-json)[ RSS](/packages/extphp-xml-to-json/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

XML to JSON
===========

[](#xml-to-json)

[![Build Status](https://camo.githubusercontent.com/580db6267677f3f4ccbfb8aebea119dbf21ff1cf178916addf6691a6e63b713a/68747470733a2f2f7472617669732d63692e6f72672f6578747068702f786d6c2d746f2d6a736f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/extphp/xml-to-json)[![Latest Stable Version](https://camo.githubusercontent.com/3ee76763b8c896576abe94dd7cb90bb5f9eb5f715420566992178d9caa290ef6/68747470733a2f2f706f7365722e707567782e6f72672f6578747068702f786d6c2d746f2d6a736f6e2f762f737461626c65)](https://packagist.org/packages/extphp/xml-to-json)[![License](https://camo.githubusercontent.com/46faf2f17a56b7212ab1a17d920e5f53351675ba5435428b8370b66623eac545/68747470733a2f2f706f7365722e707567782e6f72672f6578747068702f786d6c2d746f2d6a736f6e2f6c6963656e7365)](https://packagist.org/packages/extphp/xml-to-json)[![Total Downloads](https://camo.githubusercontent.com/78480c5693817d57aeabf72b5a67b648833e8ec8f2294b02bd89bc88bd444886/68747470733a2f2f706f7365722e707567782e6f72672f6578747068702f786d6c2d746f2d6a736f6e2f646f776e6c6f616473)](https://packagist.org/packages/extphp/xml-to-json)

An XML to JSON converter that will properly preserve attributes.

Installation
------------

[](#installation)

`composer require extphp/xml-to-json`

Usage
-----

[](#usage)

A generic usage, usefull when the `SimpleXMLElement` instance already exists.

```
use ExtPHP\XmlToJson\XmlToJsonConverter;

$string = 'child value';
$xml = simplexml_load_string($string);

$converter = new XmlToJsonConverter($xml);
$converter->toArray();      // convert xml to array
$converter->toJson();       // convert xml to json
```

A quick approach when you need to convert a XML string to array or json.

```
use ExtPHP\XmlToJson\JsonableXML;

$xml = new JsonableXML('child value');
json_encode($xml);      // convert xml to json

// These methods are also available directly on the xml object.
$xml->toArray();        // convert xml to array
$xml->toJson();         // convert xml to json
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

2463d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef360de3f6d1e1a2eb47c55b310bf697192f25dff9bf9733607404e1bf0ddc63?d=identicon)[bcismariu](/maintainers/bcismariu)

---

Top Contributors

[![bcismariu](https://avatars.githubusercontent.com/u/10166477?v=4)](https://github.com/bcismariu "bcismariu (8 commits)")

---

Tags

jsonxmlconverter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/extphp-xml-to-json/health.svg)

```
[![Health](https://phpackages.com/badges/extphp-xml-to-json/health.svg)](https://phpackages.com/packages/extphp-xml-to-json)
```

###  Alternatives

[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[goetas-webservices/xsd2php

Convert XSD (XML Schema) definitions into PHP classes and JMS metadata

2411.6M37](/packages/goetas-webservices-xsd2php)[goetas-webservices/xsd2php-runtime

Convert XSD (XML Schema) definitions into PHP classes

4910.9M36](/packages/goetas-webservices-xsd2php-runtime)[akrabat/rka-content-type-renderer

Render an array to a JSON/XML/HTML PSR-7 Response based on a PSR-7 Request's Accept header.

40443.2k1](/packages/akrabat-rka-content-type-renderer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
