Developer tools · Free · 2 min

JSON to TypeScript Type Generator

Paste a JSON value or a top-level array of example objects and generate a TypeScript interface or type alias. Across object samples, properties missing from some examples become optional; nested objects, arrays, null values, and mixed JSON types are represented with readable unions.

JSON to TypeScriptTypeScript generatorAPI responseoptional propertiesJSON

Generate TypeScript from JSON samples

Paste a JSON value or an array of example objects. Generation runs locally in this browser; inputs are not uploaded.

Up to 100 KB. Use a top-level array of objects to infer optional fields across multiple examples.

Example data is illustrative. Paste your own sample and generate a type.

This infers a type from sample values; it does not validate future API responses, generate a JSON Schema, or guarantee that unseen values match. Review the output before using it.

What this tool helps with

Manually translating example API responses into TypeScript takes time, and optional fields are easy to overlook when a response has several shapes.

How to use it

  1. Paste a JSON object, array, or collection of example objects.
  2. Choose whether a top-level array is one collection of samples or an array value; enter a valid root type name.
  3. Generate, review, copy, or download the TypeScript definition.

Requirements

Valid JSON and a modern browser with JavaScript enabled. Inputs remain in the current browser tab; no account or API is used.

Limits and privacy

This is sample-based inference, not a JSON Schema generator, runtime validator, or proof that future responses match. It does not distinguish integer from decimal values, and empty arrays infer unknown[]. The input limit is 100 KB. Review generated code against the API contract. Inputs are processed locally in this browser. The site does not provide an upload endpoint for this tool.

Frequently asked questions

Are my JSON samples uploaded?

No. Parsing and generation run locally in this browser tab.

How are optional properties inferred?

When a top-level array of objects is treated as multiple samples, a property is marked optional if it is missing from at least one object. Nested objects use the same rule.

Does this verify the API response?

No. It only infers a static type from the samples you provide. Add runtime validation separately if untrusted data must be checked.

Step-by-step guide

Generate TypeScript types from multiple JSON samples →

Related tools

JSON Formatter & Validator · Markdown Previewer