An optional field
alert appears in one forecast item, so it becomes alert: str | None = None at the end of the class.
{"forecast": [{"day": "Mon"}, {"day": "Tue", "alert": "wind"}]}Paste a JSON sample. Python dataclasses are written beside it.
Dataclasses do not parse JSON on their own. Nested dictionaries stay dictionaries unless you convert them, for example with dacite or a from_dict method.
Ctrl+Enter or ⌘+Enter runs this tool immediately.
Waiting for input.
Parsing stays in this browser. Input is not uploaded or saved.
alert appears in one forecast item, so it becomes alert: str | None = None at the end of the class.
{"forecast": [{"day": "Mon"}, {"day": "Tue", "alert": "wind"}]}elevation-m is not a valid name, so the field is elevation_m. A notice reminds you to map it back.
{"elevation-m": 114}Generate TypeScript interfaces from a JSON sample in the browser. Array items are merged, and keys missing from some items become optional.
Generate a draft 2020-12 JSON Schema from a JSON sample in the browser. Types, nested objects, array items, and required keys are inferred.
Check JSON syntax in the browser. Errors give a line and column, and duplicate keys that JSON.parse would silently drop are reported.