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

@nullplatform/json-keys-transform

v0.0.5

Published

A utility for transforming JSON object keys. It supports various transformations such as camelCase, snake_case, and more

Readme

Description

This library helps services to transform camel cased objects to snake cased objects and backwards

Install

npm install @nullplatform/json-keys-transform

It is published to the public npm registry and to GitHub Packages, with the same versions: a project that resolves the whole @nullplatform scope from GitHub Packages (@nullplatform:registry=https://npm.pkg.github.com) gets it from there. TypeScript declarations are included.

It is the transform @nullplatform/server applies to request and response bodies (transform.request.exclude / transform.response.exclude take the same path patterns), so a client can undo exactly what a service does.

Using this library

You can use this library by calling the transform function directly or using one of the function helpers like snakeCaseToCamelCase or camelCaseToSnakeCase. Please take a look to the examples below:

// CommonJS

const {
  transform,
  Style,
  snakeCaseToCamelCase,
  camelCaseToSnakeCase,
} = require('@nullplatform/json-keys-transform');

// ESM

import {
  transform,
  Style,
  snakeCaseToCamelCase,
  camelCaseToSnakeCase,
} from '@nullplatform/json-keys-transform';

// Example objects

const snakeCaseObject = {
  id: 1,
  name: 'John',
  last_name: 'Rambo',
  address: { city: 'Montevideo', street: 'Brasil', door_number: '2424' },
};
const camelCaseObject = {
  id: 1,
  name: 'John',
  lastName: 'Rambo',
  address: { city: 'Montevideo', street: 'Brasil', doorNumber: '2424' },
};

//
// Using transform function
//

let options = { from: Style.SNAKE_CASE, to: Style.CAMEL_CASE };
let result = transform(snakeCaseObject, options);
console.log(result);
// => { id: 1, name: 'John', lastName: 'Rambo', address: { city: 'Montevideo', street: 'Brasil', doorNumber: '2424' }}

options = { from: Style.SNAKE_CASE, to: Style.CAMEL_CASE, exclude: ['last_name'] };
result = transform(snakeCaseObject, options);
console.log(result);
// => { id: 1, name: 'John', last_name: 'Rambo', address: { city: 'Montevideo', street: 'Brasil', doorNumber: '2424' }}

//
// Using snake case to camel case shortcut function
//

result = snakeCaseToCamelCase(snakeCaseObject);
console.log(result);
// => { id: 1, name: 'John', lastName: 'Rambo', address: { city: 'Montevideo', street: 'Brasil', doorNumber: '2424' }}

result = snakeCaseToCamelCase(snakeCaseObject, { exclude: ['last_name'] });
console.log(result);
// => { id: 1, name: 'John', last_name: 'Rambo', address: { city: 'Montevideo', street: 'Brasil', doorNumber: '2424' }}

//
// Using camel case to snake case shortcut function
//

result = camelCaseToSnakeCase(camelCaseObject);
console.log(result);
// => { id: 1, name: 'John', last_name: 'Rambo', address: { city: 'Montevideo', street: 'Brasil', door_number: '2424' }}

result = camelCaseToSnakeCase(camelCaseObject, { exclude: ['lastName'] });
console.log(result);
// => { id: 1, name: 'John', lastName: 'Rambo', address: { city: 'Montevideo', street: 'Brasil', door_number: '2424' }}

Options

The module allows configuring various options to customize the behavior of the key transformation process. Below are the different options available:

  • from: Specifies the case style of the input keys. It must be one of the predefined Style options.
  • to: Specifies the case style to which the keys should be transformed. It must be one of the predefined Style options.
  • exclude: An array of path patterns that should be excluded from transformation. Paths can include wildcards (*). For example, ['address.[*].door_number'] would exclude all door_number keys under the address array from transformation.

API