PHPackages                             lazy-json/lazy-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. lazy-json/lazy-json

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

lazy-json/lazy-json
===================

PHP class to parse large JSON files and provide a lazy-load interface

v1.0.3(1y ago)527MITPHPPHP ^8.1CI passing

Since Jan 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rubs33/lazy-json)[ Packagist](https://packagist.org/packages/lazy-json/lazy-json)[ Docs](https://github.com/rubs33/lazy-json)[ Patreon](https://www.patreon.com/rubs33)[ RSS](/packages/lazy-json-lazy-json/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (12)Used By (0)

LazyJson
========

[](#lazyjson)

Description
-----------

[](#description)

LazyJson is a PHP library that allows you to navigate a JSON file through a lazy-loaded, object-oriented interface.

Unlike `json_decode`, which loads the entire JSON file into memory at once, this library parses only the necessary elements on demand, based on the operations you perform during navigation.

Its primary goal is to provide a **memory-efficient** way to **access** JSON data rather than modifying it. While it can be used to validate a JSON structure, it assumes the JSON is well-formed and only parses elements as needed to return the requested data.

### Advantages:

[](#advantages)

- **Memory-efficient**: Optimized for large JSON files, supporting arrays, objects, and strings, with minimal memory usage during navigation.
- **Intuitive**: Navigate the JSON as if it were parsed by `json_decode`, without needing to load the entire structure into memory.
- **Zero dependencies**: No third-party libraries required, only standard PHP extensions.
- **PHP 8.1+ compatible**.
- **High test coverage**: Rigorous unit tests ensure reliability.
- **MIT License**: You have the freedom to use, modify, and distribute it in both open-source and proprietary projects, with no warranty.

### Use cases

[](#use-cases)

For a JSON file with:

**... a large array**, you can:

1. Access a specific element without loading the entire array into memory.
2. Iterate over the array, keeping only one element in memory at a time.
3. Count the elements without loading the whole array.

**... a large object**, you can:

1. Access specific properties without parsing the entire object.
2. Iterate over the object, keeping only one key-value pair in memory at a time.

**... a large string**, you can:

1. Iterate over the string, processing one UTF-8 character at a time (e.g., stream it to an HTTP response, decode Base64, or save to a file).

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

[](#requirements)

- PHP 8.1 or higher
- ext-ctype
- ext-json
- ext-spl

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

[](#installation)

To use this library, you can install it via [Composer](https://getcomposer.org/):

```
$ composer require lazy-json/lazy-json
```

If you use PHP 7.4, you can try:

```
$ composer require 'lazy-json/lazy-json:dev-php7'
```

Documentation / API
-------------------

[](#documentation--api)

To know how to use it, check the page [Usage](docs/Usage.md).

To have details about public methods, access the [API spec](docs/API.md).

You might also want to see the [examples](/examples).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance44

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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 ~4 days

Total

10

Last Release

439d ago

Major Versions

v0.0.6 → v1.0.02025-02-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/7587f4597890ef1508bffd65777177a72c5c228c011fa110137088d4ac2cbde1?d=identicon)[rubs33](/maintainers/rubs33)

---

Top Contributors

[![rubs33](https://avatars.githubusercontent.com/u/7697159?v=4)](https://github.com/rubs33 "rubs33 (27 commits)")

---

Tags

jsonjson\_decodeparserlazy loadmemory-efficient

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lazy-json-lazy-json/health.svg)

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

###  Alternatives

[salsify/json-streaming-parser

A streaming parser for JSON in PHP.

7766.7M15](/packages/salsify-json-streaming-parser)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30422.2M45](/packages/colinodell-json5)[cerbero/json-parser

Zero-dependencies pull parser to read large JSON from any source in a memory-efficient way.

803474.6k5](/packages/cerbero-json-parser)[pcrov/jsonreader

JSON Pull Parser

1451.2M5](/packages/pcrov-jsonreader)[bcncommerce/json-stream

A bundle of tools to work with JSON in PHP

642.2M3](/packages/bcncommerce-json-stream)[laktak/hjson

JSON for Humans. A configuration file format with relaxed syntax, fewer mistakes and more comments.

86233.7k12](/packages/laktak-hjson)

PHPackages © 2026

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