BRev Free Tools
At BRev Digital, essentials should be a right — free, forever.
Open in workspacekeep several tools open at once
All tools
JSON to types

JSON to Python dataclass

json.loads gives you dicts all the way down — no attribute access, no editor completion, no type checking. Paste a payload here and get @dataclass models with full type annotations plus from_dict helpers that recursively construct real nested objects, so response["items"][0]["sku"] becomes response.items[0].sku.

A key that is present but null is typed Optional[str]; a key that is missing from some samples is handled separately — add two or three real responses as samples and the generated models reflect what the API actually does, not what one lucky response happened to contain.

ISO 8601 timestamps can be typed as datetime (with parsing in the helpers) instead of str — a toggle, since some pipelines want the raw string untouched.

Inputpaste JSON samples or a schema — multiple samples merge into one type
Loading the type generator…
Generated typesregenerates as you type
Loading the type generator…

How JSON type inference works

The generator reads your JSON and builds the strictest type that fits every value it saw: objects become interfaces, structs or classes; arrays become typed lists; a value that appears as both a number and a string becomes a union. Repeated string values (like "active" / "inactive") can be promoted to an enum, and ISO 8601 timestamps or UUIDs can map to your language's date and UUID types — both are toggles above.

Why add multiple samples?

One API response rarely shows every field — optional fields are missing, nullable fields happen to be set. Add two or three real responses with Add sample and they merge into a single type: a field present in every sample stays required, and a field that only some samples carry becomes optional. More samples always produce a more honest type.

Nullable is not optional

A field that appears as null in a sample is nullable — it is always present, but its value may be null (string | null). A field that is missing from some samples is optional — it may not exist at all (field?: string). Serializers treat the two very differently, which is why the generator keeps them distinct instead of collapsing both to "maybe".

JSON Schema in, types out

Already have a JSON Schema? Switch the input to JSON Schema and the types are derived from the schema's declared properties, required list and formats instead of being inferred from samples — or pick the JSON Schema output target to go the other way and generate a schema from samples.

Generated on your device with the quicktype engine — nothing is uploaded.

FAQ

Does my JSON leave the browser?

No. Everything is generated on your device — paste internal API responses freely; no server ever sees them.

Why from_dict helpers instead of plain dataclasses?

A dataclass alone will not build itself from a nested dict — DataClass(**data) breaks the moment a field is itself an object or a list of objects. The generated helpers convert each level, so one call turns the whole json.loads result into typed objects.

How are optional fields detected?

By merging samples: a field present in every pasted sample stays required, one missing from any sample is treated as optional. One sample cannot reveal optionality, so paste a couple of real responses.

Will mypy accept the output?

The models are standard typing-annotated dataclasses, so they type-check like hand-written code. Enum inference turns repeated string values into real Enum classes rather than loose strings.