How to generate json schema for form validation
- Step 1Create a sample form submission JSON — Build a JSON object representing a complete form submission with all fields populated: { "firstName": "Alice", "email": "[email protected]", "age": 28, "newsletterOptIn": true }.
- Step 2Generate the base schema — Paste the submission JSON and click Generate. The output schema marks all keys as required with inferred types.
- Step 3Add format and constraint refinements — Enhance the schema with specific constraints: for email add format: email, for age add minimum: 0 and maximum: 120, for text fields add minLength and maxLength. These dramatically improve form validation quality.
- Step 4Integrate with React Hook Form — Install @hookform/resolvers and ajv. Pass the schema to useForm: const { register, handleSubmit } = useForm({ resolver: ajvResolver(schema) }). Validation errors are now tied to specific fields for inline error display.
Frequently asked questions
Should I use JSON Schema validation or Zod for React Hook Form?+
Both work well. JSON Schema is the better choice if you share the schema between client-side form validation and server-side AJV validation, or if you generate the schema from an OpenAPI spec. Zod is better for pure TypeScript projects where type inference from the schema is more important than schema portability.
How do I add conditional validation — for example, require a phone number only when a specific option is selected?+
JSON Schema supports conditional validation with if/then/else. After generating the base schema, add an if block that checks the conditional field value and a then block with the additional required constraint. AJV evaluates these conditions at validation time.
Is form submission data uploaded to JAD Apps?+
No. Schema inference runs entirely in your browser. Form submission objects including user-entered data are never transmitted to JAD Apps servers.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.