JSON / JSON Schema to TypeScript & Pydantic v2 Generator
Convert raw API JSON payloads or Draft-07/2020-12 JSON Schema objects directly into TypeScript interfaces and Python Pydantic v2 BaseModel classes offline.
Input & Options
Local JS Execution
Parsed Output & Diagnostics
Ready
Status
...
Generated Output
Type Mapping Reference
| JSON Type | TypeScript | Python Pydantic v2 |
|---|---|---|
| string | string | str |
| integer / number | number | int / float |
| boolean | boolean | bool |
| array of T | T[] | list[T] |
| null / optional | T | null | T | None = None |
Parser Methodology & Privacy Guarantees
Walks parsed JSON ASTs or JSON Schema property maps recursively, extracts nested child objects into deduplicated PascalCase types, distinguishes integers vs floats for Python typing, and respects `required` schema arrays.
- Detects JSON Schema objects via `$schema` or `type: 'object' + properties`.
- Generates nested interfaces/BaseModels bottom-up so Python forward references aren't needed.
- Sanitizes Python reserved keywords or hyphenated keys using `Field(alias=...)`.
Scope & limitations: Complex polymorphic `oneOf` / `$ref` external schema files should be bundled into a single JSON file before pasting.
Frequently Asked Questions
Does it use modern Python 3.10+ / Pydantic v2 syntax?
Yes. Generated Python models use BaseModel with built-in list[...] and X | None = None union syntax cleanly compatible with Python 3.10-3.13.
How are hyphenated keys handled in Python models?
Keys containing hyphens or spaces (like content-type) are converted to snake_case Python attributes with Field(alias='content-type').
Can I download generated types directly?
Yes, click Download File in the code output header to save .ts or .py definitions directly from your browser.