Modern jQuery plugin that turns JSON Schema-like definitions into beautiful, responsive HTML forms with real-time validation.
- ๐จ Modern UI: clean, responsive (Flexbox/Grid), light/dark ready
- ๐ Real-time validation: instant feedback with friendly hints
- ๐ i18n & RTL: Persian/Farsi and other RTL languages supported
- ๐งฉ Rich inputs: string, number, email, tel, url, date, time, textarea, select, checkbox, radio, color, html, object, array
- ๐งฑ Modular code: Renderer, Validator, EventHandler, Utils
- ๐ก๏ธ TypeScript: bundled
.d.tsfor great IntelliSense
Include jQuery, the compiled plugin, and one of the themes:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="jquery/jquery.min.js"></script>
<script src="jsonToForm/jsonToForm.v2.js"></script>
<link href="src/styles/jsonToForm.clean.css" rel="stylesheet" />
<!-- Or: <link href="src/styles/jsonToForm.modern.css" rel="stylesheet" /> -->
</head>
<body>
<div id="myForm"></div>
<script>
const form = $("#myForm").jsonToForm({
schema: {
type: "object",
properties: {
name: { type: "string", title: "Full Name", minLength: 2 },
email: { type: "email", title: "Email Address" },
age: { type: "number", title: "Age", min: 18, max: 100 }
},
required: ["name", "email"]
}
});
// Read & validate
console.log(form.getValue());
console.log(form.isValid());
</script>
</body>
</html>getValue()โ returns the current form valuesetValue(obj)โ sets/replaces form valueisValid()โ boolean validity of the whole formvalidator.getAllErrors()โ list of validation errors
Example:
const form = $("#myForm").jsonToForm(options);
form.setValue({ name: "John Doe" });
console.log(form.getValue(), form.isValid());
console.log(form.validator.getAllErrors());- Themes:
src/styles/jsonToForm.clean.css(simple),src/styles/jsonToForm.modern.css(polished) - Dark mode: set
data-json-form-theme="dark"on<body> - RTL: add
dir="rtl"on<html>/<body>/container
<body dir="rtl" data-json-form-theme="dark">
<!-- your form container -->
</body>src/โ modular source (core, renderer, validator, events, utils, styles)jsonToForm/jsonToForm.v2.jsโ compiled v2 bundlejsonToForm/jsonToForm.d.tsโ TypeScript definitionsv1/โ legacy v1 plugin, styles, and demosdemo-v2.htmlโ v2 demo
Old usage (v1.x):
$('#myForm').jsonToForm({ schema, value });New usage (v2):
$('#myForm').jsonToForm({ schema });
$('#myForm').jsonToForm('setValue', value);For legacy plugin and original demos, see the v1/ folder.
Run a simple static server and open the demo (PowerShell):
# From the repo root
python -m http.server 8080
# Open in your browser:
# http://localhost:8080/demo-v2.htmlMIT ยฉ Contributors โ see LICENSE