Format & Convert
JSON to TypeScript
Infer TypeScript interfaces from JSON samples.
About JSON to TypeScript
JSON to TypeScript reads a representative JSON sample and infers interfaces that make API responses easier to type in TypeScript projects.
Common uses
- Generate a starting interface from a REST response.
- Compare how arrays and nested objects will be represented in TypeScript.
- Create documentation-friendly types from example payloads.
Good to know
Review generated types before committing them, especially when optional fields are missing from the sample or an API returns mixed value types.
Choosing a representative sample
Paste a sample that includes optional fields, null values, arrays with more than one shape, and nested objects. A tiny happy-path response can produce interfaces that look correct but miss real production cases.
How to use generated types
Treat the output as a starting point for documentation or local code. Rename interfaces, mark truly optional properties, and check whether IDs, dates, and numeric strings should use narrower domain types.
Common mistakes
Generated interfaces cannot infer values that are absent from the sample. If an API sometimes omits a field or returns mixed types, add those cases to the sample before relying on the result.
Before you rely on the output
- Use representative samples and validate the result in the target parser or application before replacing production configuration or data files.
- Privacy mode: inputs are processed locally in your browser and are not intentionally sent to an application server.
Related tools
JSON CSV Converter, JSON Formatter, SQL Formatter, XML Formatter
