JWT Decoder
Decode a JWT and read its header, claims and expiry in plain English.
Generate Python dataclasses with type hints from a sample JSON document.
Keys are converted to snake_case for PEP 8, fields with defaults are ordered last so the dataclass compiles, and the typing imports at the top match exactly what the hints below use.
The JSON to Python Dataclass converter generates dataclasses with full type hints, snake_case field names, Optional wrappers with None defaults, and exactly the typing imports the output uses.
Paste a JSON sample and get dataclasses for it: one per nested object, with type hints on every field, List[...] for arrays and Optional[...] with a None default for anything that is not always present.
The details that make generated Python actually run are handled. Field names are converted to snake_case, the typing imports at the top list exactly what the output uses, and fields with defaults are ordered after those without — the rule a dataclass refuses to compile if you break. Nested classes are declared before the classes that reference them, so the module executes top to bottom without forward references.
Fields with defaults are ordered after those without, which is the rule a dataclass raises a TypeError over if you break it.
Keys are converted to snake_case, so the generated code reads like Python rather than like the JSON it came from.
The typing line at the top lists only what the hints below actually use — no unused imports for a linter to flag.
Nested classes are declared before the classes that reference them, so the module executes top to bottom with no forward references.
A key that is missing from some records becomes Optional[...] with a None default rather than being asserted as required.
An array of records gives the best optional-field detection.
Nested classes take their names from the keys that hold them.
The typing imports at the top match exactly what the generated hints use.
Paste into a .py file and start using the classes.
No, they are plain type definitions. Construct them with **data for flat shapes, or use a library such as pydantic or dacite when the nesting is deep.
Because a dataclass raises a TypeError at import time if a field without a default follows one with a default. Reordering is the only way the output compiles.
Yes, to snake_case, since that is PEP 8. If your JSON keys are camelCase you will need an alias when parsing — pydantic calls it an alias, dacite calls it a key mapping.
Dataclasses when you only need structure and type hints; pydantic when you also want the values validated and coerced at runtime. The field declarations look almost identical either way.
What people who use the JSON to Python Dataclass think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the JSON to Python Dataclass. It takes half a minute and no account.
Write the first reviewDecode a JWT and read its header, claims and expiry in plain English.
Generate cryptographically random strings over any alphabet you choose.
Generate cryptographically random version 4 UUIDs in bulk.
Build and sign a JWT with HS256, HS384 or HS512 for testing.
Tidy a TOML file: consistent quoting, ordered tables, keys before headers.
Paste raw HTTP headers and get them parsed, explained and checked.
Convert between JSON arrays and NDJSON, one compact document per line.
The full ASCII table with decimal, hex, octal, binary and HTML entities.