JSON to TypeScript
Typed models from a sample response.
Paste a representative API response and get TypeScript interfaces that describe it — or the equivalent models in Python, Java, Kotlin, Go, C#, Rust, PHP or JSDoc. The generator is deterministic: the same input always produces the same output.
Input JSON
TypeScript models
How type generation works
Jsonviewpro infers a shape for every value in the document and merges the shapes it finds. Crucially, the shapes of array items are merged with each other — a 10,000 element array of users produces one User type, not ten thousand.
Identical shapes are de-duplicated, so a nested address object that appears in three places yields a single Address type referenced three times.
Optional and nullable fields
- A field present in some array items but not others becomes optional —
email?: stringin TypeScript,Option<String>in Rust, a nullable property elsewhere. - A field that is sometimes null becomes a nullable type —
string | null. - A field with genuinely mixed types across records widens to the safest common type, and the analyzer flags it so you can decide whether the API is inconsistent.
Supported languages
TypeScript interfaces, JavaScript JSDoc typedefs, Python dataclasses, Java classes with getters and setters, Kotlin data classes with kotlinx.serialization annotations, Go structs with JSON tags, C# classes with System.Text.Json attributes, Rust structs with serde derives, and PHP typed classes.
Where a language convention renames fields — snake_case in Python and Rust, PascalCase in Go and C# — the generator emits the mapping annotation so serialization still matches the original JSON keys.
Use a real sample
Generated types are only as good as the sample. One record cannot tell the generator which fields are optional, and a truncated response cannot show which values are sometimes null. Paste the largest realistic response you have — ideally one that includes an empty state and an error case — and review the result before committing it.
For a contract you can validate against at runtime, generate a JSON Schema instead, or as well.
Frequently asked questions
Is this AI generated?
How are optional fields decided?
Which languages are supported?
Can I generate types from a huge array?
Related JSON tools
- JSON Schema GeneratorInfer a JSON Schema from a sample document.
- JSON ViewerExplore JSON as a collapsible tree with search and copyable paths.
- JSON AnalyzerProfile structure and surface data-quality problems.
- JSON ValidatorCheck syntax with precise line, column and cause.
- JSON to CSVTurn arrays of records into a spreadsheet-ready CSV.