jsondecode.com logo

JSON to PHP Array Converter — Free Online Tool

Convert JSON to PHP associative array syntax with proper types and nested structure using AI. Free, no sign-up.

JSON to BigQuery Schema Converter — Free Online ToolJSON to React Flow Diagram — Convert JSON Online FreeJSON to Go Struct with BSON Tags — Free Online ToolJSON to TypeScript Interface Generator — Free OnlineJSON to YAML Converter — Convert JSON to YAML OnlineJSON to CSV Converter — Export JSON Array to CSV FreeJSON to Python Dataclass Generator — Free Online ToolJSON to SQL INSERT Statement Generator — Free OnlineJSON to Markdown Table Converter — Free Online ToolJSON to XML Converter — Convert JSON to XML Online FreeJSON to HTML Table Converter — Free Online ToolYAML to JSON Converter — Convert YAML to JSON Online FreeXML to JSON Converter — Convert XML to JSON Online FreeJSON to JSON Schema Generator — Free Online ToolJSON to GraphQL Schema Generator — Free Online ToolRuby to JSON Converter — Convert Ruby Hashes to JSON OnlineJSON to C# Class Generator — Free Online ToolJSON to Java Class (POJO) Generator — Free Online ToolJSON to Kotlin Data Class Generator — Free Online ToolJSON to Rust Struct Generator — Free Online ToolCSV to JSON Converter — Free Online ToolJSON to Dart Class Generator — Free Online ToolJSON to Swift Struct (Codable) Generator — Free OnlineJSON to Terraform HCL Variables Converter — Free OnlineJSON to Mongoose Schema Generator — Free Online ToolJSON to Prisma Schema Model Generator — Free OnlineJSON to Protocol Buffer (proto3) Generator — Free OnlineJSON to TOML Config Format Converter — Free Online ToolTOML to JSON Converter — Convert TOML to JSON Online FreeJSON to Apache Avro Schema Generator — Free Online ToolJSON to OpenAPI 3.0 Schema Component — Free Online ToolJSON to R Data Frame Code Generator — Free Online ToolJSON to Lua Table Syntax Converter — Free Online ToolJSON to Zod Schema (TypeScript) Generator — Free OnlineJSON to Scala Case Class with Circe Codec — Free OnlineJSON to PowerShell Hashtable Converter — Free Online Tool

JSON to PHP Array Converter — Free Online Tool

About JSON to PHP Array Converter — Free Online Tool

The JSON to PHP Array converter transforms JSON objects and arrays into native PHP associative array syntax, producing ready-to-paste PHP code using array() or short [] notation. Developers use it to bootstrap configuration files, seed test fixtures, or integrate API responses into PHP codebases without writing repetitive array syntax by hand.

JSON to PHP Type Mapping

JSON TypeJSON ExamplePHP OutputPHP Type
Object{"key": "value"}['key' => 'value']Associative array
Array[1, 2, 3][1, 2, 3]Indexed array
String"hello"'hello'string
Number (integer)4242int
Number (float)3.143.14float
Boolean truetruetruebool
Boolean falsefalsefalsebool
Nullnullnullnull
Nested object{"a": {"b": 1}}['a' => ['b' => 1]]Nested associative array
Array of objects[{"id":1}][['id' => 1]]Indexed array of associative arrays

PHP Array Syntax Comparison

Syntax StyleExamplePHP VersionNotes
Short array syntax$a = ['key' => 'val'];5.4+Preferred in modern PHP; cleaner and concise
Long array syntax$a = array('key' => 'val');All versionsBackward-compatible; required before PHP 5.4
json_decode to stdClassjson_decode($json)5.2+Returns object, not array; no static PHP code
json_decode to arrayjson_decode($json, true)5.2+Runtime conversion; requires JSON string at runtime
Static PHP array$a = ['key' => 'val'];5.4+Best for config files, fixtures, and hardcoded data

Frequently Asked Questions

How do I convert JSON to a PHP associative array?

You can convert JSON to a PHP associative array at runtime using json_decode($jsonString, true), where the second argument true forces an associative array instead of an stdClass object. For static data you want embedded directly in PHP source code — such as config files or test fixtures — use an online converter like this tool to generate the array literal syntax without writing it by hand.

What is the difference between json_decode and a static PHP array?

json_decode parses a JSON string at runtime, so your PHP file must include the raw JSON string and decode it on every execution. A static PHP array literal like ['key' => 'value'] is parsed at compile time, has no runtime overhead, and is easier for IDEs and static analyzers to inspect. Use static arrays for data that does not change; use json_decode when consuming external or dynamic JSON payloads.

Does PHP use arrow syntax or fat arrow for associative arrays?

PHP uses the fat arrow => operator (not ->) to separate keys from values in associative arrays — for example, ['name' => 'Alice', 'age' => 30]. The -> operator is reserved for accessing object properties. This is a common source of confusion when coming from JavaScript, where objects use : for key-value pairs.

How are nested JSON objects converted to PHP?

Each nested JSON object becomes a nested PHP associative array. For example, {"address": {"city": "London"}} converts to ['address' => ['city' => 'London']]. There is no depth limit in PHP array literals, so deeply nested structures are fully supported. The converter handles arbitrary nesting automatically.

Should I use array() or [] syntax in PHP?

The short [] syntax is recommended for all new PHP code targeting PHP 5.4 and above, which covers virtually every production environment in use today. It is less verbose and more consistent with array literals in other languages. Use the long array() syntax only if you must support PHP 5.3 or earlier, which reached end-of-life in 2014.

If jsondecode.com saved you time, share it with your team

Free forever. No ads. No sign-up. Help other developers find it.