⚡
usefultools.dev
TS

JSON to TypeScript Interface Converter

NOVO

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

Funciona 100% no seu navegador — o que você insere nunca é enviado nem armazenado nos nossos servidores.

Esta ferramenta ainda não está totalmente traduzida, por isso parte do texto continua em inglês. A ferramenta funciona da mesma forma em todos os idiomas.

⚡

Exemplos rápidos

Entradas típicas e os resultados que esta ferramenta gera.

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;
📖

Visão geral

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.

Por que usar esta ferramenta?

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

Recursos

🧩

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.

🛠️

Como usar

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.

🤔

Perguntas frequentes