Skip to main content

JSON to TypeScript Generator

Developer

Skip hand-typing repetitive API response interfaces. Paste any JSON object or array payload to recursively infer clean `export interface` or `export type` definitions locally—detecting optional `?` fields across non-uniform array objects automatically.

Loading tool…

How to use

4 steps
  1. 01

    Paste raw JSON from an API response or fixture into the left editor.

  2. 02

    Set a PascalCase root type name and toggle `type` vs `interface` or optional fields.

  3. 03

    Inspect nested interfaces and union array types generated live on the right.

  4. 04

    Click Copy code to drop straight into your TypeScript project.

Technical Notes & Guide

2

Merging Heterogeneous Object Arrays Cleanly

When array items omit certain keys in some records (`discount` present in item 1, absent in item 2), naive converters drop keys or fail. This tool scans every item and marks partial keys optional (`?:`) cleanly.

Refining Inferred Null Fields

Static JSON with `'discount': null` only shows `null` at runtime; replace `: null` with `: number | null` per your backend schema.

FAQ

2 questions
Q1Are hyphenated JSON keys quoted properly?

Yes—non-identifier keys such as `content-type` are automatically quoted as valid TypeScript property keys.

Q2Does pasting internal API JSON leave my device?

No. Parsing and type inference run purely in local JavaScript.

Developer