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

json-typescript-generator

v1.0.0

Published

A CLI to transform JSON to TypeScript Interfaces

Readme

JsonToTypescript

JSON → TypeScript Model CLI

npm version npm downloads license

Convert raw JSON into clean, readable TypeScript types or interfaces in seconds.

alt text

Features

  • One-step generation: paste JSON and press Enter to generate a .ts file.
  • Readable names: nested types are named from JSON keys
    e.g. profileProfile, projectsProject[], settings.notificationsNotifications.
  • Smart inference
    • null becomes any (and any dominates unions).
    • ISO-like date strings become string | Date.
    • Arrays of short token-like strings become string-literal unions, e.g. ("admin" | "editor")[].
  • File naming: output file uses the model name lowercased, e.g. Useruser.ts.
  • No dependencies: single-file Node CLI.

Install

npm install -g json-to-typescript

Usage

Interactive (paste JSON)

json-to-typescript
# Prompts:
# Model name (e.g., User, OrderItem): User
# Paste JSON and press Enter when done:
# { ...your JSON... }
# => generates user.ts in the current directory

From a file

json-to-typescript --model-name Order --input-json ./order.json

With options

  • --interface → generate interface instead of type
  • --no-dates → don't convert ISO strings to Date
  • --no-color → plain log output
  • --out path.ts → specify output file path

Example

Input JSON:

{
  "id": 123,
  "name": "Patrick",
  "profile": { "bio": "Dev", "age": 30 },
  "tags": ["typescript", "node"]
}

Output:

export type Profile = {
  age: number;
  bio: string;
};

export type User = {
  id: number;
  name: string;
  profile: Profile;
  tags: ("typescript" | "node")[];
};

Contributing

PRs welcome!


Future Enhancements

  • Nested file output → split models into multiple .ts files instead of one big file
  • JSON → Java
    • Generate POJOs with optional Lombok annotations.
  • JSON → Rust
    • Generate structs with optional serde annotations for serialization.
  • JSON → Python
    • Generate Pydantic models (ideal for FastAPI and modern Python backends).
  • Java → TypeScript
    • Translate existing Java POJOs into matching TypeScript interfaces.
    • Config file support to specify which POJOs to include for translation.
  • VS Code extension → right-click JSON → Generate TypeScript Interface
  • Web playground → paste JSON in browser → copy TS interface

License

MIT © Kevin Gleeson