PHPackages                             awesome/simdjson\_plus - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. awesome/simdjson\_plus

ActivePhp-ext[Validation &amp; Sanitization](/categories/validation)

awesome/simdjson\_plus
======================

Parsing gigabytes of JSON per second in PHP using the simdjson library.

1.0.0(1y ago)19.2k↓73.8%4Apache-2.0C++PHP ^8.1

Since Apr 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/awesomized/simdjson-plus-php-ext)[ Packagist](https://packagist.org/packages/awesome/simdjson_plus)[ Docs](https://github.com/awesomized/simdjson-plus-php-ext)[ RSS](/packages/awesome-simdjson-plus/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

`awesome/simdjson_plus`
=======================

[](#awesomesimdjson_plus)

[![Tests status](https://github.com/awesomized/simdjson-plus-php-ext/workflows/Tests/badge.svg)](https://github.com/awesomized/simdjson-plus-php-ext/actions?query=workflow%3ATests)[![Latest Stable Version](https://camo.githubusercontent.com/b8ed9ff7ec3ddfd4f39cc3d47c71b1ce8d6eb07274251df73cd2b7235da57a07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617765736f6d652f73696d646a736f6e5f706c7573)](https://packagist.org/packages/awesome/simdjson_plus)

🚀 Blazing-fast JSON encoding and decoding for PHP, powered by the [simdjson project](https://github.com/lemire/simdjson).

*This is a fork of [JakubOnderka/simdjson\_php](https://github.com/JakubOnderka/simdjson_php) (which is a fork of [crazyxman/simdjson\_php](https://github.com/crazyxman/simdjson_php))*

Since the [simdjson](https://pecl.php.net/package/simdjson) PECL extension seems to be unmaintained, or at least slow to [accept PRs for improvements](https://github.com/crazyxman/simdjson_php/pulls), we packaged this up under a new name (`simdjson_plus`) to avoid naming conflicts and published it on Packagist (instead of PECL) for easier installation.

It's a drop-in replacement for the PECL extension, with additional features from JakubOnderka, such as accelerated JSON encoding (not just decoding) and optimizations.

Performance Comparison: How Fast is simdjson\_plus?
---------------------------------------------------

[](#performance-comparison-how-fast-is-simdjson_plus)

OperationPHP Built-insimdjson\_plusSpeedupDecode to array1.48 ms0.46 ms**3.2×**Decode to object1.56 ms0.54 ms**2.9×**Encode0.67 ms0.26 ms**2.5×**Encode (pretty print)0.83 ms0.31 ms**2.6×**Validate1.37 ms0.22 ms**6.2×**Count items1.51 ms0.16 ms**9.4×**Tests were conducted using PHP 8.3 on an [Apple M1 Max](https://en.wikipedia.org/wiki/Apple_M1#M1_Pro_and_M1_Max). For test specification see `TwitterDecodeBench.php` and `TwitterEncoderBench.php`.

Additionally, simdjson\_plus reduces memory usage compared to `json_decode()`. For example, when decoding twitter.json, memory consumption drops from 3.01 MB to 2.47 MB due to efficient array key deduplication.

Related SIMD-accelerated PHP extensions
---------------------------------------

[](#related-simd-accelerated-php-extensions)

- [crc\_fast](https://packagist.org/packages/awesome/crc_fast) PHP extension for SIMD-accelerated CRC calculations at &gt;100GiB/s.
- [simdutf](https://packagist.org/packages/awesome/simdutf) PHP extension for Unicode validation and transcoding at billions of characters per second using the [simdutf](https://github.com/simdutf/simdutf) project.

Requirements
------------

[](#requirements)

- PHP 8.1+ (PHP 8.2+ recommended for maximum performance)
- g++ (version 7 or better) or clang++ (version 6 or better)
- A 64-bit system with a command-line shell (e.g., Linux, macOS, FreeBSD)

Changes
-------

[](#changes)

See the [change log](CHANGELOG.md).

Installing
----------

[](#installing)

Use [Composer](https://getcomposer.org) to install this library using [PIE](https://github.com/php/pie):

```
composer install awesome/simdjson-plus
```

Compilation Instructions for Linux
----------------------------------

[](#compilation-instructions-for-linux)

To compile simdjson\_plus, run the following commands:

```
phpize
./configure
make
make test
make install
```

Once installed, add this line to your `php.ini` file:

```
extension=simdjson_plus.so
```

Usage Examples
--------------

[](#usage-examples)

```
$jsonString =
  string(2) "30"
}
*/

// check if the key exists. return true|false|null. "true" exists, "false" does not exist,
// throws for invalid JSON.
$res = simdjson_key_exists($jsonString, "/Image/IDs/1");
var_dump($res) //bool(true)

// count the values
$res = simdjson_key_count($jsonString, "/Image/IDs");
var_dump($res) //int(5)
```

Encoder
-------

[](#encoder)

Most of available options of default `json_encode()` method are not supported by `simdjson_encode()` as they are usually useless.

`simdjson_encode($value)` method has similar behaviour as `json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR)`

Supported options are:

- `SIMDJSON_PRETTY_PRINT` - use whitespace in returned data to format it
- `SIMDJSON_INVALID_UTF8_SUBSTITUTE` - convert invalid UTF-8 characters to `\0xfffd` (Unicode Character 'REPLACEMENT CHARACTER' �)
- `SIMDJSON_INVALID_UTF8_IGNORE` - ignore invalid UTF-8 characters
- `SIMDJSON_APPEND_NEWLINE` - append new line character (`\n`) to end of encoded string. This is useful when encoding data to JSONL format as PHP strings are immutable.

Differences are:

- uses different algorithm to convert floating-point number to string, so string format can be slightly different
- even when `JSON_UNESCAPED_UNICODE` is enabled, PHP `json_encode()` escapes some Unicode chars that do not need to be escaped. `simdjson_encode()` escape just Unicode chars that needs to be escaped by JSON spec.
- simdjson will throw `SimdJsonEncoderException` exception in case of error

### Base64 encoding

[](#base64-encoding)

JSON format do not support binary data. Common way how to transfer binary data in JSON encoding is using base64 encoding. If you need to include base64 encoded value into JSON, you can use `SimdJsonBase64Encode` class that offers optimised converting to base64 value into JSON and use less memory. As creating new object in PHP is relatively slow, this approach make sense for string longer than 1 kB.

```
$fileContent = file_get_contents("example.jpg");
$fileContentEncoded = new SimdJsonBase64Encode($fileContent);
simdjson_encode(['image' => $fileContentEncoded]); // returns {"image":"TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcmsu..."}
```

You can also use base64url encoding (RFC 4648 §5) by setting second argument to true: `new SimdJsonBase64Encode($fileContent, true);`

### Encode to stream

[](#encode-to-stream)

For large data sets, simdjson\_plus provides the `simdjson_encode_to_stream()` function to save data directly to a file or output buffer.

```
$bigStructure = [...];
simdjson_encode_to_stream($bigStructure, fopen("file.json", "w")); // save to file.json
simdjson_encode_to_stream($bigStructure, fopen("php://output", "w")); // send to output buffer
```

Decoder
-------

[](#decoder)

There are some differences from `json_decode()` due to the implementation of the underlying simdjson library. This will throw a `SimdJsonDecoderException` if simdjson rejects the JSON.

Note that the simdjson PECL is using a fork of the simdjson C library to imitate php's handling of integers and floats in JSON.

1. The maximum string length that can be passed to `simdjson_decode()` is 4GiB (4294967295 bytes). `json_decode()` can decode longer strings.
2. The handling of max depth is counted slightly differently for empty vs non-empty objects/arrays. In `json_decode`, an array with a scalar has the same depth as an array with no elements. In `simdjson_decode`, an array with a scalar is one level deeper than an array with no elements. For typical use cases, this shouldn't matter. (e.g. `simdjson_decode('[[]]', true, 2)` will succeed but `json_decode('[[]]', true, 2)` and `simdjson_decode('[[1]]', true, 2)` will fail.)

### Decode from stream

[](#decode-from-stream)

If you need to decode a big file from JSON format that you want to save to a file or send to a user, you can use the `simdjson_decode_from_stream` method.

```
simdjson_decode_from_stream(fopen("file.json", "r")); // load from file.json
simdjson_decode_from_stream(fopen("php://input", "r")); // send by user
```

Benchmarks
----------

[](#benchmarks)

See the [benchmark](./benchmark) folder for more benchmarks.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance44

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

445d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/569776?v=4)[Don MacAskill](/maintainers/onethumb)[@onethumb](https://github.com/onethumb)

---

Top Contributors

[![JakubOnderka](https://avatars.githubusercontent.com/u/163343?v=4)](https://github.com/JakubOnderka "JakubOnderka (127 commits)")[![crazyxman](https://avatars.githubusercontent.com/u/6291797?v=4)](https://github.com/crazyxman "crazyxman (88 commits)")[![TysonAndre](https://avatars.githubusercontent.com/u/1904430?v=4)](https://github.com/TysonAndre "TysonAndre (67 commits)")[![sandrokeil](https://avatars.githubusercontent.com/u/3597436?v=4)](https://github.com/sandrokeil "sandrokeil (31 commits)")[![onethumb](https://avatars.githubusercontent.com/u/569776?v=4)](https://github.com/onethumb "onethumb (22 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (3 commits)")[![WeaponMan](https://avatars.githubusercontent.com/u/4890020?v=4)](https://github.com/WeaponMan "WeaponMan (3 commits)")

---

Tags

decodingencodingextensionhardware-accelerationjsonparsingphpvalidationjsonencoderdecodersimd

### Embed Badge

![Health badge](/badges/awesome-simdjson-plus/health.svg)

```
[![Health](https://phpackages.com/badges/awesome-simdjson-plus/health.svg)](https://phpackages.com/packages/awesome-simdjson-plus)
```

###  Alternatives

[seld/jsonlint

JSON Linter

1.3k228.7M271](/packages/seld-jsonlint)[opis/json-schema

Json Schema Validator for PHP

65243.6M302](/packages/opis-json-schema)[ergebnis/json-schema-validator

Provides a JSON schema validator, building on top of justinrainbow/json-schema.

3630.9M7](/packages/ergebnis-json-schema-validator)[geraintluff/jsv4

A (coercive) JSON Schema v4 Validator for PHP

116465.4k4](/packages/geraintluff-jsv4)[romaricdrigon/metayaml

Using \[Yaml|Xml|json\] schemas files to validate \[Yaml|Xml|json\]

103312.7k8](/packages/romaricdrigon-metayaml)[paulzi/yii2-json-behavior

Yii2 json attribute behavior

75546.8k3](/packages/paulzi-yii2-json-behavior)

PHPackages © 2026

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