JSON to Python Class

Convert JSON to Python dataclasses, Pydantic models or TypedDicts with type hints and Optional fields.

Runs in your browser. Your data never leaves your device.

How to use the JSON to Python Class

  1. Paste a sample JSON.
  2. Choose dataclass, Pydantic or TypedDict.
  3. Copy the Python code.

About this tool

Generate typed Python models from JSON: standard dataclasses, Pydantic models for FastAPI, or TypedDicts. Keys become snake_case attributes, nested objects become their own classes and missing values become Optional.

Frequently asked questions

Which style should I use?

Pydantic validates data at runtime and suits FastAPI. Dataclasses need no extra package. TypedDict only adds type hints to plain dicts.

More json tools

JSON and code models

All 31 free tools →
JSON tool · Runs in your browser

JSON Formatter

Format JSON online: beautify messy JSON with 2 or 4 spaces or tabs, sort keys, minify it to one line and find errors. Free, runs in your browser.

Free · No sign-upOpen tool
JSON tool · Runs in your browser

JSON Validator

Check if JSON is valid and see the exact line and column of any error, with a hint on how to fix it. A free online JSON validator in your browser.

Free · No sign-upOpen tool
JSON tool · Runs in your browser

JSON to Kotlin Data Class

Paste JSON and get Kotlin data classes for Android, with kotlinx.serialization, Gson or Moshi names, nullable fields and defaults. Free, in your browser.

Free · No sign-upOpen tool
JSON tool · Runs in your browser

JSON to Dart (Flutter)

Convert JSON to null-safe Dart model classes for Flutter, with fromJson, toJson and an optional copyWith. Free, no sign-up, runs in your browser.

Free · No sign-upOpen tool