WebTool

JSON to TypeScript

Free online JSON to TypeScript converter: infer interfaces from JSON — nested types, union arrays, optional nulls.

Privacy: all processing happens locally in your browser. Your input never leaves your device.

What is JSON to TypeScript?

Hand-writing TypeScript types from an API response is tedious and error-prone. This tool infers types from a sample JSON and generates interfaces: nested objects become independently named interfaces, array elements get union types, and null fields are marked optional. Fields with the same name but different shapes are automatically numbered to avoid collisions. The result can be pasted straight into your project.

How to Use

  1. Paste a sample JSON from an API response
  2. TypeScript interfaces are generated automatically
  3. Rename the root type if needed, then copy

FAQ

What type is generated for null values?
A field whose value is null is typed null and marked optional (?), because a null in the sample often means the field can hold other types — fill it in from the API documentation.
What if array elements have inconsistent shapes?
The tool produces a union type for the array elements, e.g. (A | B)[]; an empty array becomes unknown[].
How are the interfaces named?
The root type defaults to Root; nested objects derive PascalCase names from their field names, and same-named but different-shaped structures get numeric suffixes.

Related Tools

Last updated 2026-09-04