JSON to TypeScript

Generate TypeScript interfaces or types from JSON, with optional/nullable accuracy

How to use

  1. Paste a JSON object or array of objects into the input pane.
  2. For best optional-field detection, paste an array with several shape variants.
  3. Toggle interface vs type alias output, and readonly modifiers if you want immutability.
  4. Copy the generated types into your project.

About this tool

Most JSON-to-TS tools convert one object at a time and mark everything required. This one merges all elements of an array into a single best-effort interface: fields present in every row are required, missing ones optional, null-ed ones nullable unions. Paste your real API samples — edge cases included — and the generated types will match reality.

Frequently asked questions

How does optional detection work?

When you paste an array, fields missing from at least one element are marked with ? — the union of all shapes is inferred from your real samples.

How are nulls represented?

Fields that were explicitly null in some rows become T | null. Fields that were merely absent become optional (T | undefined).

Are numbers split into int and float?

TypeScript has a single number type, so integers and floats both map to number. The distinction only matters for other output languages.

Is my data uploaded anywhere?

No. Conversion runs entirely in your browser.

Related tools