How to use the JSON to Types
- Paste a JSON sample — ideally a real API response with arrays containing several items — or click Load sample.
- Pick the language and a style: for example Pydantic v2 for FastAPI, records for modern Java, or classes for C#.
- Set the root name. Nested objects become their own named types (e.g.
Root,Address,OrderItem). - 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
nullbecomes 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:00Zcan becomeDate,datetime,time.Time,OffsetDateTime,DateTimeOffsetorDateTime<Utc>. - Mixed values — TypeScript gets a union type; stricter languages fall back to a generic type such as
Any,interface{},Objectorserde_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
| Language | Styles | JSON mapping |
|---|---|---|
| TypeScript | interface, type alias | Quoted keys where needed |
| Python | dataclass, TypedDict, Pydantic v2 | Field(alias=…) |
| Go | struct | `json:"name,omitempty"` tags |
| Java | record, POJO | Jackson @JsonProperty |
| C# | record, class | System.Text.Json [JsonPropertyName] |
| Kotlin | data class | kotlinx.serialization @SerialName |
| Swift | struct | Codable with CodingKeys |
| Rust | struct | serde #[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.