Generate starter data models from JSON examples in TypeScript, Python, Go, Rust, Java, Kotlin, C#, or Swift. Types, nested models, nullable fields, and collections are inferred from the current sample, then you can review, copy, or download the generated code.
Generate data-model code for TypeScript, Python, Go, Rust, Java, Kotlin, C#, or Swift. Output syntax, naming, nullability, and collection conventions differ per target.
Infer primitives, objects, arrays, nested structures, and nullable or mixed values from representative JSON samples. Union types are emitted where the target language supports them.
Nested objects and arrays of objects become separate named declarations referenced by their parent type. Generated names are inferred from JSON property names and may need manual refinement.
Set the root type name and configure the options shown for the selected target, such as export declarations, optional fields, null handling, format hints, or indentation.
Copy the generated source code to your clipboard and place it in an interface, class, struct, or type definition file.
Download the generated output using the file extension of the selected target: .ts, .py, .go, or .rs. Review the output before adding it to a production codebase.
Paste a JSON object or array into the editor or open a local .json file. Representative examples produce more useful results.
JSON parsing and code generation happen in your browser. The page does not require an account or upload the source data to a remote generation service.
Paste an object, an array of objects, or a JSON file containing representative data. Include important variations when the real payload can contain optional fields or different item shapes.
Select TypeScript, Python, Go, Rust, Java, Kotlin, C#, or Swift. Each target may use different conventions for names, nullability, arrays, and serialization.
Enter a valid root name such as UserResponse, Product, or ApiResult. Nested declaration names are derived from the structure and may be adjusted after generation.
Enable the options supported for the selected target, such as export declarations, optional fields, null preservation, format hints, or indentation.
Click Generate Code and inspect nested types, arrays, unions, null handling, and property names before using the output.
Copy the result or download the source file. Generated code is a starting point and should be compiled, formatted, tested, and adapted to the target project's conventions.
{
"id": 1,
"name": "Alice",
"email": "alice@example.com"
}export interface RootObject {
id: number;
name: string;
email: string;
}A JSON to code generator reads a JSON sample and writes declarations for another language. Depending on the target, the output is a TypeScript interface, a Python dataclass, a Go struct, a Rust struct, a Java class, a Kotlin data class, a C# class, or a Swift struct, plus any nested declarations those types reference.
The generator removes repetitive boilerplate, but it does not know the rules of your application. Treat the result as a starting model that still has to be reviewed, compiled, tested, and adapted to the conventions of the target project.
string, str, or String.int/float, int/float64, and i64/f64. TypeScript uses number for both.boolean, bool, or a target-specific equivalent.Item[] (TypeScript), list[Item] (Python), []Item (Go), Vec<Item> (Rust), List<Item> (Java, Kotlin, C#), or [Item] (Swift).null, None, a pointer, or Option<T> depending on the target and the options you set.Nested JSON objects are emitted as separate named declarations in every supported target. Names are inferred from property names, but properties such as data, items, or value can produce generic or ambiguous names. Rename declarations when the generated names do not describe the domain model clearly.
Property naming also varies by target. Go field names are exported and keep the original JSON key in a struct tag. Rust field names are snake_case and keep the original key in a serde(rename) attribute. Python keeps the key when it can be used as a field name and sanitizes it otherwise, and TypeScript quotes keys that are not valid identifiers. After renaming, confirm that serialization still maps the field back to the original JSON key.
An array of objects is straightforward when every item has the same shape. Real API responses often contain variants:
[{"type":"user","name":"Alice"},{"type":"error","code":400,"message":"Bad request"}]The object variants merge into one model whose fields are marked optional. A union is only produced for mixed primitive values such as numbers and strings, and only in TypeScript and Python; Go, Rust, Java, Kotlin, C#, and Swift have no union type, so such a position falls back to a permissive value type that you should model by hand.
A field missing from some samples and a field whose value is null are different things. The first means the key may be absent; the second means the key is present with a null value.
key?, Python adds a None default, Go adds omitempty to the struct tag, Rust uses Option, and Kotlin, C#, and Swift append ? (Java represents an optional field with a boxed nullable type such as Integer).T | null, Python writes T | None, Go writes a pointer such as *string, Rust writes Option<T>, and Kotlin, C#, and Swift write T? (Java uses a boxed nullable type such as Integer).unknown (TypeScript), Any (Python), interface{} (Go), serde_json::Value (Rust), Object (Java), Any? (Kotlin), dynamic (C#), or Any (Swift).Each target exposes only the options that make sense for it. Every target supports optional fields, null preservation, and indentation. Export declarations are available for all targets except Go (which exports by capitalizing field names). Format hints are available for all targets except Rust (which has no standard date type). Renamed JSON keys are preserved through serialization metadata: @JsonProperty for Java, @SerialName for Kotlin, [JsonPropertyName] for C#, a CodingKeys enum for Swift, json struct tags for Go, serde(rename) for Rust, quoted keys for TypeScript, and sanitized names for Python.
Go exports identifiers through capitalization, so there is no export toggle. Rust has no date type in its standard library, so there is no format hint.
TypeScript has one numeric type, so both 42 and 4.2 become number. Python, Go, Rust, Java, Kotlin, C#, and Swift all separate integers from floating-point values: a sample without a fractional part becomes int, int, i64, Integer, Int, int, or Int, and a sample with one becomes float, float64, f64, Double, Double, double, or Double. One sample cannot reveal every range, so widen or narrow these types after reviewing the real data contract.
Generated TypeScript interfaces, Go structs, Python dataclasses, or Rust structs do not automatically validate incoming JSON. External data can be malformed, incomplete, or changed by another service. Add runtime parsing, schema validation, deserialization checks, or generated serializers when the application depends on runtime guarantees.
One sample may omit optional fields or fail to show alternative response shapes. Multiple representative samples can improve inference for optional properties, nullable values, mixed arrays, and unions. If the tool accepts only one input document, combine or review representative examples manually before finalizing the model.
This generator is designed to parse JSON and generate code in the browser rather than sending the input to a remote service. That is convenient for API samples and development data, but it is not a secure secret-management system. Avoid entering credentials, tokens, private customer records, or confidential production payloads into any online tool.