Componenteditors0.93 KB gzipZero dependencies
Json Editor
JSON editor with live validation, error line and format button.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add json-editorOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { JsonEditor } from "@/components/ui/json-editor"; <JsonEditor />Source code
json-editor.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxjson-editor.tsx69 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface JsonEditorProps extends React.HTMLAttributes<HTMLDivElement> { value?: string; defaultValue?: string; onValueChange?: (value: string, valid: boolean) => void; height?: string;} function format(src: string): string { try { return JSON.stringify(JSON.parse(src), null, 2); } catch { return src; }} function validate(src: string): { valid: boolean; error?: string } { if (src.trim() === "") return { valid: true };Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { JsonEditor } from "@/components/ui/json-editor"; <JsonEditor />| Prop | Type | Description |
|---|---|---|
| value | string | Controlled value. |
| defaultValue | string | Initial value when uncontrolled. |
| onValueChange | (value: string, valid: boolean) => void | Callback invoked on value change. |
| height | string | Configures height. (Default: "200px") |