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.
13 tools
13 tools
- JSON to TypeScriptGenerate TypeScript interfaces, types or classes from a JSON sample.JSONTypeScript
- JSON to JavaScriptGenerate JavaScript classes or JSDoc typedefs from JSON data.JSONJavaScript
- JSON to PythonGenerate dataclasses, TypedDicts or Pydantic models from JSON.JSONPython
- JSON to JavaGenerate Java POJOs or records with Jackson, Gson or Lombok annotations.JSONJava
- JSON to C#Generate C# classes or records with System.Text.Json or Newtonsoft attributes.JSONC#
- JSON to GoGenerate Go structs with json tags, omitempty and pointer options.JSONGo
- JSON to KotlinGenerate Kotlin data classes with kotlinx.serialization or Gson annotations.JSONKotlin
- JSON to SwiftGenerate Swift structs conforming to Codable, with CodingKeys where needed.JSONSwift
- JSON to RustGenerate Rust structs with serde derives and rename attributes.JSONRust
- JSON to PHPGenerate typed PHP classes with constructor promotion from JSON.JSONPHP
- JSON to DartGenerate Dart classes with fromJson and toJson methods for Flutter.JSONDart
- JSON to C++Generate C++ structs with std::optional and std::vector from JSON.JSONC++
- JSON to CGenerate C structs and typedefs from JSON, with array length fields.JSONC
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.