JSON to PHP Array Converter
NOUVEAUConvert JSON to PHP array code with short or long syntax, or read a PHP array literal back to JSON, all in your browser.
Fonctionne à 100 % dans votre navigateur — vos données ne sont jamais envoyées ni stockées sur nos serveurs.
Cet outil n'est pas encore entièrement traduit : une partie du texte est encore en anglais. L'outil lui-même fonctionne de la même façon dans toutes les langues.
JSON → PHP: objects become associative arrays, strings are single-quoted with only \ and ' escaped, and numbers keep their exact digits (98.60 stays 98.60). The var_export() style always writes keys and ignores the indent and syntax options.
PHP → JSON: reads literal arrays only: [ ] or array( ), single- and double-quoted strings without variables, numbers (hex, octal, binary and 1_000 included), true, false, null and =>. Constants, function calls, concatenation and heredoc strings are reported as unsupported, with their line and column.
Exemples rapides
Des entrées typiques et les résultats produits par cet outil.
Présentation
The JSON to PHP array converter writes PHP source code from JSON, so a config file, fixture or API response can be pasted straight into a PHP project. Objects become associative arrays, JSON lists become indexed arrays, and null, true and false keep their meaning.
You can choose short [ ] or long array( ) syntax, indent with 2 spaces, 4 spaces or a tab, wrap the array in <?php return …; or produce var_export-style output. Strings are single-quoted with only the backslash and the single quote escaped, and numbers keep their exact digits.
The reverse direction reads a literal PHP array and returns JSON. Constants, function calls and variables are reported as unsupported with a line and column. Nothing leaves your browser.
Pourquoi utiliser cet outil ?
- Paste JSON data straight into PHP config files
- Short, long or var_export-style output
- Exact number digits and correct string escaping
- Reverse direction for simple PHP arrays
- Runs in your browser, free, no sign-up
Fonctionnalités
Both directions
Convert JSON to PHP source or a literal PHP array back to JSON.
Short or long syntax
Write [ ] or array( ), with 2-space, 4-space or tab indentation and optional trailing commas.
Three output styles
Plain array literal, a <?php return …; file, or var_export-style text with explicit keys.
Correct string escaping
Single quotes escape only \ and '. Strings with line breaks can use double quotes with \n and \$ escapes.
Exact numbers
Numbers are copied digit for digit, so 98.60 stays 98.60 and 1.0 stays a float.
Clear errors
Invalid JSON and unsupported PHP syntax are reported with line and column numbers.
Mode d'emploi
Choose a direction
Select JSON → PHP array or PHP array → JSON under Direction.
Paste or upload
Paste your data, use Upload file, or press Load sample.
Set the options
Pick the output style, array syntax, indent, trailing commas and string quoting.
Copy or download
Press Copy for the clipboard or Download to save a .php or .json file.