JSON to PHP Array Converter Online
A JSON to PHP array converter turns a JSON document into the PHP array literal you would otherwise type by hand.
What usually happens when you need to move a JSON config into a PHP file is the JSON is there but the PHP parser will not accept curly braces and double-quoted keys. You end up escaping quotes by hand or searching for the right bracket syntax your codebase uses.
Our JSON to PHP Array Converter parses the JSON once and writes the output in whichever PHP shape the project needs, from modern short brackets to legacy array() to a serialized string for WordPress.
How to Convert JSON to a PHP Array with Our Tool
- Load the JSON: paste it into the editor on the left, drag a .json file onto the input area, or click Upload File.
- Pick the PHP shape from the toolbar: short bracket [] is the default for modern code, with array(), stdClass, serialized, var_export, and define() one click away when the codebase needs a different shape.
- Watch the right pane: the PHP code re-renders the moment the JSON parses, and the format switch swaps the output without losing your input.
- Take the PHP out: Copy puts the code on your clipboard, Download saves it as a .php file ready to drop into the project.
Features of Our JSON to PHP Array Converter
Short Bracket Output
Modern [] syntax drops into a Laravel or Symfony config without violating the style guide.
Legacy array() Mode
Keeps the old constructor syntax for PHP 5.3 projects on shared hosts.
stdClass Object Cast
When calling code uses arrow access, the (object) cast keeps working without a rewrite.
Serialized String Output
var_export Config File
Save the output as a .php file a require statement can return.
define() Constant Block
Flat JSON keys become uppercase PHP constants ready to include.
Why Choose AIFreeForever's JSON to PHP Array Converter
| Capability | AIFreeForever | Typical Online Tools |
|---|---|---|
| Output Formats | Short [], array(), stdClass, serialized, var_export, define() | One fixed format |
| String Escaping | Single-quote and backslash rules PHP expects | Raw JSON-style escapes |
| WordPress Serialize | Byte-counted serialize string ready for an option row | Not available |
| Constants Mode | define() lines with uppercase naming | Not available |
| Privacy | PHP output is generated in your tab, no data sent out | JSON uploaded to a third-party server |
Made for WordPress Authors, Laravel Developers, and Legacy Maintainers
If your codebase expects short-bracket syntax for a Laravel config or the array() constructor for a legacy PHP 5 project, our JSON to PHP Array Converter writes the output in whichever shape you need. You paste the JSON and pick the format, and the PHP array is ready to drop into the file.
Closest match to handwritten PHP from any JSON input
Our JSON to PHP Array Converter uses PHP-style string escaping instead of leaking JSON backslashes into the output. A path with an apostrophe in it keeps the single-quote rules PHP expects, and a multi-byte character in a key still parses on the first include.
Six PHP Shapes
Short bracket, array(), stdClass, serialized, var_export, and define() all share one editor so the format switch never re-uploads.
Ready for include
Every var_export pass writes valid PHP a require statement can return, so the generated file is a settings file the moment it lands.
Stays in Your Tab
Source JSON and generated PHP both stay in the browser, so a customer secret in a config blob never lands on a third-party log.