Add the PHP array
Paste an array expression, assignment, or return statement, or upload a small .php or .txt file.
Convert PHP array syntax into valid, structured JSON without running PHP code. Supports short and classic arrays, nested values, associative keys, comments, formatting, and instant download.
Create standards-compliant JSON from PHP array notation in three focused steps.
Paste an array expression, assignment, or return statement, or upload a small .php or .txt file.
Select indentation, numeric-key handling, key sorting, and optional Unicode or slash escaping.
Review the parsed structure, copy the result, or download a ready-to-use .json file.
This tool does not execute the supplied PHP. A dedicated tokenizer reads array syntax, strings, numbers, booleans, null values, keys, nested arrays, trailing commas, and common comments before building the JSON structure.
Sequential numeric keys become JSON arrays in smart mode. Associative or non-sequential keys remain JSON objects so important identifiers are not silently discarded.
[] and array() syntax with nested valuesUseful for configuration migrations, API payloads, fixtures, localization data, testing, and frontend handoffs.
The parser never evaluates functions, variables, expressions, includes, or executable PHP statements.
Nested arrays and associative keys are preserved while sequential lists become natural JSON arrays.
Unsupported tokens and malformed arrays return a readable error with a nearby line and column.
Important details about PHP array syntax and JSON conversion.
No. It uses a browser-side parser and never sends the input to PHP eval or the server.
Both short [] arrays and classic array() notation are supported, including nested arrays and => keys.
Yes. The parser can extract an array from common forms such as $config = [...] and return array(...);.
Smart mode produces a JSON array only when keys are sequential from zero. Other numeric keys are preserved in a JSON object.
No. JSON has no equivalent for executable expressions. Replace constants, functions, objects, and variables with literal values before converting.
No. Parsing, formatting, copying, and download creation happen locally in your browser.