JSON to TypeScript
Convert a JSON to TypeScript interfaces with automatically inferred types. Detects strings, numbers, booleans, arrays, nested objects and union types. Everything in your browser.
JSON inválido — verifique sintaxe.
Como funciona?
O conversor lê seu JSON e infere o tipo TypeScript correspondente para cada campo: string, number, boolean, null, arrays e objetos aninhados (cada um vira uma interface separada). Quando um array tem itens de tipos diferentes, é gerada uma união ((string | number)[]).
Útil para gerar tipos a partir de respostas de APIs reais, payloads de webhooks ou estruturas de dados que você acabou de receber. Tudo roda no seu navegador — nada é enviado a servidores.
Generate TypeScript interfaces from JSON
Typing an API response in TypeScript pays off. Writing those interfaces by hand from a big JSON, though, is tedious and easy to botch. Paste your JSON here and the matching interfaces come out automatically, with the types already inferred.
It recognises strings, numbers, booleans, arrays and nested objects, and when values vary it builds type unions too, so the result mirrors the shape of your data. Within seconds you've got code ready to drop into the project, which saves the manual grind and cuts down on typos.
Your JSON never leaves your device, because the whole conversion happens in the browser. Paste the data, copy the interfaces, and your code ends up with strong typing.
Frequently asked questions
Why did an array of objects produce two identical interfaces, Post and Post2?
One field came out typed as null. How do I fix that?
What does the root interface name field do when the JSON starts with a bracket?
Related Tools
JSONP to JSON Converter
Strips the callback wrapper of a JSONP response leaving only the JSON contained inside the parentheses.
MessagePack to JSON (text) Converter
Explains the MessagePack binary format, its advantages and how to translate it into textual JSON.
JSON to YAML
Convert JSON data to YAML format.
CBOR to JSON (text) Converter
Explains CBOR (RFC 8949), its types and how to represent compact binary values in textual JSON.
JSON to Python (dataclass)
Convert JSON to a Python dataclass with type hints. Supports List, Optional and nested classes. Everything in your browser.
YAML to JSON
Convert YAML data to JSON format.