Prompt
How can I generate forms from JSON schema?
Latest observation
Here's how to generate forms from JSON Schema, from the core concept through library-specific implementations.
The core idea
- JSON Schema describes the shape of your data (field types, required fields, validation rules like minLength or enum options) declaratively. A form-generation library reads that schema and dynamically builds the corresponding UI — inputs, labels, dropdowns, validation messages — without you hand-writing HTML/JSX for each field. Change the schema, the form updates automatically.
Example schema, used consistently across implementations
json
{
- "type": "object",
- "properties": {
- "name": { "type": "string" },
- "email": { "type": "string", "format": "email" },
- "password": { "type": "string", "minLength": 8 }
},
- "required": ["name", "email", "password"]
}
- React: JSON Forms
bash
npm install --save @jsonforms/react @jsonforms/core axios
-
JSON Forms separates the data schema (what the data looks like) from the UI schema (how it's laid out) — you define both, and the library renders a fully functional form including validation. It's client-side only, so submitting to a server (e.g., via axios) is your own integration step, not built in.
-
React: RJSF (react-jsonschema-form)
jsx
<Form
schema={schema}
uiSchema={uiSchema}
formData={formData}
onSubmit={handleSubmit}
onChange={handleChange}
validate={validate}
widgets={widgets}
/>
The most established option specifically for pure JSON Schema, with a large ecosystem of custom widget packages. Straightforward for standard forms; custom layouts require working within its widget/schema conventions.
- Vanilla JS / jQuery: JSON Form (jsonform)
js
$('form').jsonForm({
- "schema": {
- "name": { "title": "Name", "type": "string" },
- "gender": { "title": "Gender", "type": "string", "enum": ["male", "female", "alien"] }
}
});
Bootstrap-friendly out of the box, includes client-side validation and converts submitted values back into a JS object matching your schema. A good fit if you're not in a React/Vue/Angular app and just need a lightweight client-side generator.
- Visual, non-developer authoring: SurveyJS
- Rather than hand-writing the schema, SurveyJS's Creator lets you build a form visually via drag-and-drop, and it generates the corresponding JSON schema automatically — viewable and editable directly in a JSON Editor tab. This inverts the usual workflow (schema → form) into (visual design → schema), which matters specifically if non-developers need to create or update forms without writing JSON by hand. The schema-driven advantage still applies underneath: forms can be fetched dynamically from a server and updated at runtime without a page reload, and fields can conditionally show/hide based on prior answers.
No-code/API option, if you don't want to write any frontend code at all
- Services like FormForge accept a JSON schema via API and return either full embed-ready HTML or an iframe snippet — your backend stores the schema, the service renders it. Worth knowing as an option specifically if you want zero frontend form-rendering code in your own stack, though it's a smaller, newer tool compared to the established libraries above.
Practical recommendation, by stack
React, want the most established, widely-documented option → RJSF
React, want stronger schema/UI separation and multi-framework portability → JSON Forms
Vanilla JS/jQuery, no framework → jsonform
Need non-developer visual authoring on top of schema generation → SurveyJS
Want zero frontend rendering code, backend-only → a hosted JSON-to-form API service
Every implementation shares the same underlying mental model: define your data shape once in JSON Schema, let the library handle rendering and validation, and treat the schema (not hand-written markup) as your source of truth for the form's structure.
Citations
- https://medium.com/@terenceccwu/generate-forms-with-json-schema-d924e4874cf
- https://www.baeldung.com/introduction-to-jsonforms
- https://surveyjs.io/stay-updated/blog/dynamically-create-forms-from-json-schema
- https://github.com/jsonform/jsonform
- https://dev.to/agentcorp/generate-html-forms-from-json-schemas-no-frontend-code-required-4k5i
Observation history
See 2 earlier observations
Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.
How did Obsurfable measure this prompt?
Obsurfable records AI answers to buyer-style prompts in its research corpus (3 observations for this page). Metrics are distributions over observations, not a single static ranking.
Which AI systems does Obsurfable collect answers from?
OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.