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

nestform

v0.0.5

Published

A utility for encoding and decoding nested FormData objects.

Downloads

10

Readme

NestForm

A lightweight TypeScript utility for encoding and decoding nested FormData objects. Perfect for handling complex form data structures in modern web applications.

Features

  • 🔄 Bidirectional conversion between objects and FormData
  • 🎯 Full TypeScript support with type safety
  • 🌳 Handles nested objects and arrays
  • 🎨 Configurable empty string handling
  • 📦 Zero dependencies
  • 🧪 Fully tested
  • 🚀 Tree-shakeable

Installation

# Using npm
npm install nestform

# Using yarn
yarn add nestform

# Using pnpm
pnpm add nestform

Usage

Encoding Objects to FormData

import { encode } from 'nestform'

const data = {
  name: 'John Doe',
  age: 30,
  address: {
    street: '123 Main St',
    city: 'New York',
  },
  hobbies: ['reading', 'gaming'],
  createdAt: new Date(),
}

const formData = encode(data)
// FormData now contains:
// name: "John Doe"
// age: "30"
// address[street]: "123 Main St"
// address[city]: "New York"
// hobbies[0]: "reading"
// hobbies[1]: "gaming"
// createdAt: "2024-01-15T10:30:00.000Z" (ISO format by default)

Date Handling

You can configure how Date objects are encoded:

// ISO format (default)
const formData1 = encode(data, { dateFormat: 'iso' })

// Unix timestamp
const formData2 = encode(data, { dateFormat: 'timestamp' })

// Date.toString() format
const formData3 = encode(data, { dateFormat: 'string' })

Decoding FormData to Objects

import { decode } from 'nestform'

const formData = new FormData()
formData.append('name', 'John Doe')
formData.append('age', '30')
formData.append('address[street]', '123 Main St')
formData.append('address[city]', 'New York')
formData.append('hobbies[0]', 'reading')
formData.append('hobbies[1]', 'gaming')

const data = decode(formData)
// Returns:
// {
//   name: "John Doe",
//   age: "30",
//   address: {
//     street: "123 Main St",
//     city: "New York"
//   },
//   hobbies: ["reading", "gaming"]
// }

Handling Empty Strings

You can configure how empty strings are handled during decoding:

// Preserve empty strings (default)
const data1 = decode(formData, { emptyString: 'preserve' })

// Convert empty strings to null
const data2 = decode(formData, { emptyString: 'set null' })

// Convert empty strings to undefined
const data3 = decode(formData, { emptyString: 'set undefined' })

API Reference

encode(data: object, options?: EncodeOptions): FormData

Converts a plain object into FormData.

  • data: A plain object to encode
  • options.dateFormat: How to handle Date objects
    • 'iso': Convert to ISO 8601 string (default)
    • 'timestamp': Convert to Unix timestamp (number)
    • 'string': Use Date.toString() method
  • Returns: A FormData instance

decode(formData: FormData, options?: { emptyString?: 'preserve' | 'set null' | 'set undefined' }): object

Converts FormData back into a plain object.

  • formData: A FormData instance to decode
  • options.emptyString: Strategy for handling empty strings
    • 'preserve': Keep empty strings as is (default)
    • 'set null': Convert empty strings to null
    • 'set undefined': Convert empty strings to undefined
  • Returns: A decoded object

Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Build the library
pnpm build

# Run type checking
pnpm typecheck

# Format code
pnpm format

# Lint code
pnpm lint

License

MIT License © 2025 Gabriel Vaquer