User Rating 0.0
Total Usage 0 times
📄 Drop .html file here or click to browse
Is this tool helpful?

Your feedback helps us improve.

About

Extracting structured data from HTML forms is a routine task that goes wrong in subtle ways. Bracket-notation names like user[address][city] must be parsed into nested objects. Array fields (items[]) must aggregate rather than overwrite. Unchecked checkboxes produce no entry at all. Multi-select elements return arrays while single selects return scalars. Getting any of these cases wrong means your API receives malformed payloads, your validation layer rejects clean data, or - worse - silent data loss reaches your database. This tool implements a standards-compliant form serialization algorithm that handles every standard HTML form element type, including nested name paths of arbitrary depth, radio groups, multi-selects, and boolean coercion for checkboxes.

The reverse operation - hydrating a form from a JSON object - is equally fragile. This converter reconstructs well-formed HTML <input> elements with correct name bracket notation, inferred type attributes, and proper nesting. It approximates structure assuming flat-to-nested mapping. Note: file inputs and complex widget states cannot be round-tripped through JSON. Pro tip: always validate that your server-side parser uses the same bracket-notation convention as your front-end serializer - PHP and Rails differ on trailing-bracket array syntax.

html form to json form to object form serializer json to form html form converter form data extractor nested form fields

Formulas

The core algorithm converts a flat list of name/value pairs into a nested object using path decomposition.

parse(name) segments = name.match(/([^\[\]]+)/g)

For each form element el with name and extracted value:

deepSet(obj, segments, value)

Where deepSet iterates through segments[0] … segments[n 1], creating intermediate containers:

if nextSegment = empty string ("") container is Array, push value

if nextSegment Z+ container is Array, set at index

otherwise container is Object, set key

Where obj = the root result object, segments = array of path keys extracted from the bracket notation, and value = the extracted element value after type coercion. Type coercion rules: type="number" and type="range"parseFloat; type="checkbox" without explicit array name → TRUE/FALSE; empty string values are preserved as empty strings, not coerced to NULL.

Reference Data

Element TypeName ExampleValue Extraction RuleJSON Output Type
<input type="text">usernameRead .valueString
<input type="number">ageParse .value as NumberNumber
<input type="checkbox">agreeReturn TRUE/FALSE from .checkedBoolean
<input type="checkbox"> (with value)colors[]Collect all checked .valuesArray of Strings
<input type="radio">genderRead .value of checked radioString
<input type="hidden">csrf_tokenRead .valueString
<input type="email">user[email]Read .valueString (nested)
<input type="date">dobRead .value as ISO stringString (ISO 8601)
<input type="color">theme_colorRead .value as hexString (#hex)
<input type="range">volumeParse .value as NumberNumber
<input type="password">passRead .valueString
<input type="file">avatarSkipped (no serializable value)Omitted
<textarea>bioRead .valueString
<select>countryRead .value of selected optionString
<select multiple>skills[]Collect all selected .valuesArray of Strings
Nested nameuser[address][city]Split path → deep-setNested Object
Array push nameitems[]Append to arrayArray
Indexed array nameitems[0][name]Set at index → deep-setArray of Objects
Disabled elementsAnySkipped per HTML specOmitted
Elements without name - Skipped (not submittable)Omitted

Frequently Asked Questions

When multiple checkboxes share a name with trailing brackets (e.g., colors[]), the converter collects only the checked elements and pushes each .value into an array. Unchecked checkboxes are ignored entirely, matching standard browser FormData behavior. If only one checkbox is checked, the result is still an array with one element to maintain type consistency.
The name parser extracts path segments ['user', "addresses", "0", 'street']. Numeric segments trigger array creation at that level. The converter creates: {user: {addresses: [{street: 'value'}]}}. Gaps in indices (e.g., index 0 and index 3 with nothing between) will produce sparse arrays with undefined slots, which serialize to null in JSON.
Yes. Radio buttons sharing the same name attribute are treated as a group. Only the checked radio's value is included in the output object. If no radio in the group is checked, the key is omitted from the result. This matches the HTML specification for form submission - unchecked radios are not "successful controls".
Per the HTML specification (section 4.10.18.3), disabled controls and controls without a name attribute are not "successful controls" and are excluded from form submission. This converter follows the same rule: disabled elements and unnamed elements are skipped during serialization.
The reverse conversion infers element types heuristically. Boolean values become checkbox inputs. Numbers become number inputs. Strings longer than 100 characters become textarea elements. Arrays of primitives become multiple checkboxes. However, select/option elements cannot be reliably reconstructed because the converter cannot know the full set of valid options from a single selected value. The generated HTML uses input elements as a functional approximation.
The trailing empty brackets items[] signal an array-push operation: each element with this name appends its value to the items array in document order. The indexed form items[0] performs a direct assignment at index 0. If you mix both conventions for the same base name in a single form, results may be unpredictable - this mirrors real-world server-side parser behavior in PHP and Rails, which also struggle with mixed notation.