What to run
Open JSON Formatter, click the Converters tab, and select JSON to TypeScript. Paste representative JSON data from your API response or database record into the input box.
Make sure your sample JSON contains representative values rather than empty arrays or empty strings so the engine can accurately work out whether properties are strings, numbers, booleans, or nested record types.
Review the generated TypeScript definitions in the preview panel, and click Copy to clipboard to paste the interfaces straight into your TypeScript project.
How to read the result
Inspect the root interface definition (RootObject) and note how nested objects are extracted into separate, strongly typed interfaces. For example, a nested user address property automatically generates an Address interface and references it cleanly.
Check array signatures carefully. If an array contains objects, verify that the element type maps to a dedicated interface array (such as Item[]). If an array contains mixed primitives (like strings and numbers), verify that a union type (string | number)[] is generated.
Look out for null values. If a property in your sample JSON is null, TypeScript infers any or unknown because the underlying data type cannot be determined without a non-null example.
What to open next
If your JSON payload fails to parse before type generation starts, switch to the Format & Minify tab in JSON Formatter to pinpoint unescaped characters, missing quotes, or syntax issues.
If your source data is stored in tabular CSV format and you want to convert it to JSON before generating TypeScript models, open CSV Fixer to sanitize delimiters and encoding.
If you want to verify that generated TypeScript keys correspond exactly to source field names across different API versions, open Text Diff to inspect differences.
Stop when
The generated TypeScript interfaces compile cleanly in your project without syntax errors or unexpected any types.
Never rely on a single API sample if endpoints return optional properties on different records; always supply samples with complete field coverage to avoid missing optional flags.
References
Continue troubleshooting
- How to Detect and Recover Lost Shopify Theme Customisations After an Update
- How to Fix Power Platform Deployment Settings and Connection Reference Errors
- How to Fix Power BI Theme JSON Import Errors
- How to Find and Fix JSON Syntax Errors
- How to Compare Two JSON Files with Semantic Diff
- How to Convert Nested JSON to Tabular CSV
- How to Convert Between JSON and YAML
- JSON syntax vs schema validation: format and diagnose JSON
- Why large JSON numbers change in JavaScript
- JWT exp, nbf and iat explained with timestamp examples
- Base64 vs Base64URL: why JWT decoding fails
Related tools
Frequently asked questions
How does the converter name nested TypeScript interfaces?
The engine derives interface names by capitalizing property names and removing underscores or dashes (e.g. user_profile becomes UserProfile), keeping child interfaces modular and readable.
What happens when an array in JSON is empty?
If an array contains no elements ([]), the converter cannot infer the intended schema and defaults the element type to any[]. Supplying a sample with at least one record produces a strongly typed interface.
Does the tool handle union types for mixed-value arrays?
Yes. If an array contains multiple primitive types such as [1, "two", true], the generator evaluates distinct item types and outputs a TypeScript union type such as (number | string | boolean)[].