Beautiful JSON viewer column for Filament v4 tables.
composer require pepperfm/filament-json:^4.0
Previous major versions:
- Filament 4 →
composer require pepperfm/filament-json:^3.0
- Filament 3 →
composer require pepperfm/filament-json:^2.0
Optionally publish config or views if you want to customize them:
php artisan vendor:publish --tag="filament-json-config"php artisan vendor:publish --tag="filament-json-views"
No Tailwind/Vite setup is required — the package ships a compiled stylesheet and registers it via Filament assets.
use PepperFM\FilamentJson\Columns\JsonColumn;use PepperFM\FilamentJson\Enums\{RenderModeEnum, ContainerModeEnum}; // Inline (in-cell): always pretty raw JSON with click-to-copyJsonColumn::make('properties') ->renderAs(RenderModeEnum::Tree) // used if you later switch to modal/drawer ->presentIn(ContainerModeEnum::Inline); // Tree in a Drawer (with toolbar)JsonColumn::make('properties') ->renderAs(RenderModeEnum::Tree) ->presentIn(ContainerModeEnum::Drawer) ->initiallyCollapsed(1) ->expandAllToggle() // Tree only (modal/drawer) ->copyJsonAction(false); // hide Copy button // Table mode in a Modal with custom headersJsonColumn::make('properties') ->renderAs(RenderModeEnum::Table) ->presentIn(ContainerModeEnum::Modal) ->keyColumnLabel('Custom Key Label') ->valueColumnLabel('Custom Value Label');
// Content render mode:->asTree() // = renderAs(RenderModeEnum::Tree)->asTable() // = renderAs(RenderModeEnum::Table)Â // Container presentation:->inlineContainer() // = presentIn(ContainerModeEnum::Inline)->inModal() // = presentIn(ContainerModeEnum::Modal)->inDrawer() // = presentIn(ContainerModeEnum::Drawer)
maxDepth(int)
controls nesting depth rendering in Table mode.filterNullable(true)
filters out null/empty values from arrays/collections.characterLimit(?int)
truncates long string scalars.In modal/drawer modes you can enable a small toolbar above the content:
JsonColumn::make('properties') ->asTree() ->inDrawer() ->expandAllToggle() // adds Expand all / Collapse all buttons ->copyJsonAction(false); // hide Copy JSON button
JsonColumn::make('properties') ->asTable() ->inModal() ->keyColumnLabel('Key') ->valueColumnLabel('Value');
renderAs(RenderModeEnum::Tree|Table)
— choose how JSON is rendered.presentIn(ContainerModeEnum::Inline|Modal|Drawer)
— choose where it is presented.asTree()
, asTable()
— sugar for renderAs(...)
.inlineContainer()
, inModal()
, inDrawer()
— sugar for presentIn(...)
.initiallyCollapsed(int $depth = 1)
— auto-collapse depth for Tree.expandAllToggle(bool $on = true)
— toggle Tree toolbar buttons (modal/drawer).copyJsonAction(bool $on = true)
— toggle Copy JSON button (modal/drawer).keyColumnLabel(string)
, valueColumnLabel(string)
— Table headers.maxDepth(int)
— nesting limit for Table mode nested blocks.filterNullable(bool)
— filter out null/empty values.characterLimit(?int)
— truncate long string values.getContainerMode()
/ isModalContainer()
/ isDrawerContainer()
/ isInlineContainer()
— container checks.->inDrawer()
).asModal()
→ inModal()
asDrawer()
→ inDrawer()
inline()
→ inlineContainer()
getAsModal()/getAsDrawer()/getContainer()
→ getContainerMode()
or isInlineContainer()
JsonColumn::make('properties') ->asTree() ->asDrawer() ->initiallyCollapsed() ->filterNullable();
use PepperFM\FilamentJson\Enums\{RenderModeEnum, ContainerModeEnum};Â JsonColumn::make('properties') ->renderAs(RenderModeEnum::Tree) ->presentIn(ContainerModeEnum::Drawer) ->initiallyCollapsed() ->filterNullable(true);
If you previously relied on Tree/Table inline (inside the cell), note that v4 renders pretty JSON instead.
To keep the interactive view, present it in a modal or drawer:
JsonColumn::make('properties') ->asTree() ->inDrawer(); // or ->inModal()
In modal/drawer Tree mode you can show a small toolbar:
JsonColumn::make('properties') ->asTree() ->inDrawer() ->expandAllToggle() // Expand all / Collapse all buttons ->copyJsonAction(false); // Hide copy JSON button
If you test rendering, switch to Filament v4’s List resource page approach (per Filament’s docs) and ensure session/error bags are initialized in your test case to avoid ViewErrorBag
null issues.
pepperfm/filament-json:^4.0
&& pepperfm/filament-json:^3.0
pepperfm/filament-json:^2.0
Your existing constraints like ^2.x
or ^3.x
will continue to resolve to the proper major — v4 won’t auto-install unless you opt in.
The package ships a compiled CSS with soft borders, proper light/dark palette, and table grid lines.
If you publish views and manually tweak Tailwind, ensure your scanner includes the package views (e.g. resources/views/vendor/filament-json/**/*.blade.php
).
[!IMPORTANT] The
button()
andmodal()
method accept the type ofarray|Arrayable|\stdClass
, and implements basic properties of button and modal blade components from Filament documentation: Core Concepts - Blade Components
use PepperFM\FilamentJson\Columns\JsonColumn;use Filament\Support\Enums\Width;use Filament\Support\Icons\Heroicon;Â $buttonConfig = literal( color: 'primary', size: Width::Medium->value);$modalConfig = [ 'icon' => Heroicon::OutlinedSwatch, 'alignment' => 'start', 'width' => Width::Medium->value, 'closedByEscaping' => true, 'closed_button' => false, // also accepts camel_case];Â JsonColumn::make('properties') ->asModal() ->button($buttonConfig) ->modal($modalConfig);
use Filament\Support\Enums\Width;use Filament\Support\Icons\Heroicon;Â class ButtonConfigDto extends \Pepperfm\Ssd\BaseDto{ public string $color = 'primary';Â public Heroicon $icon = Heroicon::OutlinedSwatch;Â public ?string $label = null;Â public ?string $tooltip = null;Â public Width $size = Width::Medium;Â public ?string $href = null;Â public ?string $tag = null;}
use Filament\Support\Icons\Heroicon;use Filament\Support\Enums\Alignment;use Filament\Support\Enums\Width;Â class ModalConfigDto extends \Pepperfm\Ssd\BaseDto{ public ?string $id = null;Â public Heroicon $icon = Heroicon::Sparkles;Â public string $iconColor = 'primary';Â public Alignment $alignment = Alignment::Start;Â public string $width = Width::TwoExtraLarge->value;Â public bool $closeByClickingAway = true;Â public bool $closedByEscaping = true;Â public bool $closedButton = true;Â public bool $autofocus = true;}
Skipped for now
See the GitHub Releases page for a full changelog per version.
If you discover any security-related issues, please email the maintainer instead of using the issue tracker.
The MIT License (MIT). See LICENSE
for details.