TS

JSON to TypeScript

Generate TypeScript interfaces from a JSON sample, with nested types.

json-to-ts.tool
Root name
0 chars
Generated interfaces will appear here
Nothing you paste here is ever sent to a server - generation happens locally in your browser.
Overview

What is a json to typescript?

This tool generates TypeScript interfaces directly from a JSON sample - no more hand-writing types after copying an API response. Nested objects become their own named interfaces, arrays of objects are detected and typed automatically, and fields missing from some array items are marked optional.

Quick start

How to use this tool

  1. 1Paste a representative JSON sample, or upload a .json file.
  2. 2Set a root interface name (defaults to RootObject).
  3. 3Click Generate - nested objects and array item shapes each get their own interface.
  4. 4Copy the result or download it as a .ts file to drop straight into your project.
Where it helps

Common use cases

Typing an API response you don't control without writing interfaces by hand
Quickly scaffolding types while prototyping a new feature
Documenting the shape of a config file as TypeScript types
Sanity-checking that a JSON sample matches the shape you expect
Good to know

Frequently asked questions

How are nested objects named?

Each nested object is named after its key, converted to PascalCase (e.g. a "dimensions" field becomes an interface called Dimensions). Naming collisions are automatically resolved by appending a number.

How does it handle arrays of objects with different fields?

It merges the fields seen across every item in the array. Any field that isn't present on every item is marked optional with a `?`, rather than guessing incorrectly.

What about arrays of mixed types?

An array containing, say, numbers and strings becomes a union array type like `(number | string)[]`, which accurately reflects what's actually in the data.

Does this replace a tool like quicktype?

It covers the most common case - one JSON sample to one set of interfaces - entirely client-side. For more advanced inference across multiple samples or other target languages, a dedicated tool like quicktype may go further.

quick_facts.json

{

"runs_in_browser": true,

"data_sent_to_server": false,

"signup_required": false,

"price": "free",

"category": "JSON Tools"

}

Related tools

{ }
No signup
JSON Formatter

Format, validate, and minify JSON with syntax highlighting.

Open tool
{ }
No signup
JSON Beautifier

Beautify messy or minified JSON with proper indentation and syntax highlighting.

Open tool
No signup
JSON Validator

Validate JSON against strict syntax rules with line-level errors.

Open tool