Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Entity Display JSON

Security covered Under active development 36 sites

Part of the Entity ecosystem · 308 projects

This module provides a read-only JSON API for your Drupal entities, using your existing "Manage Display" configurations. It's designed for headless applications to get content in a predictable JSON format that mirrors how it's displayed on your site, including all field visibility and formatting settings. The API allows you to retrieve site information, resolve entity pointers from paths, and serialize specific entities using their configured display modes, with support for multilingual content and safe handling of deep or cyclical entity references.

Summary

A read-only JSON API for Drupal entities, driven by your existing Manage Display configuration. Designed for decoupled and headless consumers — React, Vue, Svelte, native apps, edge renderers — that want the same field visibility and formatter settings as a configured display mode, without rebuilding renderable arrays or maintaining a hand-written field map.
Configure a view display once and you get a stable JSON contract: hidden fields stay hidden, view modes propagate to referenced entities, label settings come through. Editors changing how content looks never reshape the data shape your frontend depends on.

Endpoints

  • GET /ejson — site name, slogan, language map, homepage pointer.
  • GET /ejson/resolve?path=/about-us — translates a path or alias into a {entity_type, uuid, id, display_id} pointer your frontend follows with a build call.
  • GET /ejson/{entity_type}/{uuid}/{display_id} — serializes an entity (or view) using the named view display. display_id defaults to default.

All three routes are gated by a single permission, Access Entity Display JSON endpoints.

Highlights

  • Display-driven — whatever you configure under Manage Display is what shows up in JSON.
  • One call, full page — referenced entities, paragraphs, media and files are walked recursively using each component's view mode, so a single request returns the whole tree.
  • Access-aware — per-entity and per-field view access is enforced; fields the current user cannot see are omitted.
  • Cacheable by default — entity, field, config and view cache tags bubble into a CacheableJsonResponse automatically, with the right cache contexts on top.
  • Views and blocks — view rows are processed through the row view mode; views_block:* plugins (via Block Field) are serialized the same way.
  • Multilingual — append ?lang=xx for a specific translation.
  • Safe recursion — cycles and deep nesting emit _stub: true markers with a _stub_reason (cycle or depth) instead of looping.
  • Frontend types — a JSON Schema for the invariant payload contract ships in schema/entity-payload.schema.json; pipe it through json-schema-to-typescript for free types.
  • Field groups (from the field_group module) are preserved as nested structures.

Extending without forking

The module is plugin- and hook-driven, so site code shapes the output without patching it:

  • Field value extractor plugins — implement FieldValueExtractorInterface and tag a class with the #[FieldValueExtractor] attribute to take over serialization for a field type, a formatter type, or both. Plugins are weight-ordered and the first whose applies() returns TRUE wins.
  • hook_entity_display_json_field_alter — tweak a single field's value after extraction.
  • hook_entity_display_json_entity_alter — reshape the full entity payload, inject hidden fields, or add computed properties.
  • hook_entity_display_json_response_alter — extend the top-level HTTP envelope.
  • hook_entity_display_json_field_value_extractor_info_alter — reweight or swap any built-in extractor.

Per-field opt-ins via display component third-party settings:

  • multi_value — force array or scalar output regardless of storage cardinality.
  • render — run formatted-text fields through check_markup so the output matches the filtered HTML the display would render.

Programmatic API

$builder = \Drupal::service('entity_display_json.builder');
$data = $builder->serialize($entity, $langcode, $display_id);

Requirements

  • Drupal 10.2+ or 11.
  • Optional integrations are picked up automatically when installed: Views (view serialization), Field Group (nested groups), Block Field (block plugin serialization), Paragraphs (recursive paragraph walking).

Documentation

Full configuration reference, extension examples, the JSON contract, and recipes for typed frontends live in the project README.md in the repository.

Drupal 10–11

Ask your assistant about Entity Display JSON

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
19
Tracked since
Jun 2023
Latest release
4 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
1.2.0 Stable 10–11 Jun 1, 2026
1.1.2 Stable 9–11 Sep 12, 2024
1.1.x-dev Dev 10–11 Dec 18, 2023
1.1.1 Stable 9–10 Dec 15, 2023
1.1.0 Stable 9–10 Dec 6, 2023
1.0.12 Stable 9–10 Oct 19, 2023
1.0.11 Stable 9–10 Oct 11, 2023
1.0.10 Stable 9–10 Sep 5, 2023
1.0.x-dev Dev 9–11 Jun 27, 2023
1.0.9 Stable 9–10 Jun 27, 2023