⚡
usefultools.dev
TS

JSON to TypeScript Interface Converter

NEW

Convert JSON to TypeScript interfaces or types instantly: nested PascalCase interfaces, optional props from mixed arrays and null unions. Free, in-browser.

Runs 100% in your browser — your input is never uploaded or stored on our servers.

⚡

Quick Examples

Typical inputs and the results this tool produces.

Basic
{"id":1,"name":"Ana"}
id: number; name: string;
Array
{"tags":["a","b"]}
tags: string[];
Nested
{"user":{"name":"Ana"}}
user: User; + interface User
Merged
[{"a":1},{"a":2,"b":"x"}]
type Root = RootItem[]; b?: string
Null
{"manager":null}
manager: null;
📖

Overview

This JSON to TypeScript converter turns a sample API response or config file into ready-to-paste TypeScript interfaces. Nested objects get their own PascalCase interface named after the key, array item types are named in the singular (orders → Order), and identical shapes are reused instead of duplicated.

When an array holds objects with different keys, they are merged into one interface and keys missing from some items become optional. Values that are sometimes null become a "| null" union. You can switch between interface and type aliases, toggle export, mark every property optional, and set the root name.

Conversion happens locally in your browser, so private payloads stay on your machine.

Why use this tool?

  • Type an API response in seconds
  • Optional props inferred from real samples
  • Nested interfaces with clean names
  • No upload: JSON stays in your browser
⭐

Features

🧩

Nested interfaces

Each nested object becomes its own PascalCase interface.

❓

Optional detection

Keys missing from some array items are marked with ?.

∅

Null unions

Fields that are null in some samples become T | null.

🔀

Interface or type

Output interface declarations or type aliases, with or without export.

♻️

Shape reuse

Objects with the same shape share one interface.

⬇️

Copy or download

Copy the code or save it as types.ts.

🛠️

How to Use

1

Paste JSON

Paste a sample object or array into "JSON sample".

2

Set the root name

Type a name such as User or ApiResponse in "Root name".

3

Choose options

Pick interface or type, and toggle export and "All properties optional".

4

Copy the types

Click Copy or "Download .ts" and add the file to your project.

🤔

Frequently Asked Questions