Skip to main content
Language / 语言

JSON to TypeScript – Generate Types & Interfaces Online

100% Client-Side

Convert JSON to TypeScript interfaces and types instantly. Generate accurate TypeScript definitions from any JSON data—nested objects, arrays, optional fields, and union types. Free, private, browser-based converter.

Home/JSON to TypeScript – Generate Types & Interfaces Online

How to Convert JSON to TypeScript

  1. Paste your JSON data or upload a .json file in the left editor.
  2. Configure options: root interface name, interface vs type, export, and optional fields.
  3. The TypeScript output updates instantly in the right panel.
  4. Click Copy TypeScript or Download .ts to use in your project.
JSON INPUT0 chars
TYPESCRIPT OUTPUT0 interfaces

Key Capabilities

Generates TypeScript interfaces or type aliases from any valid JSON
Handles deeply nested objects, arrays of objects with merged fields
Configurable: export keyword, optional fields, interface vs type alias
Automatic PascalCase naming and smart array item singularization
One-click copy or download generated .ts definition files

Frequently Asked Questions

How do I convert JSON to TypeScript?

Paste your JSON into the input editor and the tool will instantly generate TypeScript interfaces with correct types for strings, numbers, booleans, arrays, nested objects, and null values. You can copy or download the result as a .ts file.

What is the difference between TypeScript interface and type?

An interface defines the shape of an object and can be extended or merged. A type alias is more flexible—it can represent unions, intersections, primitives, and mapped types. For JSON object shapes, both work equally well. Use the toggle to choose your preferred style.

Does this tool handle nested JSON objects?

Yes. Every nested object in your JSON automatically generates a separate named TypeScript interface. The naming uses PascalCase derived from the parent key name, producing clean readable type definitions.

How are JSON arrays converted to TypeScript?

Primitive arrays become typed arrays (e.g., string[]). Arrays of objects are merged into a single interface with fields marked as optional if they don't appear in every item. Mixed-type arrays produce union types like (string | number)[].

Can I generate optional fields in TypeScript from JSON?

Yes. Enable the 'Optional Fields' toggle and every property will include the ? modifier. This is useful when your JSON represents partial data or API responses where fields may be missing.

Is my JSON data safe when using this converter?

Absolutely. All conversion happens 100% in your browser using client-side JavaScript. Your JSON data never leaves your machine—no server requests, no data storage, no tracking of input content.

What JSON structures are supported?

The converter handles all valid JSON: objects, arrays, nested structures, null values, booleans, numbers (integer and float), and strings. It also supports arrays of mixed types, empty arrays, and deeply nested hierarchies.

Can I use the generated TypeScript in my project?

Yes. The generated code is production-ready TypeScript. Click 'Copy TypeScript' or 'Download .ts' to get the definitions, then paste them into your project's type definition files.