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

urlchemy

v0.0.4

Published

A lightweight library for handling query strings, supporting nested objects and arrays.

Readme

README for URLchemy


URLchemy

URLchemy is a lightweight and flexible utility library for working with query strings in JavaScript and TypeScript. It provides:

  • Object to Query String Conversion: Convert JavaScript objects into URL-safe query strings.
  • Query String to Object Parsing: Parse query strings back into JavaScript objects.
  • Support for arrays, nested objects, and advanced options for encoding, sorting, and strict formatting.

Features

  • 🔄 Bidirectional conversion: Easily switch between objects and query strings.
  • 🧩 Nested structures: Works with arrays and deeply nested objects.
  • 🎛 Configurable: Customize the encoding, sorting, and formatting of query strings.
  • 🌐 URL-safe: Automatically encodes keys and values for safe use in URLs.

Installation

Install URLchemy using npm or yarn:

npm install urlchemy

Usage

1. Convert an object to a query string

import { objectToQueryString } from 'urlchemy';

const params = {
  user: {
    id: 123,
    name: 'John Doe',
  },
  tags: ['developer', 'programmer'],
};

const queryString = objectToQueryString(params, { encode: true });
console.log(queryString);
// Output: user%5Bid%5D=123&user%5Bname%5D=John%20Doe&tags=developer&tags=programmer

2. Parse a query string into an object

import { queryStringToObject } from 'urlchemy';

const query = '?user%5Bid%5D=123&user%5Bname%5D=John%20Doe&tags=developer&tags=programmer';
const parsedObject = queryStringToObject(query);

console.log(parsedObject);
// Output: { user: { id: '123', name: 'John Doe' }, tags: ['developer', 'programmer'] }

3. Add advanced options

const params = {
  user: {
    id: 123,
    name: 'John Doe',
  },
  tags: ['developer', 'programmer'],
  active: true,
  date: new Date('2023-01-01'),
};

const queryString = objectToQueryString(params, {
  encode: true,
  strict: true,
  prefix: true,
  excludeNulls: true,
  sort: true,
});

console.log(queryString);
// Output: ?active=true&date=2023-01-01T00%3A00%3A00.000Z&tags=developer&tags=programmer&user.id=123&user.name=John%20Doe

API

objectToQueryString(params, options?)

Converts a JavaScript object to a query string.

  • params (Record<string, any>): The object to convert.
  • options (StringifyOptions) (optional):
    • encode (boolean): Encode keys and values (default: true).
    • sort (boolean): Sort keys alphabetically (default: false).
    • strict (boolean): Use dot notation for nested keys (default: false).
    • prefix (boolean): Add a ? prefix to the string (default: false).
    • excludeNulls (boolean): Exclude null or undefined values (default: false).

queryStringToObject(query)

Parses a query string into a JavaScript object.

  • query (string): The query string to parse (e.g., ?key=value&arr=1&arr=2).

Advanced Examples

Handle arrays and nested objects

const params = {
  filters: {
    category: 'books',
    price: {
      min: 10,
      max: 50,
    },
  },
  tags: ['fiction', 'mystery'],
};

const queryString = objectToQueryString(params, {encode: false});
console.log(queryString);
// Output: filters[category]=books&filters[price][min]=10&filters[price][max]=50&tags=fiction&tags=mystery

Decode complex query strings

const query = '?filters[category]=books&filters[price][min]=10&filters[price][max]=50&tags=fiction&tags=mystery';
const parsedObject = queryStringToObject(query);

console.log(parsedObject);
// Output:
// {
//   filters: {
//     category: 'books',
//     price: { min: '10', max: '50' },
//   },
//   tags: ['fiction', 'mystery'],
// }

Roadmap

Ideas for Future Features

  1. Custom serializers: Allow users to define how specific types (e.g., Dates) should be serialized.
  2. Type-safe parsing: Infer and maintain type safety when converting query strings back to objects.
  3. Enhanced array support: Add options for serializing arrays as comma-separated values (tags=fiction,mystery).
  4. Internationalization: Improved handling for non-UTF-8 character encodings.
  5. Integration with TimePulse: Add support for time-sensitive URL queries using TimePulse.

Contributing

Contributions are welcome! Feel free to submit issues or pull requests if you have ideas or encounter bugs.


License

URLchemy is licensed under the MIT License. 🌐✨