JSON to Code
Paste JSON and get TypeScript interfaces, Go structs with json tags, or Python TypedDict classes right away. Free, and your data never leaves the browser.
0 characters0 bytes
0 characters0 bytes
The types come from this one sample only. A field that some objects of an array do not have is optional.
How to Use It
- Paste a JSON sample.
- Choose the language and the root type name.
- Copy the code, and edit it if necessary.
Questions and Answers
How does the tool find optional fields?
In an array of objects, a field that some objects do not have is optional: ? in TypeScript, omitempty in Go, and NotRequired in Python.
Is my JSON sent anywhere?
No. The types are made in your browser.
Good to Know
The tool sees this sample only. A field that is null in the sample gets the null type, and an empty array gets an unknown item type. The Python code needs Python 3.11 or later.
Related Tools
- JSON Formatter and ValidatorPretty-print or minify JSON, or find its errors with the line and column.
- JSON Schema ValidatorCheck JSON data against a JSON Schema (drafts 4, 7, 2019-09, and 2020-12) and see each error with its path in the data.
- JSON and YAML ConverterConvert JSON to YAML or YAML to JSON. Several YAML documents become one JSON array.
Source code of this tool (opens in a new tab)Report a problem on GitHub (opens in a new tab)