Need to convert PHP into JSON Schema?
JSON Input
Generated PHP
PHP Generation Options
Enter JSON data to generate PHP code
Classes with getters and setters
Generate PHP classes from JSON data structures
Need to convert PHP into JSON Schema?
Enter JSON data to generate PHP code
Classes with getters and setters
Use this JSON to PHP generator to create PHP classes from JSON samples for Laravel, Symfony, and backend integrations.
Step 1 – Paste a JSON sample
Import to load JSON from a file, URL, or sample data.Step 2 – Choose PHP class options
Class Name and namespace if you use PSR-4 autoloading.?string).Step 3 – Review the generated code
Root Type Name, null handling, and frameworks if available.Step 4 – Use the classes in PHP
Step 5 – Copy or download
Quick tips
// JSON input
{
"id": 123,
"name": "Maeve Winters",
"email": "maeve@example.com",
"active": true,
"roles": ["admin", "editor"],
"metadata": { "plan": "pro" },
"createdAt": "2024-03-01T10:15:00Z",
"score": 99.5,
"notes": null
}
// Generated PHP DTOs (simplified)
final class Metadata {
public string $plan;
}
final class Root {
public int $id;
public string $name;
public ?string $email;
public bool $active;
/** @var string[] */
public array $roles;
public Metadata $metadata;
public string $createdAt;
public float $score;
public mixed $notes;
}Explore more JSON and schema tools that work great alongside this JSON to PHP generator.
Convert existing PHP classes into JSON examples and JSON Schema for docs and validation.
Generate a JSON Schema from JSON samples to validate payloads and contracts.
Format and validate JSON before generating PHP classes to avoid runtime issues.
Generate frontend types that match the same PHP API payloads.
The generator creates PHP classes with type hints (PHP 7.4+), getters/setters, constructors, and supports various frameworks like Laravel Eloquent models and plain PHP classes.
Yes! Select 'Laravel' as the framework to generate Eloquent model classes that extend the base Model class with proper imports and Laravel conventions.
You can specify a custom namespace in the options. The generator will add the appropriate namespace declaration at the top of the generated PHP file.
The generator uses modern PHP type hints for method parameters and return types, supporting bool, int, float, string, and array types based on your JSON data.