JSON to TypeScript Converter

Generate TypeScript interfaces or types from JSON, including nested objects, arrays, optional and null fields.

Runs in your browser Free
Processed locally in your browser.

Types are inferred from the sample. Fields missing in some array items become optional; null values become nullable.

Type safety for API responses

Using API data as 'any' in TypeScript projects invites bugs. The JSON to TypeScript converter produces accurate, complete type definitions from a sample JSON response in seconds.

Features

  • interface or type output
  • Separate, named types for nested objects
  • Array items merged into one precise type
  • Optional (?) markers for fields missing in some items and union types for nulls
  • Keys that aren't valid identifiers are quoted

Use

Add the generated types to your React, Angular, Vue or Node.js project for autocompletion and compile-time checks. Your JSON is processed in your browser.

How to use JSON to TypeScript Converter

  1. Paste sample JSON data.
  2. Choose interface or type and the root name.
  3. Review the generated TypeScript code.
  4. Copy it into your project.

Why use this tool?

No more writing type definitions by hand, and API changes become easier to track.

FAQ

Should I choose interface or type?

Both describe object shapes. Interfaces support declaration merging and are common for public APIs; types are handy for unions.

What if my sample JSON is missing fields?

Types are inferred only from values in the sample. Use the most complete sample response you can, especially for empty arrays.

Does it generate Zod schemas?

No, it generates TypeScript types only.

Related tools