A JSON to TypeScript converter looks at a JSON sample and generates TypeScript type definitions that match it. It saves you from writing types by hand for API responses, configuration files, and data models.
ToolsViewer's online JSON to TypeScript generator reads nested objects and arrays and outputs TypeScript you can copy straight into your project. You can choose the name of the root type.
Step 1: Add your JSON
Paste a sample, import a .json or .txt file, fetch a public URL, or load the sample.
Step 2: Set the root type name
Enter a name in the sidebar. The default is Root.
Step 3: Click Convert
The tool works out the types of your data and generates TypeScript.
Step 4: Copy or download
Copy the code or download it as a .ts file, then refine it in your project.
.ts outputType API responses: Generate types from a sample response.
Speed up development: Skip the repetitive work of writing types by hand.
Document data structures: Show the shape of a JSON payload as code.
Learn TypeScript: See how JSON values map to TypeScript types.
.json files.txt files containing JSONTypes are inferred from a single sample. Optional fields and values that can have more than one type may need manual edits, so review the result before using it.
Explore related tools like JSON Validator, JSON Schema Validator, and JSON to YAML to validate and convert JSON online.