ToolCabana

JSON para TypeScript

Infere um tipo TypeScript a partir de um exemplo JSON.

Favorites are saved in this browser. Find them in My favorites.

JSON para TypeScript

Instant results · processed in your browser
Update results automatically as you type or change settings. Turn off to run manually.Clear your input, files and result, and restore the default settings.
Load sample text to explore what this tool can do. This replaces your current input.
0 charactersClear the source text.

Type or paste to update the result automatically.

Your result appears here

Type, paste, or use an example. Copy your result when it is ready.

Como usar JSON para TypeScript

JSON to TypeScript infers a TypeScript type from a JSON example and outputs it as a single exported type alias with a name you choose. Nested objects become inline object types, arrays become Array types with a union of element types, and empty arrays become unknown[]. Optional fields cannot be detected from a single example.

  1. Digite ou cole sua fonte, ou carregue um exemplo.
  2. Altere as configurações básicas ou abra o modo avançado para refinar o resultado.
  3. Revise e copie ou baixe seu resultado. Pause os resultados ao vivo para executar manualmente. Fontes ou configurações individuais acima de 20,000 caracteres exigem uma execução explícita.

O que esta ferramenta suporta

Infere um tipo TypeScript a partir de um exemplo JSON.

Nome do tipo raiz
Set this value for your task.

Limites e processamento

As operações de texto aceitam geralmente até 2,000,000 caracteres. Analisadores, geradores e fórmulas individuais aplicam limites adicionais mostrados pelos seus controles.

Fonte de exemplo
{"name":"ToolCabana","count":2}

Perguntas frequentes

How do I generate a TypeScript type from JSON?

Paste a JSON example, set the Root type name, and run the tool. The result is an export type declaration describing every property and nested value in the example.

Does JSON to TypeScript detect optional properties?

No. The type is inferred from the single example given, so every key present is required and keys that are absent cannot be inferred. Edit the type to add optional markers.

How are arrays with mixed values typed?

The element types are combined into a union, so an array holding strings and numbers becomes an Array type of string | number. An empty array becomes unknown[].

Onde minha entrada é processada?

Esta operação processa sua fonte no seu navegador. Copiar e baixar são ações explícitas; a entrada de origem não é salva em conta nem em histórico.

Quais são os limites de entrada?

As operações de texto aceitam geralmente até 2,000,000 caracteres. Analisadores, geradores e fórmulas individuais aplicam limites adicionais mostrados pelos seus controles.