JSON → TypeScript
Infer TypeScript interfaces or aliases from JSON examples, with optional fields and predictable unions.
Infer types from examples, not a schema. Review optional fields and unions against your API contract.
JSON EXAMPLE
TYPESCRIPT
Paste JSON, choose a style and root name, then generate.
Enable JavaScript to convert locally. No server submission is available.
A starting point for your types.
Paste strict JSON, choose Interface or Type alias, and name the root. Nested objects get readable names. Array objects are examined together: a field missing from an observed object becomes optional, and different observed value types become a union.
Evidence, not assumptions.
A null-only value produces null, not an invented string or number. Empty arrays use unknown[]. Empty objects use a string index signature with never values rather than the overly broad TypeScript empty-object type. Strings stay strings; dates and enums are not guessed.
Local and temporary.
Input, root names and generated definitions stay in browser memory. Reset and navigation clear the workspace. Copy and Download .ts are explicit local actions; no compiler, server request or executable code runs on your input.
Review what the sample can tell you.
Does this validate my API schema?
No. Examples cannot prove required fields, all possible variants, enum values or recursive relationships. Optionality comes only from objects observed in the same array or merged object field. Review the output against your actual contract.
How are names handled?
The root defaults to Root. Names use ASCII words in PascalCase, with a prefix for leading digits and deterministic numeric suffixes for collisions. Root normalization is shown after generation. JSON property names are never renamed; unusual keys are quoted and escaped.
What happens to large numbers?
Every JSON number infers number. The parser does not rewrite numeric tokens or construct a native value object. Numbers outside safe JavaScript precision/range receive a note: a TypeScript number annotation cannot guarantee exact values when your application later parses them.
What about duplicate keys?
JSON Formatter can retain duplicate tokens and flag them. A TypeScript declaration cannot faithfully represent conflicting duplicate properties, so this converter detects decoded duplicate names and stops before inference. Resolve duplicates explicitly; the input remains unchanged.
What are the limits?
32 KiB UTF-8 input, 32 nested levels, 8,000 values, 200 named types and 128 Ki characters of output. All array samples within those bounds are examined. The root name is limited to 80 characters. Large previews are labeled; Copy and Download use the complete result.