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

Abandoned → [sweetrdf/json-ld](/?search=sweetrdf%2Fjson-ld)Library[Parsing &amp; Serialization](/categories/parsing)

k00ni/json-ld
=============

JSON-LD Processor for PHP

1.4.0(1mo ago)31.1k1[2 PRs](https://github.com/sweetrdf/json-ld/pulls)MITPHPPHP &gt;=8.1.0CI passing

Since Dec 29Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/sweetrdf/json-ld)[ Packagist](https://packagist.org/packages/k00ni/json-ld)[ Docs](http://www.markus-lanthaler.com)[ RSS](/packages/k00ni-json-ld/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (5)Used By (0)

JsonLD (Fork)
=============

[](#jsonld-fork)

Note

**This is a fork of the [Original JsonLD](https://github.com/lanthaler/JsonLD)** library written by [Markus Lanthaler](https://github.com/lanthaler). I maintain it in my spare time to keep it alive and usable on the latest PHP versions. Code is more or less maintained but not developed any further. If you wanna participate, feel free to open a pull request!

JsonLD is a fully conforming [JSON-LD](http://www.w3.org/TR/json-ld/)processor written in PHP. It is extensively tested and passes the [official JSON-LD test suite](https://github.com/json-ld/tests).

There's an [online playground](http://www.markus-lanthaler.com/jsonld/playground/)where you can evaluate the processor's basic functionality.

Additionally to the features defined by the [JSON-LD API specification](http://www.w3.org/TR/json-ld-api/), JsonLD supports [framing](http://json-ld.org/spec/latest/json-ld-framing/)(including [value matching](https://github.com/json-ld/json-ld.org/issues/110), [deep-filtering](https://github.com/json-ld/json-ld.org/issues/110), [aggressive re-embedding](https://github.com/json-ld/json-ld.org/issues/119), and [named graphs](https://github.com/json-ld/json-ld.org/issues/118)) and an experimental [object-oriented interface for JSON-LD documents](https://github.com/lanthaler/JsonLD/issues/15).

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

[](#installation)

JsonLD requires **PHP 8.1** or later.

The easiest way to install **JsonLD** is by requiring it with [Composer](https://getcomposer.org/).

```
composer require sweetrdf/json-ld

```

Of course, you can also download JsonLD as [ZIP archive](https://github.com/sweetrdf/json-ld/releases) from Github.

Usage
-----

[](#usage)

The library supports the official [JSON-LD API](http://www.w3.org/TR/json-ld-api/) as well as a object-oriented interface for JSON-LD documents (not fully implemented yet, see [issue #15](https://github.com/lanthaler/JsonLD/issues/15) for details).

All classes are extensively documented. Please have a look at the source code.

```
// Official JSON-LD API
$expanded = JsonLD::expand('document.jsonld');
$compacted = JsonLD::compact('document.jsonld', 'context.jsonld');
$framed = JsonLD::frame('document.jsonld', 'frame.jsonld');
$flattened = JsonLD::flatten('document.jsonld');
$quads = JsonLD::toRdf('document.jsonld');

// Output the expanded document (pretty print)
print JsonLD::toString($expanded, true);

// Serialize the quads as N-Quads
$nquads = new NQuads();
$serialized = $nquads->serialize($quads);
print $serialized;

// And parse them again to a JSON-LD document
$quads = $nquads->parse($serialized);
$document = JsonLD::fromRdf($quads);

print JsonLD::toString($document, true);

// Node-centric API
$doc = JsonLD::getDocument('document.jsonld');

// get the default graph
$graph = $doc->getGraph();

// get all nodes in the graph
$nodes = $graph->getNodes();

// retrieve a node by ID
$node = $graph->getNode('http://example.com/node1');

// get a property
$node->getProperty('http://example.com/vocab/name');

// add a new blank node to the graph
$newNode = $graph->createNode();

// link the new blank node to the existing node
$node->addPropertyValue('http://example.com/vocab/link', $newNode);

// even reverse properties are supported; this returns $newNode
$node->getReverseProperty('http://example.com/vocab/link');

// serialize the graph and convert it to a string
$serialized = JsonLD::toString($graph->toJsonLd());
```

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.1% 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 ~652 days

Total

3

Last Release

59d ago

PHP version history (2 changes)1.2.1PHP &gt;=5.3.0

1.3.0PHP &gt;=8.1.0

### Community

Maintainers

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

---

Top Contributors

[![lanthaler](https://avatars.githubusercontent.com/u/456407?v=4)](https://github.com/lanthaler "lanthaler (361 commits)")[![k00ni](https://avatars.githubusercontent.com/u/381727?v=4)](https://github.com/k00ni "k00ni (32 commits)")[![zobzn](https://avatars.githubusercontent.com/u/579620?v=4)](https://github.com/zobzn "zobzn (3 commits)")[![whikloj](https://avatars.githubusercontent.com/u/2857697?v=4)](https://github.com/whikloj "whikloj (2 commits)")[![maqnouch](https://avatars.githubusercontent.com/u/3692812?v=4)](https://github.com/maqnouch "maqnouch (1 commits)")[![tomgillett](https://avatars.githubusercontent.com/u/1083890?v=4)](https://github.com/tomgillett "tomgillett (1 commits)")[![tstoeckler](https://avatars.githubusercontent.com/u/3929504?v=4)](https://github.com/tstoeckler "tstoeckler (1 commits)")[![LukasRos](https://avatars.githubusercontent.com/u/192050?v=4)](https://github.com/LukasRos "LukasRos (1 commits)")[![emteknetnz](https://avatars.githubusercontent.com/u/4809037?v=4)](https://github.com/emteknetnz "emteknetnz (1 commits)")[![frmichel](https://avatars.githubusercontent.com/u/1170961?v=4)](https://github.com/frmichel "frmichel (1 commits)")[![cafferata](https://avatars.githubusercontent.com/u/1150425?v=4)](https://github.com/cafferata "cafferata (1 commits)")

---

Tags

JSON-LDjsonld

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[ml/json-ld

JSON-LD Processor for PHP

3446.4M38](/packages/ml-json-ld)[digitalbazaar/json-ld

A JSON-LD Processor and API implementation in PHP.

28555.4k1](/packages/digitalbazaar-json-ld)

PHPackages © 2026

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