So nutzt du: JSON Schema to TypeScript
- Paste your JSON Schema — or an OpenAPI
components.schemasobject — on the left. - Set the root type name and whether to use
interfaceortype. - The TypeScript types update as you type; definitions under
$defsordefinitionsbecome their own named types. - Copy the code into a
.tsor.d.tsfile.
How JSON Schema maps to TypeScript
| JSON Schema | TypeScript |
|---|---|
"type": "string" / number, integer / boolean / null | string / number / boolean / null |
properties + required | interface with prop and optional prop? |
enum, const | literal union: "draft" | "published" |
items, prefixItems | T[], tuples [A, B] |
additionalProperties (schema) | index signature [key: string]: T |
oneOf / anyOf / allOf | A | 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.
Auch gesucht als: 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.
Passende Tools zu: 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 zu Typen — Füge eine API-Antwort ein und erhalte gebrauchsfertige Modelle in 8 Sprachen: TypeScript, Python (dataclass, TypedDict oder Pydantic), Go, Java, C#, Kotlin, Swift und Rust.
- JSON Formatierer — Füge JSON ein, um es zu formatieren, zu minifizieren oder zu prüfen.
- 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.