← All tools

Design & developer tools · Runs in your browser

JSON to TypeScript Interface Generator

Paste JSON to infer interfaces for nested objects, arrays, and primitive values. Your data stays in your browser.

Type or paste valid JSON to generate TypeScript.

About the JSON to TypeScript Interface Generator

The JSON to TypeScript Interface Generator reads a JSON value and infers type declarations for objects, arrays, and primitive values. It can speed up drafting types from a representative response or fixture. Inference reflects only the sample provided; it cannot know omitted cases, domain invariants, validation rules, or the exact names your project expects.

How to use this tool

  1. Paste a valid JSON object, array, or primitive into the input.
  2. Review the generated interfaces and how nested structures are named.
  3. Compare optional and nullable properties with other real examples.
  4. Copy the declarations, rename types to match the codebase, and run TypeScript.

Example

Input

{"user":{"name":"Amina","active":true},"tags":["astro"]}

Possible output

export interface Root { user: RootUser; tags: string[]; }

The excerpt is abbreviated; the full generated declarations include nested fields. A single object cannot reveal which properties might be absent in another response. Provide representative samples or edit optional markers after checking the API contract.

Practical tips and limitations

Type declarations do not validate runtime input. Use a runtime schema or validation step when untrusted data enters an application. Review arrays containing mixed values, empty arrays, nulls, and keys that are not valid JavaScript identifiers, then compile the output with the project’s TypeScript configuration.

Frequently asked questions

Can generated types validate JSON at runtime?

No. TypeScript types are erased at runtime; add runtime validation when your application needs it.

Why might a property need to be optional?

The generator can only infer fields present in the sample. Compare multiple response examples and the source schema.

Does it handle invalid JSON?

Invalid syntax is reported instead of generating types. Correct the JSON and try again.