@gfazioli/mantine-json-tree

中文文档
3.7.6发布于 2026/11/09MITTypeScriptESM + CJS零依赖近 30 天下载 3.1万

A Mantine extension component that renders interactive JSON trees with syntax highlighting, collapsible nodes, in-place editing of values and structure, copy-to-clipboard, and configurable expansion depth.

原始使用文档
文档目录5 节
  1. Overview
  2. Features
  3. Installation
  4. Usage
  5. Sponsor

Mantine Json Tree Component

Mantine Json Tree

mantine-json-tree at a glance, refreshed daily: commits, releases, stars, issues and pull requests, a year of commit activity, the weekly rhythm, languages, latest commits and releases, contributors
Made with glancecard · refreshed daily

Overview

This component is created on top of the Mantine library. It requires Mantine 9.x and React 19.

Mantine JsonTree provides a structured, interactive view of heterogeneous data—strings, numbers, booleans, nulls, objects, arrays, and even functions—organized as a collapsible tree. Developers can control initial expansion, show visual indent guides, and customize expand/collapse controls with arbitrary React nodes (e.g., emojis or styled icons) to match their design system. For function values, the component offers flexible rendering modes: show the function signature as text, hide functions entirely, or inspect them as objects when needed.

Set editable and the same tree becomes an editor: click a string or a number to change it in place, click a boolean to toggle it. Add structuralEdits and the reader can rename keys, add and remove keys and items, and reorder arrays, with expanded nodes and focus following every change. Updates are immutable and rebuild only the path down to the change, so every Date, Map, Set, RegExp, BigInt, function and React element elsewhere in the tree keeps its identity.

Wrapped with Mantine layout primitives like Paper, Stack, and SimpleGrid, JsonTree integrates cleanly into dashboards, developer tools, and documentation pages where readable, navigable data visualization is essential.

Features

  • Interactive collapsible tree view for any JSON-serializable data
  • In-place editing of strings, numbers and booleans (editable, onChange) — immutable updates that leave every Date, Map, Set, RegExp, BigInt, function and React element in the tree untouched
  • Structural editing: rename keys, add and remove keys and items, reorder arrays (structuralEdits), from the mouse or the keyboard
  • Search with text highlight, filtered tree view, and auto-expand matching branches
  • Diff highlighting: mark nodes as added, removed or changed with highlightNode
  • Large data: long arrays split into collapsible [start…end] groups (groupArraysAfterLength), long strings cut with a "show more" toggle (collapseStringsAfterLength), and long objects or arrays cut to their first entries with a "… N more" row that reveals the next page (maxDisplayLength)
  • Locked expansion: every node open and none collapsible (allExpanded)
  • Quote style: show or hide the quotes around strings and keys (withQuotes, withKeyQuotes)
  • Translatable labels for every built-in string, and an accessible name on every icon button (labels)
  • Indentation width (indentWidth) and a root without a label (rootName={false})
  • Type badges next to every value (showValueTypes) and sorted keys (sortKeys)
  • Redesigned toolbar with key count badge, global copy, search toggle, and modern icons
  • Paper wrapper with withBorder for bordered container look
  • Custom root name via rootName prop
  • Syntax highlighting with customizable colors for 16+ data types (strings, numbers, booleans, null, Date, RegExp, Map, Set, BigInt, Symbol, React elements, etc.)
  • Safe on object graphs: circular references are marked [Circular] instead of crashing, while shared non-circular references still expand everywhere they appear
  • Dark mode support with automatic color adaptation
  • Copy-to-clipboard on individual nodes + global copy all JSON
  • Keyboard navigation (arrow keys, Space to expand, Ctrl+C to copy)
  • Configurable expansion depth with expand/collapse all controls
  • Controlled expand/collapse state with expanded and onExpandedChange props
  • Line numbers display
  • Visual indent guides with rotating color palette
  • Path tooltip on hover showing full JSON path
  • Max height with scrollable container
  • Sticky header support with configurable offset
  • Function display modes: as-string, hide, or as-object introspection
  • Responsive font size via Mantine breakpoint objects (CSS-native, no re-renders)
  • Full Mantine Styles API support with 29 style selectors and 25+ CSS variables
  • Custom icons for expand/collapse and copy controls
  • Item count badges for objects and arrays
  • onExpand, onCollapse, onNodeClick, onCopy, and onCopyAll callbacks

[!note]

→ Demo and Documentation → Youtube Video → More Mantine Components

Installation

npm install @gfazioli/mantine-json-tree

or

yarn add @gfazioli/mantine-json-tree

After installation import package styles at the root of your application:

import '@gfazioli/mantine-json-tree/styles.css';

Usage

import { JsonTree } from '@gfazioli/mantine-json-tree';

function Demo() {
  return <JsonTree data={{ key: "value" }} />;
}

To let a reader change values, add editable and feed onChange back through data — JsonTree keeps no copy of your data:

import { useState } from 'react';
import { JsonTree } from '@gfazioli/mantine-json-tree';

function Demo() {
  const [data, setData] = useState({ key: 'value', count: 1, enabled: false });

  return <JsonTree data={data} editable onChange={setData} />;
}

Sponsor

Your support helps me:

  • Keep the project actively maintained with timely bug fixes and security updates
  • Add new features, improve performance, and refine the developer experience
  • Expand test coverage and documentation for smoother adoption
  • Ensure long‑term sustainability without relying on ad hoc free time
  • Prioritize community requests and roadmap items that matter most

Open source thrives when those who benefit can give back—even a small monthly contribution makes a real difference. Sponsorships help cover maintenance time, infrastructure, and the countless invisible tasks that keep a project healthy.

Your help truly matters.

💚 Become a sponsor today and help me keep this project reliable, up‑to‑date, and growing for everyone.


https://github.com/user-attachments/assets/ce2b1ba2-51f7-43d5-8477-6d8fee103fa3

版本与发布记录

@gfazioli/mantine-json-tree 共发布 41 个版本,首次发布于 2025/11/14;过去 12 个月发布了 39 个版本。

版本发布日期距今
3.7.6latest2026/11/096 天前
3.7.52026/11/069 天前
3.7.42026/10/2621 天前
3.7.32026/10/2224 天前
3.7.22026/10/131 个月前
3.7.12026/10/091 个月前

关于 @gfazioli/mantine-json-tree 的常见问题

@gfazioli/mantine-json-tree 是什么?

A Mantine extension component that renders interactive JSON trees with syntax highlighting, collapsible nodes, in-place editing of values and structure, copy-to-clipboard, and configurable expansion depth.

如何安装 @gfazioli/mantine-json-tree?

在项目目录运行 npm install @gfazioli/mantine-json-tree,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.x || ^19.x)、react-dom(^18.x || ^19.x)、@mantine/core(>=9.0.0)、@mantine/hooks(>=9.0.0)、@tabler/icons-react(^3.34.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gfazioli/mantine-json-tree 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gfazioli/mantine-json-tree 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gfazioli/mantine-json-tree 可以商用吗?

@gfazioli/mantine-json-tree 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gfazioli/mantine-json-tree 的下载量有多少?

根据 npm 官方下载统计,@gfazioli/mantine-json-tree 在 2026/10/17 – 2026/11/15 这 30 天内被下载 31,450 次,日均约 1,048 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gfazioli/mantine-json-tree 还在维护吗?

最新版本 3.7.6 发布于 2026/11/09(6 天前);至今共发布 41 个版本,其中过去 12 个月发布了 39 个;首次发布于 2025/11/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。