JSON to PHP

Convert JSON to PHP class/array.

Convert JSON to PHP class/array.

This tool is designed to provide a seamless experience for developers by handling complex operations directly in your browser with maximum speed and security.

100% Private
Instant Results
Customizable
Offline Ready
Dev-Friendly
Easy Export

It converts JSON data into PHP classes with properties mapped to the JSON keys. It intelligently identifies data types and creates the necessary class structure for working with JSON in modern PHP applications (7.4+), including support for nested arrays, objects, and type hints. This is especially useful for developers building web applications with frameworks like Laravel, Symfony, or Slim, where having a clean, typed representation of API data helps in building more robust and maintainable features. The tool follows clean coding standards to ensure the generated code is easy to read and integrate into your existing projects.

Paste your JSON to generate a PHP class or a typed array. It handles nested objects by creating multiple classes or nested array structures.

While PHP is highly flexible, using typed classes for complex JSON responses provides better IDE auto-completion and significantly reduces common runtime errors. This tool automates the creation of these models, helping you maintain a structured and clean codebase for your PHP backends and API integrations.

Example Input

{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com",
  "isActive": true,
  "tags": ["admin", "dev"],
  "profile": {
    "bio": "Software Engineer",
    "skills": ["Go", "React", "TypeScript"]
  }
}

Example Output

class User {
    public int $id;
    public string $name;
    public string $email;
    public bool $isActive;
}

Type Hinting

Fix: The tool uses modern PHP type hints. If you are using an older version of PHP, you may need to remove them.

Does it support json_decode?

The tool generates the class structure; you can use `json_decode($json, false)` to map JSON to these classes.