Code Generator Tools

JSON to TypeScript, Go, PHP, Java & C#

Paste a sample API response or config file and get typed models: TypeScript interfaces, Go structs with JSON tags, PHP 8.2 readonly classes, Java records or C# classes. Optional keys, null values and nested objects are detected for you.

Private by design: anything you enter is processed in your browser only. It is never uploaded to or logged on our servers. Share links contain the JSON and the options.

About generating types from JSON

Writing model classes for an API response by hand is slow and error-prone. This generator reads a sample and infers a type for every key: strings, integers (64-bit when a value does not fit in 32 bits), floats, booleans, arrays and nested objects. Each nested object becomes its own named type, named after its key; array keys are singularised, so orders becomes Order.

When the sample is an array of objects, all elements are merged: a key missing from some elements is marked optional, a key that is sometimes null is marked nullable, and an integer that is sometimes a decimal becomes a float. Paste several representative records to get the most accurate types. Keys that are not valid identifiers are renamed (first-name becomes FirstName or firstName) and mapped back with Go struct tags, Jackson @JsonProperty or [JsonPropertyName].

To validate JSON against a contract instead, generate a schema with the JSON Schema validator. Everything runs in your browser; your JSON is not uploaded.

Reference Guide

How each JSON value is mapped:

JSONTypeScriptGoPHP 8.2Java 17C#
stringstringstringstringStringstring
integernumberint / int64intint / longint / long
decimalnumberfloat64floatdoubledouble
booleanbooleanboolboolbooleanbool
arrayT[][]Tarray + @param list<T>List<T>List<T>
optional keykey?: T*T + omitempty?T $x = nullboxed type (Integer)T?
null / unknownT | null / unknown*T / any?T / mixedboxed / ObjectT? / object

A value written as 10.0 is typed as a float in browsers that expose the number's source text to JSON.parse (Chrome and Edge 114+, Firefox 135+); in other browsers it is read as the integer 10.

Frequently Asked Questions

Paste an array with several records. A key that is missing from some of them becomes optional (key?: in TypeScript, a pointer with omitempty in Go, a nullable parameter with a default in PHP), and a key that is sometimes null becomes nullable. A single object cannot show which keys are optional.

They are renamed to valid names in the target language (FirstName, firstName or _2fa) and mapped back to the original JSON key with a Go struct tag, a Jackson @JsonProperty or a [JsonPropertyName] attribute. TypeScript keeps the original key in quotes.

Go structs use the standard encoding/json tags, Java records use Jackson annotations (Jackson 2.12+ supports records), C# classes use System.Text.Json attributes, and PHP 8.2 readonly classes use constructor promotion so you can create them from decoded arrays or with a mapper such as Symfony Serializer.

No. Types are inferred and generated entirely in your browser.