WizzyTools

Generate TypeScript interfaces and PHP classes from JSON

Works offline · never uploaded

Paste JSON and get TypeScript interfaces or PHP classes with typed properties, including nested objects and arrays, instantly in your browser.

Updated

/ 5 - Be the first to rate this tool Thanks for rating!

Verification failed - please try again.

How it works

  1. 1

    Choose TypeScript or PHP.

  2. 2

    Enter a name for the root type.

  3. 3

    Paste a representative JSON sample.

  4. 4

    Copy the generated types into your code.

About the JSON to TypeScript/PHP

Writing type definitions for an API response by hand is slow and easy to get wrong, especially when it has nested objects and arrays. This tool reads a sample JSON document and generates matching TypeScript interfaces or PHP classes with typed properties. Each nested object gets its own named type, and array items are named after the singular form of their key.

What you can do

  • Generate TypeScript interfaces or PHP classes from one JSON sample.
  • Set the name of the root type; nested types are named from their keys in PascalCase.
  • Name array item types in the singular, so a users array produces a User type.
  • Combine the fields of every object in an array into one type, so a key that appears only in later items is still included.
  • Tell integers from floats in PHP output, and add @var docblocks for typed arrays.

When it works best

  • Typing the response of a REST endpoint before writing a fetch wrapper.
  • Creating PHP data transfer objects for a webhook payload.
  • Getting a first draft of types for a third-party API that ships no SDK.

Things to know

  • Your JSON is processed in the browser and is not uploaded.
  • Types reflect only the sample you paste. Fields that are sometimes missing are not marked optional, and a null value becomes null in TypeScript or mixed in PHP, so review the output.
  • Arrays of mixed primitive types become unknown[] in TypeScript. PHP property names have invalid characters replaced with underscores.
  • To check JSON against rules, use the JSON Schema Validator. To tidy the sample first, use the JSON Formatter.

Frequently asked questions

TypeScript interfaces and PHP classes with typed properties.

In PascalCase from their keys, with array items singularised, so users produces User.

No. Types reflect the sample only, so mark optional fields yourself.

They become null in TypeScript and mixed in PHP.