Esta página ainda não foi traduzida para o português, por isso aparece em inglês.

JSON Schema to TypeScript Converter

Paste a JSON Schema (draft-07 or 2020-12) and get TypeScript interfaces — required and optional properties, enums as union types, oneOf/anyOf as unions, allOf as intersections, $ref definitions as named types and descriptions as JSDoc comments.

Atualizado em
Declare as

Seus dados nunca saem do seu computador. Todo o processamento acontece localmente no navegador.

Como usar: JSON Schema to TypeScript

  1. Paste your JSON Schema — or an OpenAPI components.schemas object — on the left.
  2. Set the root type name and whether to use interface or type.
  3. The TypeScript types update as you type; definitions under $defs or definitions become their own named types.
  4. Copy the code into a .ts or .d.ts file.

How JSON Schema maps to TypeScript

JSON SchemaTypeScript
"type": "string" / number, integer / boolean / nullstring / number / boolean / null
properties + requiredinterface with prop and optional prop?
enum, constliteral union: "draft" | "published"
items, prefixItemsT[], tuples [A, B]
additionalProperties (schema)index signature [key: string]: T
oneOf / anyOf / allOfA | B / A | B / A & B
$ref: "#/$defs/User"the named type User
"type": ["string", "null"]string | null

Validation-only keywords such as minLength, pattern or format have no TypeScript equivalent; they are added to the JSDoc comment when JSDoc is on. External $ref URLs are typed as unknown.

Starting from example data instead of a schema? Use JSON to TypeScript. To check data against a schema, use the JSON Schema Validator.

Também pesquisado como: json schema to ts, generate typescript from json schema, json schema interface, json-schema-to-typescript online, openapi schema to typescript, json schema types, json schema converter.

Ferramentas que combinam com: JSON Schema to TypeScript

  • JSON to JSON Schema — Paste one or more JSON examples and get a JSON Schema that describes them: nested objects, arrays of objects merged into one item schema, required fields (keys present in every example), detected formats like email, date-time, URI and UUID, optional enums, and draft 2020-12 or draft-07 output.
  • JSON para Tipos — Cole uma resposta da API e receba modelos prontos para uso em 8 linguagens: TypeScript, Python (dataclass, TypedDict ou Pydantic), Go, Java, C#, Kotlin, Swift e Rust.
  • Formatação JSON — Cole o JSON aqui para formatá-lo, compactá-lo ou validá-lo.
  • OpenAPI / Swagger Validator — Paste an API specification to check it against the official OpenAPI schema, catch broken references and inconsistent path parameters, and see every endpoint at a glance.

Perguntas frequentes

How do I convert JSON Schema to TypeScript?
Paste the schema on the left; TypeScript interfaces appear on the right. Definitions in $defs or definitions become named types that $ref points to.
Which JSON Schema versions are supported?
Draft-04 to draft-07 and 2019-09/2020-12 keywords: properties, required, enum, const, items, prefixItems, additionalProperties, oneOf, anyOf, allOf, $ref, $defs and definitions.
Can I use it for OpenAPI schemas?
Yes — paste a single schema, or the whole components.schemas object to get one type per schema. #/components/schemas/ references are resolved.
Is my schema uploaded?
No. Conversion runs entirely in your browser.
Posso instalar o JSON Schema to TypeScript como um aplicativo da web e usá-lo offline?
Sim. O JSON Schema to TypeScript é um aplicativo da web instalável (PWA) — instalado a partir do seu navegador, não baixado de uma loja de aplicativos. Clique em “Instalar aplicativo” na parte superior desta página no Chrome ou no Edge (Windows, macOS, Linux, ChromeOS) ou, no Android, use “Compartilhar” → “Adicionar à tela inicial” no iPhone e no iPad, ou “Arquivo” → “Adicionar ao Dock” no Safari 17+ em um Mac. Em seguida, ela se abre em uma janela própria com seu próprio ícone e, como é executada inteiramente no seu navegador, continua funcionando offline. O Firefox no desktop não permite a instalação de aplicativos da web. Como funciona a instalação.

Ferramentas relacionadas