Paste JSON to begin.

What this tool does

JSON to TypeScript reads a sample payload and builds matching TypeScript definitions for objects, arrays, booleans, numbers, strings, and nested structures.

Common use cases

  • Creating front-end models from API responses.
  • Generating mock types for tests and Storybook fixtures.
  • Documenting the expected shape of third-party payloads.
  • Starting TypeScript migrations from existing JSON samples.

Before and after example

TypeScript output

export type Root = {
  id: number;
  email: string;
  tags: string[];
};

Common JSON errors related to conversion

  • Invalid JSON blocks generation completely.
  • Mixed arrays can produce broader union types than expected.
  • null values will be represented in the generated types.
  • Unquoted keys or trailing commas must be fixed before conversion.

How to use the tool

  1. Paste valid JSON into the left panel.
  2. Pick whether you want TypeScript types or interfaces.
  3. Click Generate TypeScript.
  4. Copy the output or download it as a .ts file.
Privacy note: Runs locally in your browser. Your JSON is not uploaded.

Related JSON tools

FAQ

Should I use interfaces or type aliases?

Either works. Interfaces are familiar for object models, while type aliases are convenient for unions and quick generated output.

Can I generate types from an array of objects?

Yes. Arrays are detected and converted into array types, including unions if the array contains mixed value shapes.

Does the generator infer optional properties?

It reflects the sample you provide. If a property is missing from the sample, it cannot infer that optional shape automatically.

Can I upload a local JSON file?

Yes. Upload a file, generate TypeScript in the browser, then copy or download the output.