{"id":16834782,"url":"https://github.com/serbanghita/form-to-object","last_synced_at":"2025-04-24T03:48:29.310Z","repository":{"id":10768248,"uuid":"13032496","full_name":"serbanghita/form-to-object","owner":"serbanghita","description":"Convert a HTML form to a JS literal and multidimensional object.","archived":false,"fork":false,"pushed_at":"2025-03-17T13:55:46.000Z","size":2304,"stargazers_count":90,"open_issues_count":2,"forks_count":25,"subscribers_count":11,"default_branch":"3.x","last_synced_at":"2025-04-24T03:48:23.366Z","etag":null,"topics":["form","forms","html-form","javascript","serialization","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serbanghita.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-09-23T10:07:34.000Z","updated_at":"2025-03-17T13:55:48.000Z","dependencies_parsed_at":"2024-01-02T00:44:47.757Z","dependency_job_id":"5d8da990-40cb-4bff-8e76-a9866ed69bf7","html_url":"https://github.com/serbanghita/form-to-object","commit_stats":{"total_commits":180,"total_committers":8,"mean_commits":22.5,"dds":0.07777777777777772,"last_synced_commit":"ea8d9c581aa654a7b5c15dd4eb0cd07cd1d1f6c0"},"previous_names":["serbanghita/formtoobject","serbanghita/form-to-object"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serbanghita%2Fform-to-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serbanghita%2Fform-to-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serbanghita%2Fform-to-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serbanghita%2Fform-to-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serbanghita","download_url":"https://codeload.github.com/serbanghita/form-to-object/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250560006,"owners_count":21450168,"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":["form","forms","html-form","javascript","serialization","typescript"],"created_at":"2024-10-13T12:07:52.081Z","updated_at":"2025-04-24T03:48:29.289Z","avatar_url":"https://github.com/serbanghita.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# form-to-object (formToObject.js)\n\u003e Convert **HTML forms** with all their **fields** and **values** to **multidimensional JavaScript** objects\n\n![Workflow status](https://img.shields.io/github/actions/workflow/status/serbanghita/formToObject/test.yml?style=flat-square)\n![Codecov branch](https://img.shields.io/codecov/c/gh/serbanghita/formToObject.js/v.2.1.0?token=BZRS4v9AWy\u0026style=flat-square)\n![npm version](https://img.shields.io/npm/v/form_to_object?style=flat-square)\n![npm downloads](https://img.shields.io/npm/dm/form_to_object?style=flat-square)\n[![](https://data.jsdelivr.com/v1/package/npm/form_to_object/badge)](https://www.jsdelivr.com/package/npm/form_to_object)\n\n## Install\n\nAs a [npm package](https://www.npmjs.com/package/form_to_object):\n\n```shell\nnpm install form_to_object\n```\n\n```js\nimport formToObject from 'form_to_object';\n// or\nconst formToObject = require('form_to_object');\n```\n\nAs a JS script:\n\n```html\n\u003c!-- Include minified script (~6kb) --\u003e\n\u003cscript src=\"build/formToObject.js\"\u003e\u003c/script\u003e\n\n\u003c!-- jsdelivr (CDN) --\u003e\n\u003cscript src=\"\nhttps://cdn.jsdelivr.net/npm/form_to_object@3.1.0/build/bundle/formToObject.min.js\n\"\u003e\u003c/script\u003e\n```\n\n## Example\n\n* Using the DOM node id: `formToObject('myFormId');`\n* Using the actual DOM Node reference: `formToObject(document.getElementById('myFormId'));`\n\nResulted value:\n\n```json\n{\n  \"saveSettings\": \"Save\",\n  \"name\": \"Serban\",\n  \"race\": \"orc\",\n  \"settings\": {\n     \"input\": \"keyboard\",\n     \"video\": {\n        \"resolution\": \"1024x768\",\n        \"vsync\": \"on\"\n     }\n  }\n}\n```\n\nGood to know:\n\n1. If `\u003cform\u003e` fields are found, but they lack of `name` attribute property, the result will be `{}` (empty object).\n2. If `\u003cform\u003e` contains only `disabled` fields, the result will be `{}` (empty object). If you force `includeDisabledFields` then key:value pairs will be returned.\n3. An empty `\u003cform\u003e` will throw an Error.\n4. In case of an error like non-existing form or invalid selector, an Error will be thrown.\n\n## Options\n\n| Option name                                 | Default                     | Description                                                                                                                          |\n|---------------------------------------------|-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| `includeEmptyValuedElements`                | `boolean` (default `false`) | Return field names as keys with empty value `\"\"` instead of just ignoring them.                                                      | \n| `w3cSuccessfulControlsOnly`                 | `boolean` (default `false`) | TBA, WIP                                                                                                                             |\n| `selectNameWithEmptyBracketsReturnsArray`   | `boolean` (default `true`)  | `\u003cselect\u003e` field names like `name=\"select[]\"` always return an array `[a,b]` instead or array of arrays `[0: [a,b]]`.                |\n| `checkBoxNameWithEmptyBracketsReturnsArray` | `boolean` (default `true`)  | `\u003cinput\u003e` checkboxes with field names like `name=checkbox[]` always return an array `[a,b]` instead or array of arrays `[0: [a,b]]`. |\n\n\n## Browser support\n\nIE 8, Firefox 3.5, Chrome, Safari, Opera 10, every mobile browser.\n\n## Example\n\n![](demo.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserbanghita%2Fform-to-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserbanghita%2Fform-to-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserbanghita%2Fform-to-object/lists"}