Skip to main content
Back to Tools
Web Tools

JSON to PHP Converter

Convert JSON data to PHP associative arrays or class definitions. Supports short [] and long array() syntax, const declarations, nested structures, and automatic type inference for class properties. Runs entirely in your browser — your data never leaves your machine.

json php converter array class code-generator

Published May 30, 2026

All interactive tools run entirely in your browser. Your data never leaves your device.

How It Works

Paste JSON and instantly get PHP code. Choose between associative array output (with variable or const declaration) or class definitions with typed properties and a constructor.

Features

  • Array mode: converts JSON to PHP associative arrays with $variable or const declaration
  • Class mode: generates PHP classes with typed properties (string, int, float, bool, array, mixed) and __construct(array $data)
  • Short/long syntax: toggle between [] and array() syntax
  • Nested support: nested objects generate nested arrays or sub-classes
  • String escaping: properly escapes single quotes and backslashes
  • 5 examples: simple object, nested, array of objects, API response, config file
  • Private: runs entirely in the browser — no data transmitted

Use Cases

  • Converting API JSON responses to PHP data structures
  • Generating PHP class stubs from JSON schemas
  • Building PHP configuration arrays from JSON configs
  • Quick prototyping with PHP and JSON data
  • Converting between JavaScript/JSON and PHP ecosystems