Skip to main content
{/}codefunc

JSON to TypeScript

Generate TypeScript types and interfaces from JSON objects.

About this tool

Infer interfaces and type aliases from sample JSON — a practical starting point when integrating a new API or typing a config file. Paste a representative response and refine the output in your editor.

Generated types reflect the sample you provide: optional fields, unions, and nested objects come from the data shape. Review before committing.

Sample JSON is processed on your device only.

How to use

  1. Paste a representative JSON sample (object or array) into Input.
  2. Click Convert to generate an `export type Root = …` definition.
  3. Copy the type into your project and rename `Root` to match your domain.
  4. Re-run with a fuller sample if optional fields were missing from the first payload.

Example

Infer a type from a user profile payload

Input

{
  "id": 42,
  "email": "dev@example.com",
  "tags": ["ops", "beta"]
}

Output

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

Types are inferred from the values present — empty arrays become unknown[].

Limitations

  • Inference is structural, not semantic: enums, unions, and branded types are not discovered.
  • A single sample cannot express optional keys; missing fields will be absent from the type.
  • Output is a starting point — refine for nullability and shared interfaces before shipping.

Related tools

3

Frequently asked questions

How does JSON to TypeScript infer types?

It walks the JSON structure and generates interfaces with property types inferred from values — strings, numbers, booleans, arrays, and nested objects.

When should I use JSON to TypeScript?

When bootstrapping types for a new API integration, config file, or webhook payload. Review and refine the output before committing to your codebase.

Is JSON to TypeScript free?

Yes. No account required.

Is my JSON uploaded?

No. Conversion runs entirely in your browser.

Can I validate JSON before converting?

Yes. Use the JSON Validator or JSON Formatter first if your payload has syntax errors.

Search tools

Find a developer tool