JSON to Pydantic.
Paste sample JSON to get Pydantic v2 BaseModel classes. Runs entirely in your browser.
Pydantic
JSON → Pydantic
Idle
Loading editor…
Loading…
Frequently asked questions.
- Which Pydantic version is this for?
- The output works in Pydantic v2. Switch the optional syntax to `Optional[T]` if you need v1 compatibility.
- How are nested objects handled?
- A separate `class` is emitted per distinct object shape, named after the field that contains it. Cycles are not detected (single-sample inference).
- How does it tell int apart from float?
- If every observed value at a key is an integer, the type is `int`. Otherwise it falls back to `float`. Cast manually if you need stricter typing.
- Does my JSON leave my browser?
- No. Inference is plain TypeScript that runs locally. No network round-trip and no server.
More JSON tools.
- FormatPretty-print JSON with line-accurate errors. Sort keys on demand.
- ValidateCheck a JSON document against a JSON Schema. Per-path error messages.
- MinifyStrip whitespace and shrink your JSON payload. Reports bytes saved.
- Tree ViewBrowse JSON as a collapsible tree. Drill into nested data without scrolling.
- Semantic DiffCompare two JSON files by structure. Per-path adds, removes, modifications.
- JSONPath / JMESPathRun live JSONPath and JMESPath queries against your JSON.