PasteZap
🌐 English
Free · No account

FREE · DEVELOPER TOOLS

JSON to Pydantic Model.

Turn a JSON sample into Pydantic v2 models with snake_case fields, aliases for the original keys, optional fields and nested classes.

Limits & supported formats

Types are inferred from the sample only. Everything is calculated in your browser; nothing you type is uploaded.

Loading the calculator…

How to use JSON to Pydantic Model

Paste a JSON object or an array of objects and name the root model. Copy or download models.py.

How it works

Fields missing from some array items or null in the sample become optional (X | None = None); integers and decimals merge to float; differing types become Any. Python keywords get a trailing underscore.

Example

A user with isActive, an address and a list of orders becomes User, Address and Order models; isActive becomes is_active with alias "isActive".

Questions about JSON to Pydantic Model

Is JSON to Pydantic Model free, and do I need an account?

Yes. This tool is free to use in your browser without an account. Processing takes place on your device.

What are the limits and what should I check?

Types are inferred from the sample only. Everything is calculated in your browser; nothing you type is uploaded. Review the result before using it in your work.

Is my input sent to a server?

Your input is processed in your browser and is not uploaded by this tool. Files and pasted text are cleared when the page is refreshed. Normal website requests are still required to load the page and its libraries. Read the privacy explanation.