PHPackages                             sqkhor/editorjs-html - 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. sqkhor/editorjs-html

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

sqkhor/editorjs-html
====================

A utility to parse editorjs clean data to HTML. Based on editorjs-html by Pavittar Singh

v1.0.0(2y ago)03.8kMITPHPPHP &gt;=7.4

Since Dec 18Pushed 2y agoCompare

[ Source](https://github.com/shuqikhor/editorjs-html-php)[ Packagist](https://packagist.org/packages/sqkhor/editorjs-html)[ RSS](/packages/sqkhor-editorjs-html/feed)WikiDiscussions master Synced today

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

editorjs-html (PHP Port)
========================

[](#editorjs-html-php-port)

This is a PHP port of [editorjs-html](https://github.com/pavittarx/editorjs-html) by [@pavittarx](https://github.com/pavittarx).

`editorjs-html` is a utility to parse [Editor.js](https://editorjs.io/) clean data (JSON) to HTML.

- Use it with any PHP framework of your choice.
- Fast, Efficient and Lightweight.
- Fully customizable to the core.
- Supports basic Editor.js blocks which are customizable as well.
- Extendable for any new or custom Editor.js blocks.

**\[Note\]** *You don't actually need to convert Editor.js data to HTML for display. For that purpose, simply embed Editor.js in read-only mode.*

**\[Note\]** *This library is mainly for those who needs to convert Editor.js clean data to HTML for other uses, such as for API calls to other systems, or for migration to another editor.*

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

[](#installation)

### Composer

[](#composer)

```
composer require sqkhor/editorjs-html
```

Usage
-----

[](#usage)

```
// Get an array of HTML based on original blocks
$result = edjsHTML::parse($editorjs_clean_data);

// Enclose in  for display
$sections = array_map(function ($section) {
  return "$section";
}, $result);

// Join for output
$html = implode("", $sections);
echo $html;
```

Updates
-------

[](#updates)

See [Releases](https://github.com/shuqikhor/editorjs-html-php/releases)

Docs
----

[](#docs)

### Supported Block Types

[](#supported-block-types)

- Header (H1-H6)
- Lists (Ordered &amp; Unordered)
- Nested Lists
- Image
- Delimiter
- Paragraph
- Quote
- Code
- Embed

### Accepted Data Format

[](#accepted-data-format)

The data passed to `parse()` or `parse_strict()` could be either an undecoded JSON string, or any JSON-decoded format (supports both stdClass and associative array)

### Parse Entire Editor.js Data

[](#parse-entire-editorjs-data)

```
  $HTML = edjsHTML::parse($editorjs_data);
  // returns an array of html strings per block
  var_export($HTML);
```

### Parse Entire Editor.js Data (Strict Mode)

[](#parse-entire-editorjs-data-strict-mode)

```
try {
  $HTML = edjsHTML::parse_strict($editorjs_data);

  // in case of success, returns an array of strings
  var_export($HTML)
} catch (\Exception $e) {
  // returns an error when data is invalid
}
```

### Parse Single Clean Data Block

[](#parse-single-clean-data-block)

```
  $block_HTML = edjsHTML::parse_block($editorjs_data_block);
  // returns a string of html for this block
  var_export(block_HTML);
```

### Get a list of missing parser functions

[](#get-a-list-of-missing-parser-functions)

```
  // returns a list of missing parser functions
  $block_HTML = edjsHTML::validate($editorjs_data);
  var_export(block_HTML);
```

### Extend For Custom Blocks

[](#extend-for-custom-blocks)

To add your own parser functions for unsupported block types, simply extend the `edjsHTML` class with the block parsers as static methods.

You can even override existing block parsers.

**\[Note\]** *The name of the methods must match with Editor.js custom block type.*

#### Example:

[](#example)

```
// Your custom editorjs generated block
{
  type: "custom",
  data: {
    text: "Hello World"
  }
}
```

```
// Parse this block in editorjs-html
class CustomParser extends edjsHTML {
  static public function custom ($block) {
    return "{$block['data']['text']}";
  }
}

const HTML = CustomParser::parse($editorjs_data);
```

Design Notes
------------

[](#design-notes)

**\[Note\]** *This section is not important.*

Unlike Javascript/Typescript, which the original library is built on, you can't pass a function as a variable in PHP. This limits the ways we could pass a parser function to the main class.

Therefore I was left with 2 options:

1. Have separate classes for the main operation and the block parsers. To add your own block parser, extend the parser class and pass it to the main class.
2. Have block parsers all over the places, then register each of them to the main class.
3. Have a single class for everything. To add your own block, simply extend the one-and-only class.

\#1 and #2 are the proper ways.
\#3 is easier to use.

I opted for #3.

License
-------

[](#license)

MIT Public License

Author
------

[](#author)

[@shuqikhor](https://sqkhor.com)based on works by [@pavittarx](https://github.com/pavittarx)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.4% 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

Unknown

Total

1

Last Release

928d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7521763?v=4)[Shuqi Khor](/maintainers/shuqikhor)[@shuqikhor](https://github.com/shuqikhor)

---

Top Contributors

[![pavittarx](https://avatars.githubusercontent.com/u/29155477?v=4)](https://github.com/pavittarx "pavittarx (57 commits)")[![shuqikhor](https://avatars.githubusercontent.com/u/7521763?v=4)](https://github.com/shuqikhor "shuqikhor (12 commits)")[![michaeldoubek](https://avatars.githubusercontent.com/u/20358442?v=4)](https://github.com/michaeldoubek "michaeldoubek (2 commits)")[![eurobob](https://avatars.githubusercontent.com/u/4255350?v=4)](https://github.com/eurobob "eurobob (1 commits)")[![groteworld](https://avatars.githubusercontent.com/u/1421810?v=4)](https://github.com/groteworld "groteworld (1 commits)")[![jie-lyu](https://avatars.githubusercontent.com/u/2233760?v=4)](https://github.com/jie-lyu "jie-lyu (1 commits)")[![LanceRabbit](https://avatars.githubusercontent.com/u/8542050?v=4)](https://github.com/LanceRabbit "LanceRabbit (1 commits)")[![ssuvorov](https://avatars.githubusercontent.com/u/3448821?v=4)](https://github.com/ssuvorov "ssuvorov (1 commits)")[![tommaso-perondi](https://avatars.githubusercontent.com/u/38632192?v=4)](https://github.com/tommaso-perondi "tommaso-perondi (1 commits)")[![azharalifauzi](https://avatars.githubusercontent.com/u/57862105?v=4)](https://github.com/azharalifauzi "azharalifauzi (1 commits)")[![y-onodera01](https://avatars.githubusercontent.com/u/22488782?v=4)](https://github.com/y-onodera01 "y-onodera01 (1 commits)")[![cdilga](https://avatars.githubusercontent.com/u/4075815?v=4)](https://github.com/cdilga "cdilga (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

jsonhtmlparsingeditorjseditorjs-html

### Embed Badge

![Health badge](/badges/sqkhor-editorjs-html/health.svg)

```
[![Health](https://phpackages.com/badges/sqkhor-editorjs-html/health.svg)](https://phpackages.com/packages/sqkhor-editorjs-html)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k504.8M167](/packages/mtdowling-jmespathphp)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30525.1M56](/packages/colinodell-json5)[ergebnis/json-printer

Provides a JSON printer, allowing for flexible indentation.

9242.4M29](/packages/ergebnis-json-printer)[ergebnis/json-normalizer

Provides generic and vendor-specific normalizers for normalizing JSON documents.

8341.7M8](/packages/ergebnis-json-normalizer)[craftcms/store-hours

This plugin adds a new “Store Hours” field type to Craft, for collecting the opening and closing hours of a business for each day of the week.

60104.4k1](/packages/craftcms-store-hours)[ergebnis/json

Provides a Json value object for representing a valid JSON string.

2525.7M10](/packages/ergebnis-json)

PHPackages © 2026

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