Jedison: JSON Schema Form Generator and Validator

Category: Javascript | September 9, 2026
Authorgermanbisurgi
Last UpdateSeptember 9, 2026
LicenseMIT
Views0 views
Jedison: JSON Schema Form Generator and Validator

Jedison is a JavaScript JSON Schema form generator and validator that creates editable HTML forms from schema definitions.

It has no dependencies and handles nested objects, arrays, conditional schemas, schema composition, and multiple editor layouts.

Features

  • Editors for string, number, boolean, object, array, and null values.
  • Conditional fields with if, then, and else.
  • allOf, anyOf, oneOf, and not schema composition.
  • Object layouts such as grids, navigation, categories, and accordions.
  • Array layouts such as navigation, tables, tuples, checkboxes, and sortable lists.
  • Schema-level x-* properties for field UI and editor behavior.
  • Base, Bootstrap 3, Bootstrap 4, and Bootstrap 5 themes.
  • Localization and custom validation messages.
  • $ref resolution through RefParser.
  • Optional editors backed by Choices.js, Flatpickr, IMask, Quill, Jodit, FilePond, Ace, Pickr, Milkdown, and other libraries.
  • Programmatic value access, validation, field navigation, and array-item control.
  • Custom editors and custom validation constraints.
  • Headless JSON validation in Node.js.

How To Use It

Installation

Load the UMD build directly from jsDelivr:

<script src="https://cdn.jsdelivr.net/npm/jedison@latest/dist/umd/jedison.umd.js"></script>

Install the package with npm:

npm install jedison

Or Yarn:

yarn add jedison

Import Jedison in an ES module project:

import Jedison from 'jedison';

Basic Usage

Create a container and initialize Jedison.Create with a theme and JSON Schema.

<div id="jedison-container"></div>
<script>
const schema = {
  title: 'Profile',
  type: 'object',
  required: ['name', 'email'],
  properties: {
    name: {
      title: 'Name',
      type: 'string',
      minLength: 1
    },
    email: {
      title: 'Email',
      type: 'string',
      format: 'email'
    },
    age: {
      title: 'Age',
      type: 'integer',
      minimum: 0
    }
  }
};
const jedison = new Jedison.Create({
  container: document.querySelector('#jedison-container'),
  theme: new Jedison.Theme(),
  schema
});
</script>

Load Initial Data

Pass the initial JSON value through data.

const jedison = new Jedison.Create({
  container: document.querySelector('#jedison-container'),
  theme: new Jedison.Theme(),
  schema,
  data: {
    name: 'Alex Morgan',
    email: '[email protected]',
    age: 32
  }
});

Read And Update Form Data

Read the current JSON value with getValue().

const data = jedison.getValue();
console.log(data);

Replace it with setValue().

jedison.setValue({
  name: 'Jamie Lee',
  email: '[email protected]',
  age: 27
});

Validate Form Data

Get validation errors programmatically:

const errors = jedison.getErrors(['error']);
if (errors.length === 0) {
  console.log(jedison.getValue());
}

Request both errors and warnings:

const messages = jedison.getErrors(['error', 'warning']);

Each validation result uses this structure:

{
  type: 'error',
  path: '#',
  constraint: 'minLength',
  messages: [
    'Must be at least 4 characters long.'
  ]
}

Call showValidationErrors() when a submitted form should display its current validation state.

<form id="profile-form" novalidate>
  <div id="jedison-container"></div>
  <button type="submit">Submit</button>
</form>
<script>
document.querySelector('#profile-form').addEventListener('submit', function(event) {
  event.preventDefault();
  jedison.showValidationErrors();
  if (jedison.getErrors(['error']).length === 0) {
    console.log(jedison.getValue());
  }
});
</script>

Listen For Value Changes

jedison.on('change', function(initiator) {
  console.log(jedison.getValue());
});

Use instance-change when the changed editor instance is needed:

jedison.on('instance-change', function(instance, initiator) {
  console.log(instance);
});

Use A Bootstrap Theme

Load the matching Bootstrap stylesheet before selecting a Bootstrap theme class.

const jedison = new Jedison.Create({
  container: document.querySelector('#jedison-container'),
  theme: new Jedison.ThemeBootstrap5(),
  schema
});

Available theme classes:

  • Jedison.Theme
  • Jedison.ThemeBootstrap3
  • Jedison.ThemeBootstrap4
  • Jedison.ThemeBootstrap5

Set iconLib when the generated controls should use one of Jedison’s icon mappings:

  • glyphicons
  • bootstrap-icons
  • fontawesome3
  • fontawesome4
  • fontawesome5
  • fontawesome6
const jedison = new Jedison.Create({
  container: document.querySelector('#jedison-container'),
  theme: new Jedison.ThemeBootstrap5(),
  iconLib: 'bootstrap-icons',
  schema
});

Select Different Editors

Use x-format when a schema field requires a specific editor.

const schema = {
  type: 'object',
  properties: {
    notes: {
      type: 'string',
      title: 'Notes',
      'x-format': 'textarea'
    }
  }
};

String Editors

  • Default text input
  • Radio buttons
  • Inline radio buttons
  • Select
  • Textarea
  • Awesomplete
  • Flatpickr
  • IMask
  • Jodit
  • Quill
  • FilePond
  • Ace
  • Emoji Button
  • SimpleMDE
  • Pickr
  • Milkdown

Number Editors

  • Default number input
  • Select
  • Radio buttons
  • Inline radio buttons
  • Nullable number
  • Range
  • IMask
  • Raty star rating

Boolean Editors

  • Default boolean editor
  • Checkbox
  • Radio buttons
  • Inline radio buttons
  • Select

Object Editors

  • Default object layout
  • Grid
  • Vertical navigation
  • Horizontal navigation
  • Vertical categories
  • Horizontal categories
  • Accordion
  • Radio buttons
  • Inline radio buttons

Array Editors

  • Default array editor
  • Checkboxes
  • Inline checkboxes
  • Choices
  • Vertical navigation
  • Horizontal navigation
  • Table
  • Object table
  • Tuple

Use Conditional Fields

Use standard JSON Schema conditions to change the active form schema.

const schema = {
  type: 'object',
  properties: {
    accountType: {
      type: 'string',
      enum: ['personal', 'business']
    }
  },
  if: {
    properties: {
      accountType: {
        const: 'business'
      }
    }
  },
  then: {
    properties: {
      companyName: {
        type: 'string',
        title: 'Company Name'
      }
    },
    required: ['companyName']
  }
};

Jedison processes allOf, anyOf, oneOf, and not schema composition as well.

Resolve `$ref` Schemas

Dereference the schema with Jedison.RefParser, then pass the parser to Jedison.Create.

const schema = {
  type: 'object',
  properties: {
    user: {
      $ref: '#/$defs/user'
    }
  },
  $defs: {
    user: {
      type: 'object',
      properties: {
        name: {
          type: 'string'
        }
      }
    }
  }
};
const refParser = new Jedison.RefParser();
async function init() {
  await refParser.dereference(schema);
  const jedison = new Jedison.Create({
    container: document.querySelector('#jedison-container'),
    theme: new Jedison.Theme(),
    refParser,
    schema
  });
}
init();

Headless Validation In Node.js

Create the instance without container or theme.

const Jedison = require('jedison');
const jedison = new Jedison.Create({
  schema: {
    title: 'Person',
    type: 'object',
    properties: {
      name: {
        type: 'string'
      },
      age: {
        type: 'integer',
        minimum: 0
      }
    },
    required: ['name', 'age']
  }
});
jedison.setValue({
  name: 'Alice',
  age: 30
});
console.log(jedison.getErrors());

Instance Options

These are the options exposed on Jedison’s current Instance Options reference.

Core Data And Setup

  • containerHTMLElement, default null. Element that receives the generated form.
  • iconLibstring, default null. Accepts glyphicons, bootstrap-icons, fontawesome3, fontawesome4, fontawesome5, or fontawesome6.
  • themeTheme, default null. Accepts an instance of Theme, ThemeBootstrap3, ThemeBootstrap4, or ThemeBootstrap5.
  • refParserRefParser, default null. Parser used for schema $ref references.
  • translationsobject, default {}. Adds translations or overrides existing translation strings.
  • schemaobject, default {}. JSON Schema used by the editor and validator.
  • idstring, default ''. Prefixes generated id and for attributes when multiple Jedison forms share a page.
  • languagestring, default 'en'. Language for UI text and validation messages.
  • dataobject, default undefined. Initial JSON data.
  • customEditorsarray, default []. Custom editor classes used during editor resolution.
  • hiddenInputAttributesobject, default {}. Attributes applied to the hidden input that stores the complete JSON value.
  • settingsobject, default {}. Application values and functions that can be accessed by plugins and templates.

Annotation And Data Processing

  • parseMarkdownboolean, default false. Converts Markdown annotations to HTML when window.marked is available.
  • purifyHtmlboolean, default true. Sanitizes rendered annotation HTML when window.DOMPurify is available.
  • purifyDataboolean, default true. Sanitizes string input values when window.DOMPurify is available.
  • domPurifyOptionsobject, default {}. Options passed to DOMPurify.

UI And Editor Behavior

  • btnContentsboolean, default true. Displays text inside editor buttons.
  • btnIconsboolean, default true. Displays icons inside editor buttons.
  • switcherInputstring, default 'select'. Accepts select, radios, radios-inline, modal, or select-inline.
  • enablePropertiesToggleboolean, default false. Adds the properties activation control.
  • embedSwitcherboolean, default false. Places the oneOf or anyOf schema switcher inside the selected editor header.
  • enableCollapseToggleboolean, default false. Adds collapse controls to compatible editors.
  • deactivateNonRequiredboolean, default false. Deactivates non-required object properties, including cases where recursive schemas need controlled activation.
  • showErrorsstring, default 'change'. Accepts never, change, input, or always.
  • editJsonDataboolean, default false. Activates inline JSON editing.

Validation And Schema Behavior

  • enforceConstboolean, default false. Keeps editor values at the schema const value in editor mode.
  • enforceEnumboolean, default true. Uses the first enum item as the initial editor value.
  • enforceRequiredboolean, default true. Keeps required properties visible and adds missing required properties in editor mode.
  • enforceAdditionalPropertiesboolean, default true. Removes properties that are not listed in properties in editor mode.
  • assertFormatboolean, default false. Uses JSON Schema format as a validation assertion.
  • subErrorsboolean, default false. Adds nested sub-error detail to validation results.
  • useConstraintAttributesboolean, default true. Maps applicable JSON Schema limits to native min, max, minlength, maxlength, and pattern attributes.

Array And Object Controls

  • arrayDeleteboolean, default true. Displays array delete controls.
  • arrayMoveboolean, default true. Displays array move controls.
  • arrayAddboolean, default true. Displays array add controls.
  • objectAddboolean, default true. Displays the Add Property control for object editors.
  • arrayDeleteConfirmboolean, default true. Shows a confirmation dialog before an array item is deleted.
  • arrayDeleteAllboolean, default false. Adds Delete All to the array header.
  • arrayFooterAddboolean, default false. Adds an Add Item control to the array footer.
  • arrayFooterButtonsPositionstring, default 'right'. Accepts left or right.
  • arrayFooterDeleteAllboolean, default false. Adds Delete All to the array footer.

Schema Options

Array Controls

  • x-arrayAddboolean, default true. Displays array Add controls.
  • x-arrayAddContentstring. Changes the Add control content.
  • x-arrayButtonsPositionstring, default 'left'. Accepts left or right for table-format array action controls.
  • x-arrayDeleteboolean, default true. Displays item delete controls.
  • x-arrayDeleteAllboolean, default false. Adds Delete All to the array header.
  • x-arrayDeleteAllContentstring. Changes Delete All content.
  • x-arrayDeleteConfirmboolean. Overrides the instance-level delete confirmation behavior.
  • x-arrayDeleteContentstring. Changes item Delete control content.
  • x-arrayDragContentstring. Changes the drag-control content.
  • x-arrayFooterAddboolean, default false. Adds Add Item to the footer.
  • x-arrayFooterAddContentstring. Changes the footer Add Item content.
  • x-arrayFooterButtonsPositionstring, default 'right'. Accepts left or right.
  • x-arrayFooterDeleteAllboolean, default false. Adds Delete All to the footer.
  • x-arrayFooterDeleteAllContentstring. Changes the footer Delete All content.
  • x-arrayMoveboolean, default true. Displays Move Up and Move Down controls.
  • x-arrayMoveDownContentstring. Changes Move Down content.
  • x-arrayMoveUpContentstring. Changes Move Up content.
  • x-sortableboolean, default false. Activates drag-and-drop sorting when Sortable.js is available.

Object, Layout, And Presentation

  • x-addPropertyContentstring. Changes Add Property content.
  • x-categoryOrderstring[]. Defines category order in categories-vertical and categories-horizontal object layouts.
  • x-collapseToggleContentstring. Changes collapse-control content.
  • x-containerAttributesobject. Applies HTML attributes to an editor container.
  • x-deactivateNonRequiredboolean. Controls activation of non-required object properties.
  • x-editJsonDataboolean, default false. Activates inline JSON editing for the schema node.
  • x-enableCollapseToggleboolean. Displays a collapse control on compatible object and array editors.
  • x-gridobject. Configures columns, offset, and newRow for grid layouts.
  • x-hiddenboolean. Hides the editor when set to true.
  • x-infoobject. Adds supplementary information with variant, title, and content.
  • x-inputAttributesobject. Applies HTML attributes to the generated input.
  • x-navWarningboolean, default true. Displays a warning icon when navigation-based object or array editors contain nested validation errors.
  • x-navWarningMessagestring. Changes the warning icon tooltip. x-navWarning must be active.
  • x-objectAddboolean, default true. Overrides Add Property visibility for the object editor.
  • x-propertiesToggleContentstring. Changes properties-toggle content.
  • x-propGroupstring. Assigns a property to a group in the properties activation dialog.
  • x-propGroupOrderstring[]. Defines property-group order.
  • x-startCollapsedboolean. Starts compatible editors collapsed.
  • x-titleHiddenboolean, default false. Hides the editor title.
  • x-titleIconClassstring. Sets the icon class used in a title.
  • x-titleTemplatestring. Builds dynamic item titles in navigation-format array editors.

Schema Selection And Editor Configuration

  • x-discriminatorstring | object. Selects a oneOf or anyOf branch from a property value. Object form accepts propertyName.
  • x-enumTitlesstring[]. Supplies display labels for enum values.
  • x-filepondobject. Passes configuration to FilePond when x-format is filepond.
  • x-formatstring. Selects the editor UI used for the schema node.
  • x-switcherInputstring, default 'select'. Accepts select, radios, radios-inline, modal, or select-inline.
  • x-switcherTitlestring, default property name or "title". Sets the label shown for a schema branch in the switcher.

Validation And Messages

  • x-assertFormatboolean, default false. Uses format as a validation assertion for the schema node.
  • x-enforceConstboolean, default true. Keeps the value at the schema const.
  • x-enforceEnumboolean, default true. Uses the first enum item as the initial editor value.
  • x-messagesobject | string[]. Defines custom validation messages as a simple array, a constraint-message object, or a localized language object.
  • x-showErrorsstring, default "change". Accepts "never", "change", "input", or "always".
  • x-subErrorsboolean. Overrides nested sub-error output for the schema node.
  • x-useConstraintAttributesboolean. Overrides conversion of JSON Schema limits to native HTML constraint attributes.

Custom Editor Actions

Each button entry accepts:

  • label: sanitized HTML content for the button.
  • event.name: emits jedison:<name> from the root Jedison instance.
  • attributes: permitted HTML, ARIA, and data-* attributes for the button.
jedison.on('jedison:detectCity', function({ jedison, editor, path }) {
  console.log(path);
});

API Methods

getValue()

Returns the current root JSON value.

const value = jedison.getValue();

setValue(value)

Replaces the current root value.

jedison.setValue({
  name: 'Grace',
  age: 34
});

getInstance(path)

Returns an editor instance from its JSON Pointer-style location.

const street = jedison.getInstance('#/address/street');

Array Instance Methods

Retrieve the array instance first:

const tags = jedison.getInstance('#/tags');

Available array-instance controls:

  • addItem(): Appends an item.
  • addItemAfter(index): Inserts an item after an existing index.
  • move(fromIndex, toIndex): Moves an item.
  • deleteItem(index): Deletes an item.
tags.addItem();
tags.addItemAfter(0);
tags.move(2, 0);
tags.deleteItem(1);

showValidationErrors()

Displays current validation errors in the editor UI.

jedison.showValidationErrors();

getErrors(types)

Returns validation results filtered by message type.

const errors = jedison.getErrors(['error']);
const allMessages = jedison.getErrors(['error', 'warning']);

disable()

Disables editor controls.

jedison.disable();

enable()

Re-enables editor controls.

jedison.enable();

navigateTo(path)

Opens the corresponding section in compatible navigation-based layouts.

jedison.navigateTo('#/organization/name');

destroy()

Destroys the editor instance.

jedison.destroy();

Events

change

Fires when the root value changes.

jedison.on('change', function(initiator) {
  console.log(jedison.getValue());
});

instance-change

Returns the editor instance involved in a change.

jedison.on('instance-change', function(instance, initiator) {
  console.log(instance);
});

item-add

Array editor event fired after an item is created.

jedison.editor.on('item-add', function(initiator, newInstance) {
  console.log(newInstance);
});

item-delete

Array editor event fired after an item is deleted.

jedison.editor.on('item-delete', function(initiator) {
  console.log(initiator);
});

item-move

Array editor event fired after an item changes position.

jedison.editor.on('item-move', function(initiator) {
  console.log(initiator);
});

Remove Event Listeners

Remove one callback with off():

const onChange = function(initiator) {
  console.log(jedison.getValue());
};
jedison.on('change', onChange);
jedison.off('change', onChange);

Remove all callbacks for an event:

jedison.off('change');

Custom Validation Constraints

Pass custom constraint functions through the constraints constructor option.

const jedison = new Jedison.Create({
  schema,
  constraints: {
    'x-my-constraint': function(context) {
      const errors = [];
      const expected = context.schema['x-my-constraint'];
      if (expected && context.value !== expected) {
        errors.push({
          type: 'warning',
          path: context.path,
          constraint: 'x-my-constraint',
          messages: [
            `Value should be equal to "${expected}".`
          ]
        });
      }
      return errors;
    }
  }
});

Alternatives And Related Resources

You Might Be Interested In:


Leave a Reply