DM Tool Studio logoDM Tool Studio

JSON to Struct

Paste JSON and get TypeScript interfaces or Go structs. Nested objects become named types, a field missing in some rows becomes optional, and null becomes | null (TypeScript) or a pointer (Go). Everything runs in your browser; your text is never uploaded.

Drop a .json file here, or click to choose one

Paste JSON

Result

How to use

1. Paste JSON on the left (or drop a .json file above) — an object, an array of objects, or an object holding one array of objects. 2. Pick TypeScript or Go, set the root type name, then click Generate. 3. Copy the result or download it as a .ts / .go file.

FAQ

Is my JSON uploaded? No. Parsing and type inference all run in your browser with the built-in JSON parser; nothing passes through our server.
When is a field optional? When it is missing from at least one object in the sample. TypeScript marks it with ?, Go adds omitempty to its json tag. A field present in every object is required.
How is null handled? A field that is sometimes null becomes T | null in TypeScript and a pointer *T in Go. A field that is always null becomes any (TypeScript) or interface{} (Go) — the sample says nothing about its real type.
How are numbers typed? TypeScript uses number for all numbers. Go uses int when every observed value is an integer, and float64 as soon as one value has a fraction. A field mixing integers and strings becomes a union in TypeScript and interface{} in Go, with a comment listing the observed types.
What about empty arrays and objects? An empty array has no element to learn from, so it becomes unknown[] (TypeScript) or []interface{} (Go); an empty object becomes Record<string, unknown> or map[string]interface{}. Paste at least one non-empty example if you need a precise type.
Can I trust the output as-is? Types are inferred from the sample you paste, not from a schema. If your real data has a wider range — a field that is sometimes a string, a date that looks like a string — the generated type will be too narrow. Dates stay strings; nothing is guessed. Treat the output as a starting point and check the fields that matter.