{"_id":"parse-nested-form-data","_rev":"4-8b5fa75479464d74a4d790204aee2d30","name":"parse-nested-form-data","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"parse-nested-form-data","version":"1.0.0","keywords":["FormData","parse","nested","form","array","object","parse"],"author":{"name":"Christian Schurr","email":"chris@schurr.dev"},"license":"MIT","_id":"parse-nested-form-data@1.0.0","maintainers":[{"name":"milamer","email":"fischerc.it@gmail.com"}],"homepage":"https://github.com/milamer/parse-nested-form-data#readme","bugs":{"url":"https://github.com/milamer/parse-nested-form-data/issues"},"dist":{"shasum":"497fdba08d9d99c6425f49c589fd1e1d1c637034","tarball":"https://registry.npmjs.org/parse-nested-form-data/-/parse-nested-form-data-1.0.0.tgz","fileCount":12,"integrity":"sha512-lIeGMds1l6h6YXxhmcD4aD72xwFAqfDjuzh9dUMyS4h5WhimOfhmfeDiT3KZhqpj+XgaEyen+X9Ks9Y3+Rp5+g==","signatures":[{"sig":"MEYCIQDCohDSyduL2c3f2kvqvilrNL63f94slpTU9MJqc9NatAIhAKif2a6kEx6WVDee83RjBbsXaq6ce2KVQ2SFGycMnkdW","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":98730,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjuuHCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr7Gw//RAAeOzoV/ElJm3H6Z6Ai2mmt0icVzNRqbHis6uMYEnlINuWd\r\n/n+aTg8n4wUlTp5DhXl71tDNa2oSLAIvLTlYf3Mf4GV+A+a4aTO5lrc7i0VJ\r\n7y/SpdeYFTIizx2it/DlguZDmYRQx+ZyDPKWEkjloAQ6WNr61Tnh3IWCr2wi\r\nQQQWBDwXN438nzuzdU7YveAJlsckhj80ZIQLhQKplhx7FgnjSKv27sO4gMwr\r\ng8YhJKJ5Zp8Vb5sdeJ8LmUV51i7zR9vuRO3SrAVsCtZ7/Py+1KwZOcp2KjvK\r\nA0BtBZxHwBqY9Q+6CF+nJmhhRjje0vhzRTTyZ28X0O9P7hwrXGmw/R5yJLFg\r\nloEpIu8V9yEOiFBeymCdR9hufCkKiSDsR2gx9baOndvdyW/VBH1A8bwf2nNL\r\nz8B4vB6BDO8LZPNCBSeh5F7hYzjZlgE6tTdoz21fgSAn/+GWKrICMc82eZtA\r\ngw1y08XcaAQRRh1NtJ5L4gpOXNTGZtRUL91Mh6G2BdsEZe4WpO3vo18Uml7g\r\n8/mPuw/wj6xJUcDgu6sCd1zyn2Gv3SaKfiIxD1uxCj/UsTcy6FHuS1OFI7h8\r\nVTXeeX4NosM7XrkD8THVU8myzBPoRXW+8VKcZh8j+1IPdxvoD4IiM0m8psZd\r\n6a8VJt+FYL+NLEwBxmWwidL9zGF/cy0AK5c=\r\n=SEOo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/parse-nested-form-data.cjs.js","types":"dist/index.d.ts","module":"dist/parse-nested-form-data.esm.js","gitHead":"57200d3d525f0eb14ce9c95ea3bc2fdb33be31a1","scripts":{"lint":"kcd-scripts lint","test":"kcd-scripts test","build":"kcd-scripts build --bundle --environment BUILD_NAME:parseNestedFormData","clean":"rimraf dist coverage node_modules","setup":"npm install && npm run validate -s","validate":"kcd-scripts validate","build:toc":"npx doctoc .","typecheck":"kcd-scripts typecheck","test:update":"npm test -- --updateSnapshot --coverage"},"_npmUser":{"name":"milamer","email":"fischerc.it@gmail.com"},"repository":{"url":"git+https://github.com/milamer/parse-nested-form-data.git","type":"git"},"_npmVersion":"6.14.17","description":"A tiny node module for parsing FormData by name into objects and arrays","directories":{},"_nodeVersion":"14.21.1","dependencies":{"@babel/runtime":"^7.19.0"},"eslintConfig":{"rules":{"one-var":["error","never"],"import/extensions":"off","max-lines-per-function":"off","@typescript-eslint/no-loop-func":"off","@typescript-eslint/no-unsafe-assignment":"off"},"extends":"./node_modules/kcd-scripts/eslint.js"},"eslintIgnore":["node_modules","coverage","dist"],"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^3.0.2","typescript":"^4.8.4","kcd-scripts":"^12.3.0","@remix-run/web-file":"^3.0.2","@remix-run/web-form-data":"^3.0.3"},"peerDependencies":{"@remix-run/web-file":">=3.0.0"},"peerDependenciesMeta":{"@remix-run/web-form-data":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/parse-nested-form-data_1.0.0_1673191874552_0.5408375548256537","host":"s3://npm-registry-packages"},"deprecated":"Vulnerable to GHSA-27g4-8gfp-mm2j (event loop DoS via large array indices). Upgrade to 1.1.0 or later: https://github.com/milamer/parse-nested-form-data/releases/tag/v1.1.0"},"1.0.1":{"name":"parse-nested-form-data","version":"1.0.1","keywords":["FormData","parse","nested","form","array","object","parse"],"author":{"name":"Christian Schurr","email":"chris@schurr.dev"},"license":"MIT","_id":"parse-nested-form-data@1.0.1","maintainers":[{"name":"milamer","email":"fischerc.it@gmail.com"}],"homepage":"https://github.com/milamer/parse-nested-form-data#readme","bugs":{"url":"https://github.com/milamer/parse-nested-form-data/issues"},"dist":{"shasum":"e164713a1131ec7cd5d645b0bc4849dfa5d1e655","tarball":"https://registry.npmjs.org/parse-nested-form-data/-/parse-nested-form-data-1.0.1.tgz","fileCount":12,"integrity":"sha512-BuMXaUOncsciUsL3N69cMvEHCeLAG6sRoFa7NPbw30Jn+klD47hlx/+Rq1MWrxsdQWu8157d2TnReea/NWTuFA==","signatures":[{"sig":"MEQCIHYehIqQFXe2HDjIBt/cwaI7hsX4M+/7re7KHQTYAq8XAiB1WeXJQJYuNvVTpAKd6q9mC/Ta9VEcpTWYiJ19/58X2A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":109366},"main":"dist/parse-nested-form-data.cjs.js","types":"dist/index.d.ts","module":"dist/parse-nested-form-data.esm.js","gitHead":"527ad58eb486e32438f7198fb88315c20449d792","scripts":{"lint":"kcd-scripts lint","test":"kcd-scripts test","build":"kcd-scripts build --bundle --environment BUILD_NAME:parseNestedFormData","clean":"rimraf dist coverage node_modules","setup":"npm install && npm run validate -s","validate":"kcd-scripts validate","build:toc":"npx doctoc .","typecheck":"kcd-scripts typecheck","test:update":"npm test -- --updateSnapshot --coverage"},"_npmUser":{"name":"milamer","email":"fischerc.it@gmail.com"},"repository":{"url":"git+https://github.com/milamer/parse-nested-form-data.git","type":"git"},"_npmVersion":"6.14.18","description":"A tiny node module for parsing FormData by name into objects and arrays","directories":{},"_nodeVersion":"14.21.3","dependencies":{"@babel/runtime":"^7.19.0"},"eslintConfig":{"rules":{"one-var":["error","never"],"import/extensions":"off","max-lines-per-function":"off","@typescript-eslint/no-loop-func":"off","@typescript-eslint/no-unsafe-assignment":"off"},"extends":"./node_modules/kcd-scripts/eslint.js"},"eslintIgnore":["node_modules","coverage","dist"],"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^3.0.2","typescript":"^4.8.4","kcd-scripts":"^12.3.0","@types/minimatch":"^3.0.5","@remix-run/web-file":"^3.0.2","@remix-run/web-form-data":"^3.0.3"},"peerDependencies":{"@remix-run/web-file":">=3.0.0"},"peerDependenciesMeta":{"@remix-run/web-form-data":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/parse-nested-form-data_1.0.1_1778273504045_0.7220158812948887","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Vulnerable to GHSA-27g4-8gfp-mm2j (event loop DoS via large array indices). Upgrade to 1.1.0 or later: https://github.com/milamer/parse-nested-form-data/releases/tag/v1.1.0"},"1.1.0":{"name":"parse-nested-form-data","version":"1.1.0","keywords":["FormData","array","form","form-data","lightweight","multipart","nested","nextjs","no-dependencies","object","parse","parser","react-router","remix","server-actions","tiny","typescript","urlsearchparams","zero-dependency"],"author":{"name":"Christian Schurr","email":"chris@schurr.dev"},"license":"MIT","_id":"parse-nested-form-data@1.1.0","maintainers":[{"name":"milamer","email":"fischerc.it@gmail.com"}],"homepage":"https://github.com/milamer/parse-nested-form-data#readme","bugs":{"url":"https://github.com/milamer/parse-nested-form-data/issues"},"dist":{"shasum":"7ff12bf9214411444eed45d7f99731e0db59e30a","tarball":"https://registry.npmjs.org/parse-nested-form-data/-/parse-nested-form-data-1.1.0.tgz","fileCount":10,"integrity":"sha512-1coPdYi6vywiGhwmv0GeNnmqlzCoXGQ32uA84T1SAAAcjI11ZY3r41x/oEuJRSzDKvN53QyUkYol2dkvrEGYBQ==","signatures":[{"sig":"MEYCIQCDoJJY+ag3/KbLuu0ZzVAjSB8K8+S16ZUj/ykHbiD86wIhALQSVqPLiHYjyNLyx+tn+5gQYM0TGAF4CJ2a9l5dipNF","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/parse-nested-form-data@1.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":159135},"main":"dist/parse-nested-form-data.cjs.js","types":"dist/index.d.ts","module":"dist/parse-nested-form-data.esm.js","gitHead":"cd88e9e2f8ff087b6aff85904a581363fcc08834","release":{"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits"}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits"}],["@semantic-release/npm",{"npmPublish":false}],["@semantic-release/exec",{"publishCmd":"npm stage publish --tag ${nextRelease.channel ? 'release-' + nextRelease.channel : 'latest'}"}],"@semantic-release/github"],"branches":["+([0-9]).x","+([0-9]).+([0-9]).x","main"]},"scripts":{"knip":"knip","lint":"oxlint --type-aware --deny-warnings","size":"size-limit","test":"vitest run","build":"node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsdown","clean":"node -e \"for (const d of ['dist','coverage']) require('fs').rmSync(d,{recursive:true,force:true})\"","format":"oxfmt","validate":"npm run format:check && npm run lint && npm run typecheck && npm run test:coverage && npm run build && npm run test:dist && npm run check:package && npm run size && npm run knip","build:toc":"doctoc README.md && oxfmt README.md","test:dist":"node scripts/smoke-dist.mjs","typecheck":"tsc -p .","test:watch":"vitest","format:check":"oxfmt --check","check:package":"publint && attw --pack .","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","approver":{"name":"milamer","email":"fischerc.it@gmail.com"},"trustedPublisher":{"id":"github","oidcConfigId":"cc47c1c7-20dc-4f30-be19-8445b9378148"}},"commitlint":{"extends":["@commitlint/config-conventional"]},"devEngines":{"packageManager":{"name":"npm","onFail":"error","version":">=11.19.1"}},"repository":{"url":"git+https://github.com/milamer/parse-nested-form-data.git","type":"git"},"_npmVersion":"11.19.1","description":"Tiny (under 2 kB), dependency-free parser that turns FormData into nested objects and arrays, based on the field names. Works in browsers, Node.js, Deno, Bun and edge runtimes.","directories":{},"sideEffects":false,"_nodeVersion":"24.22.2","allowScripts":{"fsevents":false,"lefthook":false,"@tybys/wasm-util":false},"_hasShrinkwrap":false,"packageManager":"npm@11.19.1+sha512.cedb312b1b7f92421a02cfb68b4194e88f8346651dacd6acc5364a25ef5309d4a32b19616a1ff8aff865e7280c0fa5c0835a99f5cd93368991e2a80ec9da75d2","devDependencies":{"knip":"^6.44.1","oxfmt":"^0.76.0","doctoc":"^2.5.0","oxlint":"^1.91.0","tsdown":"^0.23.5","vitest":"^5.1.0","publint":"^0.3.25","lefthook":"^2.2.2","fast-check":"^4.10.2","size-limit":"^14.3.0","typescript":"7.0.2","@commitlint/cli":"^21.2.4","oxlint-tsgolint":"^7.0.2006","@remix-run/web-file":"^3.0.2","@vitest/coverage-v8":"^5.1.0","@arethetypeswrong/cli":"^0.18.5","@size-limit/preset-small-lib":"^14.3.0","@commitlint/config-conventional":"^21.2.4"},"_npmOperationalInternal":{"tmp":"tmp/parse-nested-form-data_1.1.0_1794224663866_0.001968275563150823","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2023-01-08T15:31:14.551Z","modified":"2026-11-09T12:08:20.199Z","1.0.0":"2023-01-08T15:31:14.756Z","1.0.1":"2026-05-08T20:51:44.193Z","1.1.0":"2026-11-09T11:44:23.989Z"},"bugs":{"url":"https://github.com/milamer/parse-nested-form-data/issues"},"author":{"name":"Christian Schurr","email":"chris@schurr.dev"},"license":"MIT","homepage":"https://github.com/milamer/parse-nested-form-data#readme","keywords":["FormData","array","form","form-data","lightweight","multipart","nested","nextjs","no-dependencies","object","parse","parser","react-router","remix","server-actions","tiny","typescript","urlsearchparams","zero-dependency"],"repository":{"url":"git+https://github.com/milamer/parse-nested-form-data.git","type":"git"},"description":"Tiny (under 2 kB), dependency-free parser that turns FormData into nested objects and arrays, based on the field names. Works in browsers, Node.js, Deno, Bun and edge runtimes.","maintainers":[{"name":"milamer","email":"fischerc.it@gmail.com"}],"readme":"<div align=\"center\">\n<h1>parse-nested-form-data</h1>\n\n<p>Parse FormData into nested objects and arrays, based on the field names</p>\n</div>\n\n---\n\n<!-- prettier-ignore-start -->\n[![Build Status][build-badge]][build]\n[![Code Coverage][coverage-badge]][coverage]\n[![version][version-badge]][package]\n[![Size][size-badge]][size]\n[![downloads][downloads-badge]][npmtrends]\n[![MIT License][license-badge]][license]\n[![All Contributors][all-contributors-badge]](#contributors-)\n[![PRs Welcome][prs-badge]][prs]\n[![Code of Conduct][coc-badge]][coc]\n<!-- prettier-ignore-end -->\n\nA form sends flat name-value pairs. This library turns them into nested objects\nand arrays, with numbers, booleans and `null`. The field names tell it how.\n\n```html\n<form method=\"post\">\n  <input name=\"user.name\" value=\"Ada\" />\n  <input name=\"+user.age\" value=\"36\" />\n  <input name=\"&user.admin\" type=\"checkbox\" checked />\n  <input name=\"tags[]\" value=\"math\" />\n  <input name=\"tags[]\" value=\"code\" />\n</form>\n```\n\n```ts\nparseFormData(formData)\n// {\n//   user: {name: 'Ada', age: 36, admin: true},\n//   tags: ['math', 'code'],\n// }\n```\n\nIt's under 2 kB (minified and brotli-compressed), has no dependencies and works\nin all modern JavaScript runtimes (see\n[Supported runtimes](#supported-runtimes)).\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n- [Install](#install)\n- [Usage](#usage)\n- [Field names](#field-names)\n  - [Numbers](#numbers)\n  - [Booleans](#booleans)\n  - [Null](#null)\n  - [Arrays](#arrays)\n  - [Objects](#objects)\n  - [Files](#files)\n- [API](#api)\n  - [parseFormData(formData, options?)](#parseformdataformdata-options)\n    - [formData](#formdata)\n    - [options](#options)\n      - [removeEmptyString](#removeemptystring)\n      - [depth](#depth)\n      - [transformEntry](#transformentry)\n- [Errors](#errors)\n- [Security](#security)\n- [Supported runtimes](#supported-runtimes)\n- [Issues](#issues)\n  - [🐛 Bugs](#-bugs)\n  - [💡 Feature Requests](#-feature-requests)\n- [Contributors ✨](#contributors-)\n- [LICENSE](#license)\n- [Special Thanks](#special-thanks)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Install\n\n```sh\nnpm install parse-nested-form-data\n```\n\n## Usage\n\n```ts\nimport {parseFormData} from 'parse-nested-form-data'\n\nconst data = parseFormData(await request.formData())\n```\n\n`parseFormData` reads each entry, puts its value at the place its name tells,\nand returns a new object. The input stays unchanged.\n\n## Field names\n\n| In the name      | Meaning                              | Name and value | Result          |\n| ---------------- | ------------------------------------ | -------------- | --------------- |\n| `.key`           | A key in an object                   | `a.b` = `x`    | `{a: {b: 'x'}}` |\n| `[key]`          | A key in an object, same as `.key`   | `a[b]` = `x`   | `{a: {b: 'x'}}` |\n| `[]`             | Add the value to the end of an array | `a[]` = `x`    | `{a: ['x']}`    |\n| `[0]`, `[1]`, …  | Put the value at this array position | `a[0]` = `x`   | `{a: ['x']}`    |\n| `+` at the start | Change the value to a number         | `+a` = `36`    | `{a: 36}`       |\n| `&` at the start | Change the value to a boolean        | `&a` = `on`    | `{a: true}`     |\n| `-` at the start | Change the value to `null`           | `-a` = `x`     | `{a: null}`     |\n\nYou can combine them, for example `+orders[0].items[].price`.\n\nIn this README, the name without its `+`, `&` or `-` is the **path**. Each\n`key`, `.key`, `[key]`, `[]` and `[0]` in it is a **path part**: `a.b[0]` has\nthree path parts.\n\n### Numbers\n\nA name that starts with `+` changes the value with `Number(value)`. A value that\nisn't a number gives `NaN`. An empty string gives `0`.\n\n```ts\nconst formData = new FormData()\nformData.append('+a', '1')\nformData.append('+b', '1.5')\nformData.append('+c', 'x')\nparseFormData(formData)\n// {a: 1, b: 1.5, c: NaN}\n```\n\n### Booleans\n\nA name that starts with `&` changes the value to a boolean. The value `on`,\n`true` or any number other than `0` gives `true`. All other values give `false`.\n\n```ts\nconst formData = new FormData()\nformData.append('&a', 'on')\nformData.append('&b', 'true')\nformData.append('&c', '1')\nformData.append('&d', 'off')\nformData.append('&e', 'false')\nformData.append('&f', '0')\nparseFormData(formData)\n// {a: true, b: true, c: true, d: false, e: false, f: false}\n```\n\nA checkbox sends `on` when it's checked. When it isn't checked, the browser\nsends nothing, so the key is missing from the result.\n\n### Null\n\nA name that starts with `-` changes the value to `null`, whatever the value is.\n\n```ts\nconst formData = new FormData()\nformData.append('-a', 'x')\nparseFormData(formData)\n// {a: null}\n```\n\n### Arrays\n\n`[]` adds the value to the end of the array, in the order of the entries:\n\n```ts\nconst formData = new FormData()\nformData.append('a[]', '1')\nformData.append('a[]', '2')\nparseFormData(formData)\n// {a: ['1', '2']}\n```\n\n`[0]`, `[1]`, … put the value at that position. The order of the entries doesn't\nmatter. Gaps are removed, so `a[1]` and `a[5]` give an array of two values:\n\n```ts\nconst formData = new FormData()\nformData.append('a[5]', 'second')\nformData.append('a[1]', 'first')\nparseFormData(formData)\n// {a: ['first', 'second']}\n```\n\nOne array can't use both `[]` and `[0]`. That throws a `MixedArrayError`.\n\nThe largest position is `4294967294`, the largest index a JavaScript array can\nhold. A larger number throws an `InvalidPathError`.\n\nArrays can hold objects and other arrays:\n\n```ts\nconst formData = new FormData()\nformData.append('a[0].b', '1')\nformData.append('a[1].b', '2')\nformData.append('c[0][]', '3')\nformData.append('c[0][]', '4')\nformData.append('c[1][]', '5')\nparseFormData(formData)\n// {a: [{b: '1'}, {b: '2'}], c: [['3', '4'], ['5']]}\n```\n\n### Objects\n\n`.key` and `[key]` mean the same thing, so `a.b` and `a[b]` are the same key.\nOnly digits in brackets (`[0]`) make an array. You can mix both forms with each\nother and with arrays:\n\n```ts\nconst formData = new FormData()\nformData.append('a[b]', '1')\nformData.append('a.c[0].d', '2')\nformData.append('a[c][1][d]', '3')\nparseFormData(formData)\n// {a: {b: '1', c: [{d: '2'}, {d: '3'}]}}\n```\n\nThe text in brackets is the key exactly as written. It can contain `.`, `[` and\n`]`, if the brackets inside are balanced:\n\n```ts\nconst formData = new FormData()\nformData.append('a[b.c]', '1')\nformData.append('a[d[e]]', '2')\nparseFormData(formData)\n// {a: {'b.c': '1', 'd[e]': '2'}}\n```\n\nBrackets in the wrong place don't cause an error:\n\n- A `[` without a matching `]` stays in the key. `a[[0]` is the key `[0` in `a`.\n  `a[0` is the key `a[0`.\n- A `]` without a matching `[` stays in the key. `a]b` is the key `a]b`.\n- Text after `]` starts the next key. `a[0]b` is the same as `a[0].b`.\n- Empty keys are skipped. `a..b` and `a.[b]` are the same as `a.b`, and `[a]` is\n  the same as `a`.\n\n### Files\n\n`File` values stay as they are. This includes native files and files from a\npolyfill such as `@remix-run/web-file`. A file is always the end of a path:\n\n```ts\nconst formData = new FormData()\nformData.append('avatar', new File(['...'], 'avatar.png'))\nparseFormData(formData)\n// {avatar: File}\n\nformData.append('avatar.name', 'me.png')\nparseFormData(formData)\n// throws DuplicateKeyError('avatar')\n```\n\n## API\n\n### parseFormData(formData, options?)\n\nReturns a new object with the parsed values.\n\n#### formData\n\nType: `Iterable<[string, string | File]>`\n\nA `FormData` object, or any other list of `[name, value]` pairs, for example\n`[['a.b', 'x']]` or a `URLSearchParams` object.\n\n#### options\n\nType: `object`\n\n##### removeEmptyString\n\nType: `boolean`\\\nDefault: `false`\n\nSkip all entries whose value is an empty string (`''`).\n\n```ts\nconst formData = new FormData()\nformData.append('a', '')\nformData.append('b', 'x')\nparseFormData(formData, {removeEmptyString: true})\n// {b: 'x'}\n```\n\n##### depth\n\nType: `number`\\\nDefault: `Infinity`\n\nThe maximum number of path parts in one path. All parts count, so `a.b[0]` and\n`a[b][]` both have three. A longer path throws a [`DepthLimitError`](#errors).\nThe value must be a positive integer or `Infinity`. Other values throw a\n`TypeError`.\n\n```ts\nconst formData = new FormData()\nformData.append('user.address.street', 'Main St')\nparseFormData(formData, {depth: 3})\n// {user: {address: {street: 'Main St'}}}\n\nformData.append('user.address.geo.lat', '52.5')\nparseFormData(formData, {depth: 3})\n// throws DepthLimitError('user.address.geo.lat')\n```\n\nThe parser can handle any depth. But a field like `a.a.a…` with thousands of\nparts makes an object that crashes code that walks it recursively, for example\n`JSON.stringify`, validators or deep clones. If the input comes from untrusted\nclients, set a limit. `depth: 32` is enough for almost every form. Version 2.0\nwill change the default to a smaller number.\n\nThe depth is checked after `transformEntry`. An entry that `removeEmptyString`\nskips is never checked.\n\n##### transformEntry\n\nType:\n`(entry: [path: string, value: string | File], defaultTransform) => {path: string, value: string | number | boolean | null | File}`\\\nDefault:\nthe built-in transform for `+`, `&` and `-`\n\nChanges each entry before it's parsed. It gets the entry as `[name, value]` and\nthe built-in transform. It must return the path and the value for the result.\nCall `defaultTransform(entry)` to keep `+`, `&` and `-` working:\n\n```ts\nconst formData = new FormData()\nformData.append('a', 'x')\nformData.append('+b', '1')\nparseFormData(formData, {\n  transformEntry: (entry, defaultTransform) => {\n    const {path, value} = defaultTransform(entry)\n    return {\n      path,\n      value: typeof value === 'string' ? value.toUpperCase() : value,\n    }\n  },\n})\n// {a: 'X', b: 1}\n```\n\n## Errors\n\n`parseFormData` stops at the first error. All error classes are exported:\n\n```ts\nimport {\n  DepthLimitError,\n  DuplicateKeyError,\n  ForbiddenKeyError,\n  InvalidPathError,\n  MixedArrayError,\n} from 'parse-nested-form-data'\n```\n\n| Error               | Thrown when                                                              | Example names                            |\n| ------------------- | ------------------------------------------------------------------------ | ---------------------------------------- |\n| `DuplicateKeyError` | Two entries set the same path, or use a path part in two different ways. | `a` and `a`; `a` and `a.b`; `a.b`, `a[]` |\n| `MixedArrayError`   | One array uses both `[]` and `[0]`.                                      | `a[]` and `a[0]`                         |\n| `ForbiddenKeyError` | A path part is `__proto__`, `constructor` or `prototype`.                | `__proto__.x`; `a[constructor]`          |\n| `DepthLimitError`   | A path has more path parts than the `depth` option allows.               | `a.b.c` with `depth: 2`                  |\n| `InvalidPathError`  | An array position is larger than `4294967294`.                           | `a[4294967295]`                          |\n| `TypeError`         | The `depth` option isn't a positive integer or `Infinity`.               | `depth: 0`                               |\n\nEach library error has a `key` property. It's the path up to the path part that\ncaused the error. For example, `a.b` = `y` and then `a.b[0]` = `x` throw\n`DuplicateKeyError('a.b')`. In `ForbiddenKeyError`, `DepthLimitError` and\n`InvalidPathError`, a `key` longer than 100 characters is cut to 100 characters\nplus `...`.\n\n`key` is the path after `transformEntry`, not the field name. So it doesn't have\nthe `+`, `&` or `-`: `+a.b.c` with `depth: 2` throws `DepthLimitError('a.b.c')`.\nA custom `transformEntry` can change the path completely. If you use `key` to\nfind the form field, undo your own transform first.\n\nThe entries are parsed in order, so the error of an earlier entry comes first.\nIn one entry, the depth is checked first: a path that's too deep throws\n`DepthLimitError`, even if it has `__proto__` in it.\n\n```ts\ntry {\n  parseFormData(formData)\n} catch (error) {\n  if (error instanceof DuplicateKeyError) {\n    return badRequest(`The field ${error.key} is used more than once`)\n  }\n  throw error\n}\n```\n\n## Security\n\n`__proto__`, `constructor` and `prototype` could change `Object.prototype`. So a\npath part with one of these names throws a `ForbiddenKeyError`, in every\nposition, with or without brackets:\n\n```ts\nconst formData = new FormData()\nformData.append('user.__proto__.isAdmin', 'true')\nparseFormData(formData)\n// throws ForbiddenKeyError('user.__proto__')\n```\n\nOther names that exist on `Object.prototype` at parse time (`toString`,\n`hasOwnProperty`, …, and names that a newer runtime or other code adds) would\nhide a built-in method of the result. So the parser removes every entry with\nsuch a name in its path. It parses the entry like any other entry first, so the\nentry causes the same errors as any other name. Because of this, an error\ndoesn't tell the client which properties exist on the server's\n`Object.prototype`.\n\n```ts\nconst formData = new FormData()\nformData.append('user.name', 'Ada')\nformData.append('user.toString', 'x')\nformData.append('settings.valueOf', 'x')\nparseFormData(formData)\n// {user: {name: 'Ada'}}\n```\n\nFor input from untrusted clients, also set the [`depth`](#depth) option.\n\n## Supported runtimes\n\nThe library uses only ES2020 and no runtime APIs. It works in:\n\n- browsers\n- Node.js (CI tests versions 22, 24 and 26)\n- Deno\n- Bun\n- Cloudflare Workers\n- Vercel (Edge and Node.js runtimes)\n\nThe package has ESM, CommonJS and UMD builds. In a `<script>` tag, the UMD build\nsets the global `parseNestedFormData`.\n\n## Issues\n\n_Looking to contribute? Look for the [Good First Issue][good-first-issue] label,\nand see [CONTRIBUTING.md](CONTRIBUTING.md) for how to set up the project._\n\n### 🐛 Bugs\n\nPlease open an issue for bugs, missing documentation or unexpected behavior.\n\n[**See Bugs**][bugs]\n\n### 💡 Feature Requests\n\nPlease open an issue to suggest new features. Vote on feature requests with a\n👍. This helps maintainers decide what to work on.\n\n[**See Feature Requests**][requests]\n\n## Contributors ✨\n\nThanks goes to these people ([emoji key][emojis]):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n  </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors][all-contributors] specification.\nContributions of any kind welcome!\n\n## LICENSE\n\nMIT\n\n## Special Thanks\n\nSpecial thanks to Kent C. Dodds and his [match-sorter][match-sorter] package\nwhere most of the setup is from.\n\n<!-- prettier-ignore-start -->\n[build-badge]: https://img.shields.io/github/actions/workflow/status/milamer/parse-nested-form-data/validate.yml?branch=main&logo=github&style=flat-square\n[build]: https://github.com/milamer/parse-nested-form-data/actions?query=workflow%3Avalidate\n[coverage-badge]: https://img.shields.io/codecov/c/github/milamer/parse-nested-form-data.svg?style=flat-square\n[coverage]: https://codecov.io/github/milamer/parse-nested-form-data\n[version-badge]: https://img.shields.io/npm/v/parse-nested-form-data.svg?style=flat-square\n[package]: https://www.npmjs.com/package/parse-nested-form-data\n[size-badge]: https://img.shields.io/badge/min%2Bbrotli-%3C%202%20kB-brightgreen?style=flat-square\n[size]: https://github.com/milamer/parse-nested-form-data/blob/main/.size-limit.json\n[downloads-badge]: https://img.shields.io/npm/dm/parse-nested-form-data.svg?style=flat-square\n[npmtrends]: https://www.npmtrends.com/parse-nested-form-data\n[license-badge]: https://img.shields.io/npm/l/parse-nested-form-data.svg?style=flat-square\n[license]: https://github.com/milamer/parse-nested-form-data/blob/main/LICENSE\n[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\n[prs]: http://makeapullrequest.com\n[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square\n[coc]: https://github.com/milamer/parse-nested-form-data/blob/main/CODE_OF_CONDUCT.md\n[emojis]: https://github.com/all-contributors/all-contributors#emoji-key\n[all-contributors]: https://github.com/all-contributors/all-contributors\n[all-contributors-badge]: https://img.shields.io/github/all-contributors/milamer/parse-nested-form-data?color=orange&style=flat-square\n[bugs]: https://github.com/milamer/parse-nested-form-data/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug\n[requests]: https://github.com/milamer/parse-nested-form-data/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement\n[good-first-issue]: https://github.com/milamer/parse-nested-form-data/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement+label%3A%22good+first+issue%22\n[match-sorter]: https://github.com/kentcdodds/match-sorter/blob/main/README.md\n<!-- prettier-ignore-end -->\n","readmeFilename":"README.md"}