Hey community! π If you're building or maintaining JavaScript apps and want clean, efficient, and valid payloads, check out clean-object-keys β a tiny utility to remove null, undefined, and empty strings ("") from your objects.
π What It Does
It cleans up your objects by removing noise before you send them to APIs, save configs, or process data.
const { cleanObject } = require("clean-object-keys");
const messy = {
name: "Alex",
email: "",
phone: undefined,
age: null,
};
const clean = cleanObject(messy);
// Output: { name: "Alex" }
π‘ Why Devs Love It
β
Clean request payloads
β
Sanitize form inputs
β
Works with nested objects
β
No dependencies
β
Super lightweight
π¦ Install & Use
npm install clean-object-keys
π NPM Package: https://www.npmjs.com/package/clean-object-keys
Then import and go!
const { cleanObject } = require("clean-object-keys");
π€ Contribute or Star
Created by Manu Kumar Pal, this package is open-source and ready for your PRs, ideas, or stars β.
Top comments (0)