JSON Tools

JSON to TypeScript

Generate readable TypeScript interfaces from JSON, with nested objects broken out into their own named interfaces.

Use the tool ↓

Your data is processed locally in your browser and is not uploaded to our servers.

JSON input
JSON
TypeScript
Paste JSON to generate interfaces.

About this tool

Writing TypeScript interfaces by hand for a JSON shape you already have in front of you — an API response, a config file, a fixture — is mostly mechanical transcription: look at each key, figure out its type, write the corresponding interface line, repeat for every nested object. It's exactly the kind of repetitive, error-prone-if-done-by-hand task that's better automated, since a JSON example already contains every piece of information needed to generate the matching interface.

This generator walks your JSON's structure and infers a TypeScript type for every value: string, number, and boolean map directly from their JSON equivalents, null becomes the literal type null, and arrays become the element type followed by [] — inferred from the array's first item, since TypeScript expects a consistent element type for a simple array. Nested objects are the interesting case: rather than inlining their shape, each one becomes its own named interface, referenced by name from its parent, which is what makes the generated code actually readable rather than one deeply indented mega-interface that's hard to scan.

Naming those nested interfaces sensibly matters for the output to be usable without a manual pass — this tool derives a name from the property that held the object (a profile key nested inside your root produces a Profile interface) and converts it to PascalCase, matching TypeScript's interface naming convention. You can set the root type's name directly; nested names follow automatically from their parent property names.

One limitation worth being upfront about, since it affects real generated output: the type inference looks at a single example value, not a full schema — if a field is sometimes a number and sometimes null across different API responses, this tool will type it based on whichever value happened to be in your pasted example. For fields you know vary, you may want to manually widen the generated type afterward (e.g., to number | null). Everything runs locally; nothing you paste is sent anywhere.

How to use it

01

Paste a JSON example

A single representative object or array works best.

02

Set the root type name

Name it to match how you'll use it in your code — User, ApiResponse, Config, etc.

03

Review the generated interfaces

Nested objects appear as their own named, referenced interfaces.

04

Copy or download

Copy directly into a .ts file, or download it ready to use.

Example

JSON
{"name":"John","age":30,"city":"Delhi"}
TypeScript
interface Root {
  name: string;
  age: number;
  city: string;
}

Common use cases

Typing an API response

Generate a starting interface from a real response payload instead of writing one by hand.

Scaffolding a new feature

Quickly get types in place from sample data before building the real logic.

Documenting a config shape

Turn a JSON config file into a typed interface for validation and autocomplete.

Reviewing third-party API shapes

Generate types for an external API's response to use safely in your codebase.

Migrating from JavaScript to TypeScript

Bootstrap interfaces for existing JSON-shaped data as you add types incrementally.

Teaching TypeScript structural typing

Show how a JSON shape maps directly onto an interface definition.

Frequently asked questions

Related tools

Related articles