You copy a JSON response from an API, and now you need the types for it. Writing them by hand is slow, and the usual online converters mean pasting your data into someone else's website. I built a small VS Code extension, JSON Typer, that does it inside the editor with no network access.

It works in VS Code-compatible editors that use the Open VSX registry: VSCodium, Cursor, Windsurf, Eclipse Theia and similar. I'm part of the team at King AI Kits that built it, so treat this as a how-to from the author.

Install

Open the Extensions view, search for "JSON Typer" and install the one from kingaikits. In an editor that uses Open VSX you can also open Quick Open (Ctrl+P or Cmd+P) and run:

ext install kingaikits.json-typer 

Listing: https://open-vsx.org/extension/kingaikits/json-typer

Use it

  1. Select some JSON in a file, or copy JSON to your clipboard.
  2. Open the Command Palette.
  3. Run JSON Typer: Generate Types from Selection or File (or Paste Clipboard JSON as Types).
  4. Pick a language. The result opens in a tab beside your editor.

Take this input:

{"id":1,"name":"Ada","email":null,"orders":[{"sku":"A1","qty":2,"price":9.5},{"sku":"B2","qty":1}]} 

With the root name set to User, TypeScript comes out as:

export interface Order { sku: string; qty: number; price?: number; } export interface User { id: number; name: string; email: null; orders: Order[]; } 

Notice that price is optional because the second order doesn't have it. Items in an array are merged into one type, and keys missing from some items become optional. Go gets the same treatment:

type Order struct { Sku string `json:"sku"` Qty int64 `json:"qty"` Price *float64 `json:"price,omitempty"` } type User struct { Id int64 `json:"id"` Name string `json:"name"` Email any `json:"email"` Orders []Order `json:"orders"` } 

Whole numbers become integer types, other numbers become floats, and nested object names are derived from the keys (orders gives Order).

What is free

  • TypeScript, as an interface or a type, with optional readonly
  • Go structs with json tags
  • JSON Schema (draft-07)

Settings: jsonTyper.rootName, jsonTyper.typescriptStyle, jsonTyper.readonlyFields and jsonTyper.output (new tab, or replace your selection).

The parser is forgiving. It accepts comments, trailing commas, and a leading const data = with a trailing ;, so you can select a snippet straight out of source code.

Pro

Zod schemas, Python dataclasses and Pydantic models, Rust structs with serde, C# classes and Kotlin @Serializable classes are in Pro, a one-time $4.99 payment with no subscription. You get a key after paying, run JSON Typer: Activate Pro Key, and paste it. The key is checked on your device and works offline.

Privacy

There are no network calls and no telemetry. Your JSON never leaves your machine. The only thing stored is your Pro key, in the extension's own storage.

Links

If there's a language or an inference rule you'd like added, open an issue and tell me what your JSON looks like.