# json-render **Repository Path**: limoncc/json-render ## Basic Information - **Project Name**: json-render - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2026-01-26 - **Last Updated**: 2026-01-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # json-render **Predictable. Guardrailed. Fast.** Let end users generate dashboards, widgets, apps, and data visualizations from prompts — safely constrained to components you define. ```bash npm install @json-render/core @json-render/react ``` ## Why json-render? When users prompt for UI, you need guarantees. json-render gives AI a **constrained vocabulary** so output is always predictable: - **Guardrailed** — AI can only use components in your catalog - **Predictable** — JSON output matches your schema, every time - **Fast** — Stream and render progressively as the model responds ## Quick Start ### 1. Define Your Catalog (what AI can use) ```typescript import { createCatalog } from '@json-render/core'; import { z } from 'zod'; const catalog = createCatalog({ components: { Card: { props: z.object({ title: z.string() }), hasChildren: true, }, Metric: { props: z.object({ label: z.string(), valuePath: z.string(), // Binds to your data format: z.enum(['currency', 'percent', 'number']), }), }, Button: { props: z.object({ label: z.string(), action: ActionSchema, // AI declares intent, you handle it }), }, }, actions: { export_report: { description: 'Export dashboard to PDF' }, refresh_data: { description: 'Refresh all metrics' }, }, }); ``` ### 2. Register Your Components (how they render) ```tsx const registry = { Card: ({ element, children }) => (

{element.props.title}

{children}
), Metric: ({ element }) => { const value = useDataValue(element.props.valuePath); return
{format(value)}
; }, Button: ({ element, onAction }) => ( ), }; ``` ### 3. Let AI Generate ```tsx import { DataProvider, ActionProvider, Renderer, useUIStream } from '@json-render/react'; function Dashboard() { const { tree, send } = useUIStream({ api: '/api/generate' }); return ( downloadPDF(), refresh_data: () => refetch(), }}> e.key === 'Enter' && send(e.target.value)} /> ); } ``` **That's it.** AI generates JSON, you render it safely. --- ## Features ### Conditional Visibility Show/hide components based on data, auth, or complex logic: ```json { "type": "Alert", "props": { "message": "Error occurred" }, "visible": { "and": [ { "path": "/form/hasError" }, { "not": { "path": "/form/errorDismissed" } } ] } } ``` ```json { "type": "AdminPanel", "visible": { "auth": "signedIn" } } ``` ### Rich Actions Actions with confirmation dialogs and callbacks: ```json { "type": "Button", "props": { "label": "Refund Payment", "action": { "name": "refund", "params": { "paymentId": { "path": "/selected/id" }, "amount": { "path": "/refund/amount" } }, "confirm": { "title": "Confirm Refund", "message": "Refund ${/refund/amount} to customer?", "variant": "danger" }, "onSuccess": { "set": { "/ui/success": true } }, "onError": { "set": { "/ui/error": "$error.message" } } } } } ``` ### Built-in Validation ```json { "type": "TextField", "props": { "label": "Email", "valuePath": "/form/email", "checks": [ { "fn": "required", "message": "Email is required" }, { "fn": "email", "message": "Invalid email" } ], "validateOn": "blur" } } ``` --- ## Packages | Package | Description | |---------|-------------| | `@json-render/core` | Types, schemas, visibility, actions, validation | | `@json-render/react` | React renderer, providers, hooks | ## Demo ```bash git clone https://github.com/vercel-labs/json-render cd json-render pnpm install pnpm dev ``` - http://localhost:3000 — Docs & Playground - http://localhost:3001 — Example Dashboard ## Project Structure ``` json-render/ ├── packages/ │ ├── core/ → @json-render/core │ └── react/ → @json-render/react ├── apps/ │ └── web/ → Docs & Playground site └── examples/ └── dashboard/ → Example dashboard app ``` ## How It Works ``` ┌─────────────┐ ┌──────────────┐ ┌─────────────┐ │ User Prompt │────▶│ AI + Catalog│────▶│ JSON Tree │ │ "dashboard" │ │ (guardrailed)│ │(predictable)│ └─────────────┘ └──────────────┘ └─────────────┘ │ ┌──────────────┐ │ │ Your React │◀───────────┘ │ Components │ (streamed) └──────────────┘ ``` 1. **Define the guardrails** — what components, actions, and data bindings AI can use 2. **Users prompt** — end users describe what they want in natural language 3. **AI generates JSON** — output is always predictable, constrained to your catalog 4. **Render fast** — stream and render progressively as the model responds ## License Apache-2.0