JSON to TypeScript
Free online JSON to TypeScript converter: infer interfaces from JSON — nested types, union arrays, optional nulls.
Privacy: all processing happens locally in your browser. Your input never leaves your device.
What is JSON to TypeScript?
Hand-writing TypeScript types from an API response is tedious and error-prone. This tool infers types from a sample JSON and generates interfaces: nested objects become independently named interfaces, array elements get union types, and null fields are marked optional. Fields with the same name but different shapes are automatically numbered to avoid collisions. The result can be pasted straight into your project.
How to Use
- Paste a sample JSON from an API response
- TypeScript interfaces are generated automatically
- Rename the root type if needed, then copy
FAQ
- What type is generated for null values?
- A field whose value is null is typed null and marked optional (?), because a null in the sample often means the field can hold other types — fill it in from the API documentation.
- What if array elements have inconsistent shapes?
- The tool produces a union type for the array elements, e.g. (A | B)[]; an empty array becomes unknown[].
- How are the interfaces named?
- The root type defaults to Root; nested objects derive PascalCase names from their field names, and same-named but different-shaped structures get numeric suffixes.
Related Tools
JSON Formatter & ValidatorFree online JSON formatter and validator with inline error hints, collapsible tree view and in-browser processing.JSON MinifierFree online JSON minifier: compress JSON to one line, see live size savings, and validate syntax — processed locally.JSON Escape / UnescapeFree online JSON escape and unescape tool for quotes, newlines and backslashes — fix nested escaping locally.JSON Key SorterFree online JSON key sorter: recursively order object keys alphabetically so semantically identical JSON diffs cleanly.JSON Diff & CompareFree online JSON compare tool: ignores key order, listing added, removed and changed fields by path — all local.JSON to CSV ConverterFree online JSON to CSV converter with RFC4180 escaping, union-field headers, CSV-to-JSON reverse and .csv download.
Last updated 2026-09-04