Skip to content

Json To Python Class API

POST https://api.findutils.com/api/tools/json-to-python-class/execute

Generate Python class source code from a JSON object as a dataclass, a Pydantic model, or a plain class. Nested objects become separate classes, field names become snake_case, and type hints are optional.

Request body

application/json
  • json

    string required

    JSON object to convert (the root must be an object).

  • class_name

    string optional

    Name of the root class. Default: "Root". Default "Root".

  • class_type

    string optional

    Class style: "dataclass", "pydantic", or "plain". Default: "dataclass". One of dataclass · pydantic · plain. Default "dataclass".

  • add_type_hints

    boolean optional

    Add type hints (str, int, List[...], Optional[Any]). Default: true. Default true.

  • generate_init

    boolean optional

    For class_type "plain": generate an __init__ method. Default: true. Default true.

Example arguments

Verified
{
  "json": {
    "userId": 1,
    "firstName": "A",
    "tags": [
      "x"
    ]
  }
}