convert

JSON to TypeScript

Generate TypeScript interfaces from a JSON sample, with nested types, arrays and optional fields inferred.

Runs on your deviceBatch readyPaste textNew

Paste or drop

Paste text below, or drop a file instead.

0 chars · 0 lines
…or drop a file
Drag and drop, or choose files
JSONTXT

Choose an output

Generate TypeScript interfaces from a JSON sample, with nested types, arrays and optional fields inferred.

Fine-tune

Optional — sensible defaults are already set.

About JSON to TypeScript

Paste a sample JSON payload and this tool generates TypeScript interfaces that describe it, with a named interface for every nested object. When an array contains several objects, their fields are merged, and a field missing from some of them is marked optional with ?.

When it helps

  • Typing a third-party API response quickly instead of writing interfaces by hand.
  • Creating types for a JSON config file or fixture used in tests.
  • Getting a starting point for a shared types file that a backend and frontend both use.

Tips

  • The types are only as complete as your sample. Paste a response that includes optional fields and several array items so the inference sees the full shape.
  • A field that is null in the sample becomes null, or a union such as string | null if other samples have a value. Review these by hand.
  • Nested interface names come from the key, and arrays use a singular form, so a key named users produces a User interface. Set the root type name to match your domain.
  • Empty arrays become unknown[] because there is nothing to infer from.

Good to know

Quick answers about json to typescript in your browser.

Within an array of objects, it counts how many objects contain each key. If a key appears in some but not all of them, the field is marked optional.

No. It outputs TypeScript interfaces and type aliases only, which disappear at compile time. You still need to validate untrusted data at runtime if correctness matters.

Yes. There is no sign-up, no watermark and no limit on how many files you process.

No. Files are read and processed locally in your browser, so they never leave your device.

Related tools