SQL Minifier
Collapse a SQL query to one line and strip its comments.
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 reviewCollapse a SQL query to one line and strip its comments.
Turn text into a block-letter ASCII banner for a README or a CLI.
Score a selector and find out which of two rules actually wins.
Parse Set-Cookie and Cookie headers, and check the security flags.
Validate a JSON document against a draft-07 schema and see every failure by path.
Generate time-ordered UUID v7 identifiers that index cleanly.
Draw a clipping shape with draggable points and get the CSS.
Pretty-print XML with clean indentation, or collapse it back to one line.