Instalar o ZYBERMART

Abra qualquer ferramenta pela tela inicial ou pelo Dock, em uma janela própria. As ferramentas que você já usou também funcionam offline.

JSON para TypeScript

Transforme um exemplo de JSON, como a resposta de uma API, em interfaces ou types TypeScript, com tipos aninhados e campos opcionais.

How to turn JSON into TypeScript

  1. Paste a sample of the JSON, such as an API response.
  2. Name the main type, and choose interface or type.
  3. Copy the result into your project. It updates as you type.

Need to check the JSON first? Use the JSON formatter.

Frequently asked questions

How are the types worked out?

From your sample JSON: strings, numbers and booleans become string, number and boolean; nested objects get their own interface named after their key; arrays become lists of the types inside them. If objects in an array don't all have a key, it becomes optional (key?).

What happens with null?

A key that's null in the sample becomes the type null (or, combined with other values in an array, for example string | null). Paste a sample with real values where you can, for more useful types.

Interface or type?

Both describe the same shapes. Interfaces can be extended and merged, and are the usual choice for object shapes; types can also describe unions. Pick what your codebase uses.

Is my JSON uploaded?

No. The types are made in your browser.

Entrar no ZYBERMART

Tenha seus currículos, faturas, flashcards, notas e ferramentas salvas em todos os seus dispositivos. É grátis, e as ferramentas funcionam igual sem conta.

ou

Não precisa de senha. Ao entrar, você concorda com os termos; veja como tratamos seus dados na política de privacidade.

Sua conta

Ao sair, uma cópia do seu trabalho fica neste navegador. Em um computador compartilhado, limpe os dados do navegador depois.

O que você quer criar?

Designs

Redes sociais

Documentos

Estudos

Editar

Ver todas as 282 ferramentas