Command Palette

Search for a command to run...

Dev Tools/Schema Viewer

Schema Viewer

JSON Schema visualizer with tree view, type badges, and required indicators

Open in v0Open in

User

A user in the system

object

A user in the system

id*string(uuid)

Unique identifier

email*string(email)

User email address

namestring
minLength: 1 maxLength: 100
ageinteger
min: 0 max: 150
rolesarray
[items]stringenum: "admin" | "user" | "guest"

Overview

A JSON Schema visualizer that renders schema definitions as an interactive tree. Shows types, required fields, constraints, and examples with color-coded type badges.

Installation

bunx shadcn@latest add @elements/schema-viewer

Usage

import { SchemaViewer } from "@/components/elements/devtools/schema-viewer";

const schema = {
  title: "User",
  description: "A user in the system",
  type: "object",
  properties: {
    id: { type: "integer", description: "Unique identifier" },
    email: { type: "string", format: "email" },
    name: { type: "string", minLength: 1, maxLength: 100 },
    role: { type: "string", enum: ["admin", "user", "guest"] }
  },
  required: ["id", "email"]
};

export function SchemaExample() {
  return (
    <SchemaViewer
      schema={schema}
      showExamples
    />
  );
}

Props

PropTypeDefaultDescription
schemaJsonSchema-JSON Schema object
showExamplesbooleantrueDisplay example values
classNamestring-Additional CSS classes

Supported Schema Features

  • Types: string, number, integer, boolean, object, array, null
  • Composition: oneOf, anyOf, allOf
  • Constraints: minimum, maximum, minLength, maxLength, pattern
  • Metadata: title, description, format, enum, default, example

Type Colors

  • string: Green
  • number/integer: Blue
  • boolean: Amber
  • object: Purple
  • array: Orange
  • null: Gray

Features

  • Collapsible nested properties
  • Type badges with format display
  • Required field indicators (*)
  • Constraint display (min/max, pattern)
  • Example value rendering
  • oneOf/anyOf/allOf support