JSON to Pydantic, TypeScript & Dataclass Converter
Paste a JSON response and get typed models you can drop into your code. Nested objects become their own classes, and fields missing from some array items become optional.
AI DevRuns in your browser — nothing uploaded
How it works
- 1
Reads your sample
Every value is typed: strings, integers, floats, booleans, nulls, nested objects and arrays.
- 2
Merges array items
All objects in an array are combined into one model. A key missing from some items is marked optional.
- 3
Names the classes
Nested objects are named after their key — an “orders” array becomes an Order model. Identical shapes share one class.
- 4
Handles awkward keys
Keys like “pin-code” or “class” get a safe Python name, with a Pydantic alias so parsing still works.
Questions, answered
Pydantic v2 syntax with Python 3.10+ type hints (list[str], str | None). The models also work in Pydantic v1.10 on Python 3.10+.
From your sample only. If a key appears in some array items but not others, it becomes optional. Paste a bigger sample to catch more cases.
A field that is always null gets the type Any (or null in TypeScript), because there is nothing to infer from. A field that is sometimes null becomes nullable.
No. Conversion happens entirely in your browser, so it’s safe for API responses that contain private data.
Yes. A top-level array is treated as a list of records, and the model describes one item.
Popular uses
Related tools
- Prompt CompressorCut tokens from prompts and code before you send them to an LLM.AI Dev
- Regex ExplainerPaste a regex, get plain English plus test cases.AI Dev
- AI SQL Query GeneratorEnglish to SQL for Postgres, MySQL and MSSQL.AI Dev
- JSON to TOON ConverterShrink JSON for LLM prompts with TOON — and convert back.AI Dev