JSON Field

JSON Field is a copy-paste React component that stops broken json saved to config before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/json-field
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsBroken JSON saved to config

Was this component page useful?

How do I install JSON Field?

pnpm dlx shadcn@latest add @bollard/json-field

The files land in your project. They're yours to edit.

How do I use JSON Field in React?

json-field-usage.tsx
import { JsonField } from "@/components/ui/json-field"

return <JsonField label="Service config" defaultValue={pasted} rows={7} className="max-w-sm" />

What input mistakes does JSON Field catch?

  • Trailing commas
  • Single or smart quotes, and unquoted keys
  • Comments and Python literals such as True and None
  • Missing commas and unclosed braces or brackets
  • Exact line and column, the same in every browser

What props does JSON Field accept?

JsonField props
PropTypeDefault
label

Visible label.

string"JSON"
hint

Helper text shown while the field is empty.

string—
value

Controlled value.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the text on every change, including fixes and formatting.

(value: string) => void—
delay

Pause in ms before a problem is shown while typing. Leaving the field shows it at once.

number600
indent

Indent used by the Format button.

number2
formatLabel

Format button text.

string"Format"
validMessage

Shown under valid JSON.

string"Valid JSON"
fixLabels

Labels of the one-tap fixes, per mistake.

Partial<Record<JsonMistake, string>>—
showLabel

Text of the button that selects the problem in the textarea.

string"Show me"
formatPosition

Formats the position shown before each problem.

(line: number, column: number) => string(line, column) => `Line ${line}, column ${column}:`

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

How is JSON Field accessible?

  • Visible label; textarea has aria-invalid and is described by the status
  • Status is a polite live region and problems wait for a pause while typing
  • Position button moves the caret to the problem
  • Caret overlay is aria-hidden

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Checks syntax only; no JSON Schema validation
  • Fixes are heuristic; review the result before saving

What expensive mistakes does JSON Field stop?

Broken JSON saved to config

Also known as

json · json editor · json validator · config · payload · metadata · settings · api body

Field type

What dependencies does JSON Field require?

JSON Field facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameJSON Field
Registry identifier@bollard/json-field
Install commandnpx shadcn@latest add @bollard/json-field
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about JSON Field

What form validation mistake does JSON Field catch?

JSON Field prevents broken JSON saved to config. Validates JSON as you type, points at the exact line and column, and repairs the usual hand-editing mistakes in one tap. Catches: Trailing commas, Single or smart quotes, and unquoted keys, Comments and Python literals such as True and None, Missing commas and unclosed braces or brackets, Exact line and column, the same in every browser. Limitation: validate json-field schemas on backend.

How do I install json-field with shadcn?

Run `npx shadcn@latest add @bollard/json-field`. Sources added: registry/default/json-field/json-check.ts, registry/default/json-field/json-field.tsx. Package requirements: lucide-react.

What props customize JSON Field?

JSON Field accepts `label`, `hint`, `value`, `defaultValue`, `onValueChange`. Configures json, json editor, json validator behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of json-field?

Checks syntax only; no JSON Schema validation. Fixes are heuristic; review the result before saving Server requirement: backend verification for json-field.

How does JSON Field meet accessibility guidelines?

Visible label; textarea has aria-invalid and is described by the status. Status is a polite live region and problems wait for a pause while typing. Position button moves the caret to the problem. Caret overlay is aria-hidden. Minimizes errors: json syntax error, trailing comma json.

Which components pair with JSON Field?