CODDY Tool

JSON to Python

Turn a JSON sample into Python type definitions.

Paste a JSON response and get Python types back. Every element of an array is merged, so fields missing from some objects come out optional rather than required.

Everything you enter stays in this browser tab. Nothing is sent to our servers, logged or stored.

This is one of the thingsJSON Type Generatordoes — open it for everything else it supports.

Loading tool…

What JSON Type Generator supports

  • TypeScriptExported interfaces.
  • GoStructs with json tags.
  • KotlinData classes.
  • SwiftCodable structs.
  • PythonDataclasses.
  • C#Classes with properties.

About JSON to Python

Python dataclasses give you typed attributes, a constructor and a readable repr from a single decorator, which makes them a good target for a JSON shape.

There is one rule that turns a wrong type into a hard error: fields with defaults must come after fields without them, or the class is a syntax error. Optional fields are therefore emitted last, sorted for you.

Keys are converted to snake_case, and any key that would start with a digit is prefixed, because Python identifiers cannot.

How to generate Python types

  1. Paste your JSON

    A whole array is better than one object — more samples means a more accurate type.

  2. Name the root type

    Nested objects are named automatically from the keys that hold them.

  3. Copy the definitions

    Types are emitted children first, so the file compiles in order.

Frequently asked questions

Why is a field optional when my sample has it?

Because at least one object in the array you pasted was missing it. That is a real difference in the data, and a type that marks it required would compile and then fail at runtime on the object that lacks it.

Why did a field come out as unknown?

Because the same key held genuinely different types across your samples — a number in one object and a string in another. There is no single type that describes both, so widening to unknown is the honest answer.

Does it handle nested objects?

Yes. Each nested object becomes its own named interface, named after the key holding it, and a key holding an array is singularised — users produces a User rather than a Users.

Is my JSON uploaded anywhere?

No. Everything is parsed and generated in this browser tab, which matters when the sample is a response from an unreleased API.

All Developer Tools

JSON to Python is free to use with no account, no watermark and no usage limits. Last updated 14 August 2026.