Skip to main content
Convert2JSON Tools

Code Generators

Paste a real API response and get models that compile. Structure is analysed recursively, identical nested shapes are reused, and keywords are escaped so the output is valid rather than nearly valid.

Turn a JSON sample into typed models for thirteen languages, with the annotations and naming conventions each ecosystem expects.

How the generators infer types

Each generator walks your sample recursively and builds a type for every distinct object shape it encounters. Two nested objects with the same set of keys collapse onto one reusable type rather than producing near-duplicate definitions, which is what keeps the output readable when a response repeats a structure at several levels.

Scalars are mapped to each language’s natural equivalent: integers and floating-point numbers are distinguished, booleans and strings map directly, and null becomes the language’s optional or nullable form. Arrays take the type of their elements, and a mixed array widens to whatever type accepts all of them.

Output that actually compiles

Real JSON keys are not always legal identifiers. A key may start with a digit, contain a hyphen or a space, collide with a reserved word, or use non-ASCII characters. Every generator rewrites those into valid identifiers and, where the language supports it, adds the annotation that maps the field back to the original key — Go struct tags, Java and C# attributes, Swift CodingKeys — so serialisation still round-trips.

That is the difference between output you can paste and output you have to repair. A generator that emits a field called `class` or `2fa_enabled` produces code that does not build; these escape it and record the original name.

Use a representative sample

A generated model can only describe the example you provide. If a field happened to be null or absent in your sample, the inferred type reflects that rather than the field’s real domain. Paste a response that exercises the variations you care about — populated optional fields, arrays with more than one element — and then tighten the result by hand where the API contract says more than the sample could.