JSON Schema Editor
simple-ai/json-schema-editorFreeComponent
A visual editor for creating and editing JSON Schema definitions with support for nested objects, arrays, enums, and property descriptions.
Live preview
live · rendered by the registry
Rendered by simple-ai on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://simple-ai.dev/r/json-schema-editor.jsonSource
1"use client";23import type { JSONSchema7 } from "ai";4import { Asterisk, Brackets, Plus, Save, Trash2 } from "lucide-react";5import { nanoid } from "nanoid";6import { type ComponentProps, useState } from "react";7import { Button } from "@/components/ui/button";8import {9 Dialog,10 DialogContent,11 DialogDescription,12 DialogHeader,13 DialogTitle,14 DialogTrigger,15} from "@/components/ui/dialog";16import { Input } from "@/components/ui/input";17import {18 Select,19 SelectContent,20 SelectItem,21 SelectTrigger,22 SelectValue,23} from "@/components/ui/select";24import { cn } from "@/lib/utils";2526const MAX_NESTING_LEVEL = 5;2728const SCHEMA_TYPES = [29 "string",30 "number",31 "integer",32 "boolean",33 "enum",34 "object",35] as const;3637export type JsonSchemaEditorJSONSchemaType = (typeof SCHEMA_TYPES)[number];3839export interface JsonSchemaEditorInternalSchemaProperty {40 id: string;41 type: JsonSchemaEditorJSONSchemaType;42 isArray?: boolean;43 isRequired?: boolean;44 enumValues?: string[];45 properties?: Record<string, JsonSchemaEditorInternalSchemaProperty>;46 description?: string;47}4849export interface JsonSchemaEditorInternalSchema {50 type: "object";51 properties: Record<string, JsonSchemaEditorInternalSchemaProperty>;52 required?: string[];53 additionalProperties?: boolean;54 description?: string;55}5657/**58 * Parse a JSON Schema property into an internal representation59 * Shared utility for both editor and preview components60 */61function parseJSONSchemaProperty(prop: Record<string, unknown>): {62 type: string;63 isArray: boolean;64 description?: string;65 properties?: Record<string, ReturnType<typeof parseJSONSchemaProperty>>;66 enumValues?: string[];67} {68 const result: {69 type: string;70 isArray: boolean;71 description?: string;72 properties?: Record<string, ReturnType<typeof parseJSONSchemaProperty>>;73 enumValues?: string[];74 } = {75 type: "string",76 isArray: false,77 };7879 if (prop.type === "array" && prop.items && typeof prop.items === "object") {80 result.isArray = true;81 const items = prop.items as Record<string, unknown>;8283 if (typeof items.type === "string") {84 result.type = items.type;85 }8687 if (items.enum && Array.isArray(items.enum)) {88 result.type = "enum";89 result.enumValues = items.enum.map(String);90 }9192 if (93 items.type === "object" &&94 items.properties &&95 typeof items.properties === "object"96 ) {97 result.type = "object";98 result.properties = {};99100 for (const [nestedName, nestedProp] of Object.entries(101 items.properties as Record<string, unknown>,102 )) {103// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from simple-ai
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| base-handlebase-handle | simple-ai | Components | Free | 1 dep | |
| base-nodebase-node | simple-ai | Components | Free | no deps | |
| Chat Inputchat-input | simple-ai | Components | Free | 7 deps | |
| Chat Messagechat-message | simple-ai | Components | Free | no deps | |
| Chat Message Areachat-message-area | simple-ai | Components | Free | 1 dep | |
| Chat Suggestionschat-suggestions | simple-ai | Components | Free | no deps | |
| Editable Handleeditable-handle | simple-ai | Components | Free | 1 dep | |
| Generate Text Nodegenerate-text-node | simple-ai | Components | Free | 1 dep |
