form2js API Reference | form2js

Packages

@form2js/core

Turn path-like key/value pairs into nested objects and flatten them back into entries.

@form2js/dom

Parse browser form controls into an object while preserving native submission behavior.

@form2js/form-data

Parse FormData and tuple entries with the same path rules used by the core parser.

@form2js/react

Handle React form submission with parsed payloads, optional schema validation, and submit state.

@form2js/jquery

Install a jQuery plugin wrapper around the DOM parser for legacy form handling flows.

Who this is for

  • Developers choosing between the @form2js/* packages
  • Teams migrating from the legacy form2js flow to package-specific APIs
  • Anyone who needs exact options, exported types, and behavior notes

Package Guide

These rules apply across parser-based packages such as core, dom, and form-data.

  • Dot paths build nested objects: person.name.first becomes { person: { name: { first: ... } } }
  • Repeated [] pushes into arrays in encounter order: roles[]
  • Indexed arrays are compacted in first-seen order: items[8], items[5] becomes indexes 0, 1
  • Rails-style brackets are supported: rails[field][value]
  • By default, empty string and null are skipped (skipEmpty: true)
  • Unsafe key path segments (__proto__, prototype, constructor) are rejected by default