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

snaptype

v1.0.2

Published

Generate TypeScript types and Zod schemas from JSON, CSV, or live API responses

Readme

snaptype

Stop writing TypeScript types by hand.

snaptype is a CLI that turns your JSON files, CSV exports, REST APIs, and OpenAPI/GraphQL schemas into TypeScript interfaces and Zod schemas — in one command.

snaptype.dev — docs, Pro licence, live demo


The problem

Every time you hit an API or open a data file, you end up writing types by hand. You copy-paste a JSON response, squint at the shape, type out an interface. The API changes — you do it again.

snaptype automates that step entirely.


Quick start

npx snaptype from-json ./user.json -o types.ts

Input — user.json:

{
  "id": 1,
  "name": "Alice",
  "email": "[email protected]",
  "role": "admin",
  "createdAt": "2024-01-15T10:30:00Z",
  "address": { "city": "Paris", "zip": "75001" }
}

Output — types.ts:

// Generated by snaptype — do not edit manually

export interface Address {
  city: string;
  zip: string;
}

export interface User {
  id: number;
  name: string;
  email: string; // email
  role: string;
  createdAt: string; // ISO 8601
  address: Address;
}

Add --zod to also get a ready-to-use Zod schema:

npx snaptype from-json ./user.json -o types.ts --zod
// types.zod.ts — Generated by snaptype

import { z } from 'zod';

export const AddressSchema = z.object({
  city: z.string(),
  zip: z.string(),
});

export const UserSchema = z.object({
  id: z.number(),
  name: z.string(),
  email: z.string().email(),
  role: z.string(),
  createdAt: z.string().datetime(),
  address: AddressSchema,
});

export type User = z.infer<typeof UserSchema>;

Installation

npm install -D snaptype
# peer dep if you use --zod
npm install zod

Requires Node.js 20+.


Input sources

| Source | Command | |---|---| | Local JSON file | snaptype from-json ./data.json -o types.ts | | Live API / URL | snaptype from-url https://api.example.com/users -o types.ts | | CSV file | snaptype from-csv ./export.csv -o types.ts | | stdin (pipe) | curl https://… \| snaptype from-stdin --name User -o types.ts | | OpenAPI 3.x spec | snaptype from-openapi ./openapi.yaml -o types.ts | | GraphQL endpoint | snaptype from-graphql https://…/graphql -o types.ts (Pro) |


What it infers automatically

  • Primitives: string, number, boolean, null
  • Nested objects and arrays
  • Optional and nullable fields
  • Semantic hints on string fields — email, url, ISO 8601 dates → .email(), .url(), .datetime() in Zod
  • Enum / union literals when a field has low cardinality (≤ 10 distinct values, ≥ 80% coverage)
  • $ref, oneOf, allOf, anyOf from OpenAPI specs
  • GraphQL scalars, enums, unions, and interfaces

More commands

# Detect breaking changes between two type files (Pro)
snaptype diff old.ts new.ts

# Generate realistic mock data from a schema (Pro)
snaptype mock ./types.ts -o mocks.ts

# Convert existing TypeScript interfaces to Zod schemas (Pro)
snaptype to-zod ./src/types/user.ts

# Re-export all generated files in one barrel file
snaptype barrel ./src/types

# Watch a source file and regenerate on change (Pro)
snaptype from-json ./api.json -o types.ts --watch

Project config

Drop a .snaptyperc at the root of your project to stop repeating flags:

{
  "naming": "camel",
  "emit": "interface",
  "zod": true,
  "outDir": "src/types"
}

CLI flags always take priority. See the configuration docs for all keys.


Free vs Pro

Pro is a one-time purchase — no subscription, works across machines.

| Feature | Free | Pro | |---|:---:|:---:| | from-json (single file) | ✓ | ✓ | | from-url, from-csv, from-stdin | ✓ | ✓ | | from-openapi (single file) | ✓ | ✓ | | TypeScript + Zod generation | ✓ | ✓ | | Semantic inference (email, date, url) | ✓ | ✓ | | Enum / union literal detection | ✓ | ✓ | | --readonly, .snaptyperc, barrel | ✓ | ✓ | | from-json / from-url (multiple files) | — | ✓ | | from-graphql | — | ✓ | | snaptype diff + --ci | — | ✓ | | snaptype mock | — | ✓ | | snaptype to-zod | — | ✓ | | --watch | — | ✓ |

Get Pro at snaptype.dev


License

MIT — free tier is free forever. Pro features require a licence key.