JSON to Types — TypeScript, Python, Go, Java, C# & More

Paste an API response and get ready-to-use models in 8 languages: TypeScript, Python (dataclass, TypedDict or Pydantic), Go, Java, C#, Kotlin, Swift and Rust. Objects in arrays are merged, so optional and nullable fields are detected automatically.

Runs in your browser
TypeScript

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the JSON to Types

  1. Paste a JSON sample — ideally a real API response with arrays containing several items — or click Load sample.
  2. Pick the language and a style: for example Pydantic v2 for FastAPI, records for modern Java, or classes for C#.
  3. Set the root name. Nested objects become their own named types (e.g. Root, Address, OrderItem).
  4. Copy the code or download it with the right file extension.

How types are inferred

  • Arrays of objects are merged — a field that’s missing in some items becomes optional; a field that is sometimes null becomes nullable.
  • Numbers — whole numbers become integer types (int, int64, long, i64); anything with decimals becomes a float/double.
  • Dates — ISO 8601 strings like 2026-10-26T09:30:00Z can become Date, datetime, time.Time, OffsetDateTime, DateTimeOffset or DateTime<Utc>.
  • Mixed values — TypeScript gets a union type; stricter languages fall back to a generic type such as Any, interface{}, Object or serde_json::Value.
  • Names — keys that aren’t valid identifiers are converted (snake_case for Python and Rust, PascalCase for Go and C#, camelCase for Java, Kotlin and Swift) and mapped back with the language’s JSON annotation.

Output per language

LanguageStylesJSON mapping
TypeScriptinterface, type aliasQuoted keys where needed
Pythondataclass, TypedDict, Pydantic v2Field(alias=…)
Gostruct`json:"name,omitempty"` tags
Javarecord, POJOJackson @JsonProperty
C#record, classSystem.Text.Json [JsonPropertyName]
Kotlindata classkotlinx.serialization @SerialName
SwiftstructCodable with CodingKeys
Ruststructserde #[serde(rename)]

Tips

Paste a response that contains several items in each array — the more examples, the better optional and nullable detection works. No sample data yet? Create some with the Mock Data Generator. For TypeScript-only options such as readonly and array syntax, the dedicated JSON to TypeScript converter has extra settings. Clean up messy JSON first with the JSON Formatter.

Tools that pair well with the JSON to Types

  • JSON Path Finder — Paste a webhook payload or API response, click any value and copy its exact path — for JavaScript, JSONPath, jq, Python, PHP, n8n and Make.
  • JSON to YAML — Paste JSON and get clean YAML for Kubernetes manifests, Docker Compose, GitHub Actions or any config file.
  • cURL to Code — Paste a curl command — from API docs or “Copy as cURL” in your browser’s DevTools — and get ready-to-run code for six languages, with headers, body and authentication carried over.
  • YAML to JSON — Paste YAML — a Compose file, Kubernetes manifest or CI config — and get formatted JSON.

Frequently asked questions

Is my JSON uploaded?
No. Parsing and code generation run entirely in your browser, so it’s safe to paste real API responses.
How are optional fields detected?
When an array contains several objects, their keys are merged. A key that’s missing in at least one object becomes optional (e.g. name?: string, Optional[str], omitempty). Turn this off to make every field required.
Which Python style should I use?
Pydantic v2 if you validate data (FastAPI, settings); dataclasses for plain typed containers; TypedDict when you keep working with dicts, e.g. for json.loads results.
What happens with empty arrays or null-only fields?
There is nothing to infer from, so they become a generic type (unknown, Any, interface{}, Object, JsonElement, JsonElement, Any or serde_json::Value). Add a sample item to get a precise type.

Related tools