CODDY Tool

JSON to TypeScript

Turn a JSON sample into TypeScript type definitions.

Paste a JSON response and get TypeScript types back. Every element of an array is merged, so fields missing from some objects come out optional rather than required.

Everything you enter stays in this browser tab. Nothing is sent to our servers, logged or stored.

This is one of the thingsJSON Type Generatordoes — open it for everything else it supports.

Loading tool…

What JSON Type Generator supports

  • TypeScriptExported interfaces.
  • GoStructs with json tags.
  • KotlinData classes.
  • SwiftCodable structs.
  • PythonDataclasses.
  • C#Classes with properties.

About JSON to TypeScript

TypeScript interfaces written by hand from an API response go stale quietly. The dangerous mistake is not a typo — it is marking a field required when the API sometimes omits it, because that compiles cleanly and fails only when the missing case shows up in production.

Pasting the whole array rather than one object is what prevents that. Every element is merged, so a key present in some objects and absent from others is emitted with a question mark, and a key that is null in one sample and a string in another comes out as string | null.

Keys that are not valid TypeScript identifiers — user-name, 2fa — are quoted rather than renamed, because TypeScript allows quoted property names and quoting keeps the type an exact description of the JSON.

How to generate TypeScript types

  1. Paste your JSON

    A whole array is better than one object — more samples means a more accurate type.

  2. Name the root type

    Nested objects are named automatically from the keys that hold them.

  3. Copy the definitions

    Types are emitted children first, so the file compiles in order.

Frequently asked questions

Why is a field optional when my sample has it?

Because at least one object in the array you pasted was missing it. That is a real difference in the data, and a type that marks it required would compile and then fail at runtime on the object that lacks it.

Why did a field come out as unknown?

Because the same key held genuinely different types across your samples — a number in one object and a string in another. There is no single type that describes both, so widening to unknown is the honest answer.

Does it handle nested objects?

Yes. Each nested object becomes its own named interface, named after the key holding it, and a key holding an array is singularised — users produces a User rather than a Users.

Is my JSON uploaded anywhere?

No. Everything is parsed and generated in this browser tab, which matters when the sample is a response from an unreleased API.

All Developer Tools

JSON to TypeScript is free to use with no account, no watermark and no usage limits. Last updated 14 August 2026.