PHPackages                             nadar/prosemirror-json-parser - 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. nadar/prosemirror-json-parser

ActiveLibrary

nadar/prosemirror-json-parser
=============================

A library that easily converts ProseMirror/TipTap JSON into customizable HTML elements.

2.1(2mo ago)49.0k↓28%1MITPHPPHP ^8.1CI passing

Since Dec 5Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/nadar/prosemirror-json-parser)[ Packagist](https://packagist.org/packages/nadar/prosemirror-json-parser)[ RSS](/packages/nadar-prosemirror-json-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (8)Versions (14)Used By (1)

ProseMirror JSON Parser
=======================

[](#prosemirror-json-parser)

The ProseMirror JSON Parser (**prosemirror-json-parser**) is a versatile PHP library crafted for effortless conversion of [ProseMirror/TipTap JSON Model](https://prosemirror.net/docs/ref/#model) content into HTML. With dependency-free operation and exceptional parsing speed, this library ensures high-performance HTML generation. Seamlessly integrating with TipTap and ProseMirror, it offers customization through easy addition or modification of nodes. Effortlessly install via Composer, utilize the `toHtml` function and explore extensive customization options for tailored JSON to HTML conversion.

**It functions seamlessly with both TipTap and ProseMirror because TipTap is built upon ProseMirror.**

[![PHPUnit Tests](https://github.com/nadar/prosemirror-json-parser/actions/workflows/phpunit.yml/badge.svg)](https://github.com/nadar/prosemirror-json-parser/actions/workflows/phpunit.yml)[![Maintainability](https://camo.githubusercontent.com/4d0d4e1575888e2089ba2359df5a0e55826a5ab4555cea67559a8e15d5179cdc/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f37396636383631313238616364613333343338662f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/nadar/prosemirror-json-parser/maintainability)[![codecov](https://camo.githubusercontent.com/dd2c6977f3cfccb7c4458d0c26c5864c9f99755ee76e189ad5f2ff2b0bded212/68747470733a2f2f636f6465636f762e696f2f67682f6e616461722f70726f73656d6972726f722d6a736f6e2d7061727365722f67726170682f62616467652e7376673f746f6b656e3d4853534a483630585a56)](https://codecov.io/gh/nadar/prosemirror-json-parser)[![Latest Stable Version](https://camo.githubusercontent.com/a0de54e23e8e4a428ac865e94cc9b47208d0ab54a763c55d457dcf5786c77814/68747470733a2f2f706f7365722e707567782e6f72672f6e616461722f70726f73656d6972726f722d6a736f6e2d7061727365722f762f737461626c65)](https://packagist.org/packages/nadar/prosemirror-json-parser)[![Total Downloads](https://camo.githubusercontent.com/1c2b4e31dafdcb0ff5b30797663bc2252a9ea85e81e87097bef13dc8d4ad50e6/68747470733a2f2f706f7365722e707567782e6f72672f6e616461722f70726f73656d6972726f722d6a736f6e2d7061727365722f646f776e6c6f616473)](https://packagist.org/packages/nadar/prosemirror-json-parser)[![License](https://camo.githubusercontent.com/bc77c83e788d8bfb1a63e0ed22c1a403eb3549cad9554a88020275b4ef343bef/68747470733a2f2f706f7365722e707567782e6f72672f6e616461722f70726f73656d6972726f722d6a736f6e2d7061727365722f6c6963656e7365)](https://packagist.org/packages/nadar/prosemirror-json-parser)

[![ProseMirror JSON Parser, what AI thinks about](ai-prosemirror-to-html.webp)](ai-prosemirror-to-html.webp)

**Key Features:**

- Dependency-free: No additional libraries required for this parser.
- Exceptional speed: Offers high-performance parsing capabilities.
- Highly extendible: Enables the addition of custom nodes as per your requirements.
- 100% Code Coverage and Testing: Ensures comprehensive test coverage, guaranteeing reliability and stability.
- Robust out-of-the-box HTML generation: Generates high-quality HTML seamlessly without requiring modifications, ensuring ease of use and reliability.

Installation &amp; Usage
------------------------

[](#installation--usage)

To install the library using Composer, execute the following command:

```
composer require nadar/prosemirror-json-parser
```

After installing the library, integrate the parser into your project. Utilize the `toHtml` function to convert your JSON value into renderable HTML code. Note that the `toHtml` function solely accepts an array. Therefore, if your content is in JSON format, employ `json_decode($json, true)` to initially convert the JSON string into an array and pass it `toHtml(json_decode($json, true))`.

```
$html = (new Nadar\ProseMirror\Parser())
    ->toHtml($json);
```

Extending &amp; Customizing
---------------------------

[](#extending--customizing)

Each node corresponds to a callable function within the parser, using the node's name as the key. This setup allows for easy addition or modification of nodes.

For example, to adjust the rendering of the image node, you can include your own function into the parser using the `replaceNode()` method:

```
$html = (new \Nadar\ProseMirror\Parser())
    ->replaceNode(\Nadar\ProseMirror\NodeType::image, fn(\Nadar\ProseMirror\Node $node) => '')
    ->toHtml($json);
```

> To see all default nodes declared, refer to the `NodeType` class.

If you have a custom node with a specific name, you can add it to the parser using the `addNode()` method:

```
$html = (new \Nadar\ProseMirror\Parser())
    ->addNode('myCustomNode', fn(\Nadar\ProseMirror\Node $node) => '...')
    ->toHtml($json);
```

> The `addNode()` and `replaceNode()` methods are almost identical internally, except that `replaceNode` should only be used when altering the output of default nodes. You can view all by-default declared nodes in the `NodeType` class.

### Customizing Marks

[](#customizing-marks)

In addition to customizing nodes, you can also customize how marks (like bold, italic, link, etc.) are rendered without replacing the entire text node renderer. This is particularly useful when you want to customize the output of specific marks.

For example, to customize the link mark to add additional attributes:

```
$html = (new \Nadar\ProseMirror\Parser())
    ->replaceMark('link', fn(\Nadar\ProseMirror\Mark $mark, string $text) =>
        '' . $text . ''
    )
    ->toHtml($json);
```

You can also use the `MarkType` enum for type safety:

```
$html = (new \Nadar\ProseMirror\Parser())
    ->replaceMark(\Nadar\ProseMirror\MarkType::link, fn(\Nadar\ProseMirror\Mark $mark, string $text) =>
        '' . $text . ''
    )
    ->toHtml($json);
```

You can also add custom mark renderers for your own mark types:

```
$html = (new \Nadar\ProseMirror\Parser())
    ->addMark('highlight', fn(\Nadar\ProseMirror\Mark $mark, string $text) =>
        '' . $text . ''
    )
    ->toHtml($json);
```

Default marks that can be customized include: `bold`, `italic`, `underline`, `strike`, and `link`.

> The `addMark()` and `replaceMark()` methods work similarly to their node counterparts - use `replaceMark()` for customizing default marks and `addMark()` for adding new custom mark types. Both methods accept either a `MarkType` enum or a string for the type parameter.

### List Item Paragraph Handling

[](#list-item-paragraph-handling)

By default, the parser produces clean HTML for list items without wrapping content in paragraph tags: `text`.

If you need the previous behavior where list items were wrapped in paragraph tags (`text`), you can enable it:

```
$html = (new \Nadar\ProseMirror\Parser())
    ->setWrapParagraphsInListItems(true)
    ->toHtml($json);
```

> Note: Paragraphs outside of list items will always be rendered with `` tags. This option only affects paragraphs that are direct children of list items.

---

*The text and image were enhanced by an AI, as English is not my first language and I am quite lazy. Even this sentence was generated by AI.*

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance85

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.9% 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 ~136 days

Recently: every ~192 days

Total

7

Last Release

76d ago

Major Versions

1.30 → 2.02025-10-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/86184bf08843ed8fcc4aedb2fdecd8a9e832e47e89a7166cebfda529c176f5ce?d=identicon)[nadar](/maintainers/nadar)

---

Top Contributors

[![nadar](https://avatars.githubusercontent.com/u/3417221?v=4)](https://github.com/nadar "nadar (42 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nadar-prosemirror-json-parser/health.svg)

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

PHPackages © 2026

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