Tools / JSON → Type Generator

JSON → Type Generator.

Generate TypeScript interfaces, PHP DTOs, or Go structs from JSON.

About JSON → Type Generator

Manually writing TypeScript interfaces, PHP DTOs, or Go structs from JSON API responses is tedious and error-prone. This tool automates the process — paste any JSON object and instantly get strongly-typed code for your language of choice. It infers types from values, handles nested objects and arrays, and supports optional nullable fields and automatic snake_case to camelCase conversion. Perfect for working with REST APIs, database fixtures, or config files.

How to Use

  1. Paste a JSON object or array of objects into the input field.
  2. Select the target language: TypeScript, PHP DTO, or Go Struct.
  3. Optionally enable nullable fields or snake_case → camelCase conversion.
  4. Click "Generate Types" to produce the typed code.
  5. Copy the output into your project.

Key Features

  • Generate TypeScript interfaces from JSON
  • Generate PHP readonly DTOs with typed properties
  • Generate Go structs with JSON tags
  • Support for nested objects and arrays
  • Optional nullable/optional field annotations
  • Automatic snake_case to camelCase conversion

Common Use Cases

  • Creating TypeScript types from REST API responses
  • Building PHP DTOs for Laravel request/response handling
  • Generating Go structs from JSON API contracts
  • Converting JSON fixtures to strongly-typed models
  • Bootstrapping type definitions for new API integrations

Frequently Asked Questions

What JSON formats are supported?

The tool accepts JSON objects and arrays of objects. For arrays, the first element is used as the schema to infer types.

How are nested objects handled?

Nested objects generate separate named types (interfaces, DTOs, or structs) that are referenced by the parent type.

What does the nullable option do?

For TypeScript it adds `| null` to each field type. For PHP it adds `?` prefix to types. For Go it uses pointer types and adds `omitempty` to JSON tags.

How does snake_case to camelCase work?

Field names like `user_name` are converted to `userName` in the output. For Go, struct field names are always PascalCase but the JSON tag reflects the selected casing.

Does it handle arrays of primitives?

Yes. Arrays of strings become `string[]` in TypeScript, `array` in PHP, and `[]string` in Go. Arrays of objects generate nested types.

Related Tools