BUILD, INSPECT AND REUSE

JSON to TypeScript

Turn a JSON sample into a TypeScript type. Merge the shapes observed in arrays, mark missing sample properties optional, and review the result before using it in your code.

Nested objects & mixed arraysOptional sample propertiesReadonly types + .d.ts export

Paste JSON or load an example.

Open a JSON file

This infers a type from examples, not a complete API schema or runtime validator. Empty arrays become Array<unknown>; empty object-only samples become Record<string, unknown>. Numbers map to TypeScript number, without guaranteeing exact large-integer behavior at runtime. Duplicate keys are rejected. Limits: 200,000 characters, 5,000 values and 32 nested containers.

Using JSON to TypeScript

Create a starting type from JSON examples using the existing syntax-aware parser. The output reflects observed data, not an authoritative schema.

  1. Paste JSON, open a UTF-8 file or try an example.
  2. Choose the exported type name and optional readonly output, then generate.
  3. Review inferred unions and optional fields; copy or download the .d.ts declaration.

Example

[{"id":1,"name":"Alex"},{"id":2}]
Infers an array of objects with id: number and optional name?: string.

Questions & answers

Does this validate my API at runtime?

No. TypeScript declarations help static type checking; they do not validate response values. Review the type against your API contract and use runtime validation separately when needed.

How are arrays of objects combined?

Observed object keys are merged. A property missing from some objects is marked optional, and differing value types form unions. Arrays containing primitives and objects form a union element type.

What do empty arrays and objects become?

An empty array becomes Array<unknown>, or ReadonlyArray<unknown>. An object-only empty sample becomes Record<string, unknown>. These samples cannot establish more specific types.

Are duplicate keys or large integers accepted?

Duplicate keys are rejected as ambiguous. JSON numbers are parsed without rounding in the syntax tree but inferred as TypeScript number, which does not guarantee runtime large-integer precision.

What limits apply?

Use up to 200,000 characters, 5,000 JSON values and 32 nested containers. UTF-8 file imports are limited to 256 KiB. Generated code is capped at 200,000 characters and is not saved automatically.

Help improve this tool

Report a problem or suggest an improvement

Describe the issue without pasting private tool input. Feedback goes to our admin inbox.

Find another tool · Read practical guides