Skip to main content
HandyWeb

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.

Language
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

  1. Paste a JSON sample.
  2. Choose the language and the root type name.
  3. 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.

Source code of this tool (opens in a new tab)Report a problem on GitHub (opens in a new tab)