npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mypolis.eu/formdata

v0.1.2

Published

A lightweight utility to process `FormData` into structured JavaScript objects. It supports nested objects and arrays using bracket notation, making it easier to handle complex form data.

Downloads

243

Readme

@mypolis.eu/formdata

A lightweight utility to process FormData into structured JavaScript objects. It supports nested objects and arrays using bracket notation, making it easier to handle complex form data.

Installation

pnpm add @mypolis.eu/formdata

Or using npm:

npm install @mypolis.eu/formdata

Features

  • Nested Objects: Supports keys like user[name] and user[address][city].
  • Arrays: Supports empty bracket notation (items[]), index notation (items[0]), and repeated keys.
  • Sparse Arrays: Correctly handles sparse arrays (e.g., items[0] and items[2] will result in [val1, undefined, val2]).
  • Complex Structures: Handles nested combinations of objects and arrays.
  • TypeScript Support: Built with TypeScript for excellent developer experience.

Usage

Basic Example

import { formDataToObject } from "@mypolis.eu/formdata";

const formData = new FormData();
formData.append("name", "John Doe");
formData.append("email", "[email protected]");

const result = formDataToObject(formData);
// { name: "John Doe", email: "[email protected]" }

Nested Objects

const formData = new FormData();
formData.append("user[name]", "John");
formData.append("user[address][city]", "Lisbon");

const result = formDataToObject(formData);
/*
{
  user: {
    name: "John",
    address: {
      city: "Lisbon"
    }
  }
}
*/

Arrays

Supports multiple ways of defining arrays:

const formData = new FormData();

// Index notation
formData.append("tags[0]", "news");
formData.append("tags[1]", "sport");

// Empty bracket notation
formData.append("categories[]", "tech");
formData.append("categories[]", "gadgets");

// Repeated names
formData.append("colors", "red");
formData.append("colors", "blue");

const result = formDataToObject(formData);
/*
{
  tags: ["news", "sport"],
  categories: ["tech", "gadgets"],
  colors: ["red", "blue"]
}
*/

Complex Nested Structures

const formData = new FormData();
formData.append("classes[0][name]", "10A");
formData.append("classes[0][students][0]", "Ana");
formData.append("classes[0][students][1]", "João");
formData.append("classes[1][name]", "11B");
formData.append("classes[1][students][0]", "Maria");

const result = formDataToObject(formData);
/*
{
  classes: [
    { name: "10A", students: ["Ana", "João"] },
    { name: "11B", students: ["Maria"] }
  ]
}
*/

License

MIT