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

zod-inquirer

v0.5.0

Published

Generate validated inquirer.js prompts from Zod schemas.

Readme

zod-inquirer (WIP)

A TypeScript library that automatically generates validated CLI prompts from Zod schemas.

Installation

npm install zod-inquirer

Usage

Define your schema once, get validated prompts automatically (example uses choices passed to zodPrompter):

import { z } from "zod";
import { zodPrompter } from "zod-inquirer";

const PizzaSchema = z.object({
  name: z.string().describe("Enter your name"), // Zod 3 style
  email: z.email().meta({ description: "Enter your email" }), // Zod 4 style
  age: z.number().int().positive(), // will use default description
  size: z
    .enum(["small", "medium", "large"])
    .meta({ description: "Select your size" }),
  crust: z
    .enum(["thin", "thick", "stuffed"])
    .meta({ description: "Select your crust" }),
  deliveryWindow: z.string().meta({ description: "Select delivery window" }),
  toppings: z
    .array(z.string())
    .min(1, { message: "You must select at least one topping." })
    .max(3, { message: "You can select up to 3 toppings." })
    .meta({ description: "Select up to 3 toppings" }),
  acceptTerms: z.boolean().meta({ description: "Accept terms and conditions" }),
  password: z.string().min(8).meta({ description: "Enter your password" }),
});

const pizza = await zodPrompter(PizzaSchema, {
  choices: {
    deliveryWindow: ["ASAP", "In 30 minutes", "In 1 hour", "Sometime later"],
    toppings: ["pepperoni", "mushrooms", "onions", "sausage", "bacon", "extra cheese"],
  },
});
console.log(pizza);

This will automatically prompt the user with:

  • A text input for name
  • A text input for email
  • A number input for age
  • A select dropdown for size
  • A select dropdown for crust
  • A select dropdown for deliveryWindow
  • A checkbox list for toppings
  • A confirm checkbox for acceptTerms
  • A password input for password

All inputs are validated against your Zod schema with automatic retry on validation failure.

Options

await zodPrompter(schema, {
  maxRetries: 3, // Maximum retry attempts for invalid input (default: 3)
  hint: "press Ctrl+C to abort", // Hint message shown on validation error
  // Provide static choices for specific fields (strings or { name, value } objects)
  choices: {
    deliveryWindow: ["ASAP", "In 30 minutes", "In 1 hour", "Sometime later"],
    toppings: ["pepperoni", "mushrooms", "onions"],
  },
});

Notes:

  • The choices object is a mapping from schema field name to an array of choices.
  • If choices are provided for a field, the prompter will use them instead of deriving options from z.enum.
  • For array fields (e.g. z.array(z.string())) the prompter will use a checkbox multi-select; for single-value fields (e.g. z.string()) it will use a select.
  • Choices can be simple strings or objects with { name, value } to control display text vs stored value.
  • Ensure the keys in choices exactly match your schema field names (case-sensitive).

Supported Types

  • z.string() - Text input, masked based on name: password, secret, token, apikey, apiKey, api_key
  • z.enum() - Select dropdown
  • z.array(z.enum()) - Checkbox multi-select
  • z.boolean() - Checkbox
  • z.number() - Number input
  • z.email() - Email input

License

MIT