JsonTree component provides a beautiful, UX-focused way to display JSON data structures in your documentation. It uses badges, type indicators, and visual hierarchy for optimal readability, with type-specific colors and clean indentation.
Basic Usage
Import the component and pass it JSON data to display.JsonTree usage
Basic JsonTree Example
Features
Visual Design
- Type-specific colors: Strings (green), numbers (blue), booleans (orange), null (gray)
- Badge-based property names: Consistent blue badges for all property names
- Clean hierarchy: Borders and indentation for nested structures
- Modern typography: Proper spacing and font choices
- Dark mode support: Automatic theme adaptation
Data Type Support
- Objects: Display with nested property structure
- Arrays: Show length and individual elements
- Primitives: Strings, numbers, booleans, null values
- Mixed types: Handle complex nested structures
Enhanced Readability
- String quotes: Properly formatted string values
- Array length indicators: Show
[n]for array types - Consistent spacing: Optimal padding and margins
- Visual borders: Subtle left borders for nested items
Advanced Examples
API Response Example
Preview
Configuration Object Example
Preview
Mixed Data Types Example
Preview
Properties
The JSON data to display. Can be any valid JSON structure including objects, arrays, primitives, or nested combinations
Optional title displayed above the JSON structure
Maximum nesting depth to prevent excessive rendering with deeply nested structures
JsonTreeGroup
UseJsonTreeGroup to organize multiple related JSON structures:
Preview
Best Practices
Use Descriptive Titles
Use Descriptive Titles
Provide clear, contextual titles that explain what the JSON data represents.
Include Realistic Data
Include Realistic Data
Use realistic, production-like data in examples to help users understand the actual structure and content.
Show Different Data Types
Show Different Data Types
Include examples that demonstrate various data types (strings, numbers, booleans, null, arrays, objects) to showcase the component’s type-specific formatting.
Group Related Examples
Group Related Examples
Consider Depth Limits
Consider Depth Limits
For very deeply nested JSON structures, consider setting an appropriate
maxDepth to prevent overwhelming the reader, or break the structure into multiple examples.Styling and Theming
JsonTree automatically adapts to Mintlify’s light and dark themes:- Property names: Consistent blue badges across themes
- String values: Green text with proper quote formatting
- Numbers: Blue text for numeric values
- Booleans: Orange text for true/false values
- Null values: Gray italic text
- Borders: Subtle left borders for nested structures
- Spacing: Consistent padding and margins
- Typography: Monospace font for values, clean spacing
Comparison with Code Blocks
JsonTree is designed as a more readable alternative to raw JSON code blocks:- JsonTree (Recommended)
- Code Block (Basic)
- Type-specific color coding
- Clean visual hierarchy
- Badge-based property names
- No syntax highlighting dependencies
- Consistent styling
Troubleshooting
Component not found
Component not found
If you see
Cannot find module "/snippets/JsonTree.jsx":- Ensure JsonTree.jsx exists in your
docs/snippets/folder - Run
mint-tsdocsto auto-install the component - Check that the import path is correct (should start with
/snippets/)
Data not rendering
Data not rendering
If the JSON structure doesn’t display:
- Verify that the
dataprop contains valid JSON - Check browser console for JavaScript errors
- Ensure the data is not
undefinedornullat the root level
Styling issues
Styling issues
If the component doesn’t look right:
- Ensure Tailwind CSS is properly loaded in your Mintlify site
- Check that you’re using an up-to-date version of the component
- Try refreshing the page to reload styles
Performance with large data
Performance with large data
If rendering is slow with large JSON structures:
- Consider setting a lower
maxDepthvalue - Break large structures into smaller, focused examples
- Use pagination or filtering for very large datasets
Version History
v2.0.0
Redesigned with beautiful formatting, type-specific colors, badge-based property names, and enhanced visual hierarchy
Future
- Expandable/collapsible sections
- Copy JSON functionality
- Search and filtering
- Custom color themes

