{"id":29325612,"url":"https://github.com/hblanko/json-schema-forms","last_synced_at":"2025-07-07T18:02:58.407Z","repository":{"id":57285198,"uuid":"224024305","full_name":"hblanko/json-schema-forms","owner":"hblanko","description":"A pure JavaScript tool that generates HTML forms from JSON Schemas.","archived":false,"fork":false,"pushed_at":"2020-06-02T07:22:47.000Z","size":663,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-05T19:51:23.861Z","etag":null,"topics":["html-form","json-schema","json-schema-form"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hblanko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-25T19:22:43.000Z","updated_at":"2025-03-19T21:38:54.000Z","dependencies_parsed_at":"2022-09-17T13:03:47.643Z","dependency_job_id":null,"html_url":"https://github.com/hblanko/json-schema-forms","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hblanko/json-schema-forms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hblanko%2Fjson-schema-forms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hblanko%2Fjson-schema-forms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hblanko%2Fjson-schema-forms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hblanko%2Fjson-schema-forms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hblanko","download_url":"https://codeload.github.com/hblanko/json-schema-forms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hblanko%2Fjson-schema-forms/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264011031,"owners_count":23543731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html-form","json-schema","json-schema-form"],"created_at":"2025-07-07T18:01:39.102Z","updated_at":"2025-07-07T18:02:53.459Z","avatar_url":"https://github.com/hblanko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JsonSchemaForms\n\nA JavaScript tool that generates HTML forms from JSON Schemas.\n\nThis implementation accepts schemas following the [JSON Schema Draft 2019-09 specification](https://json-schema.org/), with the goal of providing a straightforward mean to express potentially large and complex JSON Schemas in an intuitive fashion.\n\nJsonSchemaForms comes with [Bootstrap](https://getbootstrap.com/) (4.5+) and [Font Awesome](https://fontawesome.com/) (5.13+) support in order to organize and decorate the layout. While these libraries are not required, they are highly recommended to get the form properly rendered by the browser.\n\nJsonSchemaForms makes use of the [JSON Schema \\$Ref Parser](https://github.com/APIDevTools/json-schema-ref-parser) to resolve and dereference the schemas to be processed.\n\n## Usage\n\nThe JsonSchemaForms module provides a `build()` function that performs the whole process of analyzing a JSON Schema and generating the DOM and internal representation of the form. Have a look at the [`JsonSchemaForms.build()` API](https://hblanko.github.io/json-schema-forms/module-JsonSchemaForms.html) for usage details.\n\n### Through CDN\n\nThe quickly and easy way to make JsonSchemaForms available to your scripts, by adding a few CDN links to your HTML code.\n\nJsonSchemaForms provides a script and style sheet that can be linked adding the following tags:\n\n```html\n\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.jsdelivr.net/npm/json-schema-forms@latest/css/json-schema-forms.min.css\" /\u003e\n```\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/json-schema-forms@latest/dist/json-schema-forms.min.js\"\u003e\u003c/script\u003e\n```\n\nOn top of that, as mentioned before, Bootstrap and Font Awesome allow for a nice-looking result, so their CDN links are recommended to be included, too.\n\nHence, the full picture of a barebone `example.html` using JsonSchemaForms CDN ends up looking like this:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\" /\u003e\n    \u003c!-- Bootstrap-related style --\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css\" integrity=\"sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk\" crossorigin=\"anonymous\" /\u003e\n    \u003c!-- JsonSchemaForms style sheet --\u003e\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.jsdelivr.net/npm/json-schema-forms@latest/css/json-schema-forms.min.css\" /\u003e\n  \u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003c!-- Bootstrap and Font Awesome scripts --\u003e\n    \u003cscript src=\"https://code.jquery.com/jquery-3.5.1.slim.min.js\" integrity=\"sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js\" integrity=\"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js\" integrity=\"sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://kit.fontawesome.com/64968f57be.js\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n    \u003c!-- JsonSchemaForms script --\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/json-schema-forms@latest/dist/json-schema-forms.min.js\"\u003e\u003c/script\u003e\n    \u003c!-- Your script --\u003e\n    \u003cscript src=\"./example.js\"\u003e\u003c/script\u003e\n\n    \u003c!-- Some containers to use by your script --\u003e\n    \u003cdiv id=\"form-container\"\u003e\u003c/div\u003e\n    \u003cpre id=\"json-result\"\u003e\u003c/pre\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nA basic script `example.js` may look like this:\n\n```javascript\n// You've got two options in order to plug your JSON Schema:\n//   1. Provide a URL to a JSON Schema.\n//   2. Directly assign an object following the JSON Schema format.\n\n// const schema = 'http://landarltracker.com/schemas/test.json';\nconst schema = {\n  title: 'The Root Form Element',\n  description: 'Easy, right?',\n  type: 'string',\n};\n\n// Also, you can define the form behavior on submission, e.g.:\nconst submitCallback = (rootFormElement) =\u003e {\n  // Show the resulting JSON instance in your page.\n  document.getElementById('json-result').innerText = JSON.stringify(\n    rootFormElement.getInstance(),\n    null,\n    2\n  );\n  // (For testing purposes, return false to prevent automatic redirect.)\n  return false;\n};\n\n// Finally, get your form...\nconst jsonSchemaForm = JsonSchemaForms.build(schema, submitCallback);\n\n// ... and attach it somewhere to your page.\nwindow.addEventListener('load', () =\u003e {\n  document.getElementById('form-container').appendChild(jsonSchemaForm);\n});\n```\n\nThis example works directly out of the box. Feel free to copy, paste, and play around with it!\n\n### Custom bundle\n\nIf you prefer to import it into your own project, use your favorite package manager to install it:\n\n```console\nyarn add json-schema-forms\n```\n\nor\n\n```console\nnpm i json-schema-forms\n```\n\nAnd just make it available by including at the top of your script:\n\n```javascript\nimport JsonSchemaForms from 'json-schema-forms';\n```\n\nThen, you can use it as shown in `example.js` through the `build()` function\n(check [the API docs](https://hblanko.github.io/json-schema-forms/module-JsonSchemaForms.html) for detailed information).\n\n## What's to come?\n\nBase code is still under work, being several features not yet covered (but expected to be):\n\n- Conditional in-place applicators.\n- Some child applicators (e.g. `patternProperties`) and validation keywords.\n- Aggregation logic yet to be implemented for several keywords.\n\n_JsonSchemaForms was initially conceived as a basis for a specialized version to be used in the framework of [the Cookbase Project](https://github.com/hblanko/cookbase)._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhblanko%2Fjson-schema-forms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhblanko%2Fjson-schema-forms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhblanko%2Fjson-schema-forms/lists"}