XPath Tester
Run XPath expressions against your own XML and see every node that matches.
Convert JSON into a PHP array literal or a typed class you can paste into a project.
The JSON to PHP Array converter writes a PHP array literal with the modern short syntax, correctly indented and escaped, or typed PHP 8 classes with promoted constructor properties if you want real models instead.
Two things people mean by "JSON to PHP", and this tool does both. The array mode writes a PHP array literal with the modern short syntax, correctly indented and with strings escaped, so it can be pasted straight into a config file, a seeder or a test fixture.
The class mode writes typed PHP 8 classes instead, using promoted constructor properties, with a nullable type and a null default for any field that is not always present. Nested objects become their own classes and arrays carry an array-shape docblock, which is what static analysers such as PHPStan and Psalm need in order to check the code that consumes them.
An array literal for fixtures and config, or typed PHP 8 classes with promoted constructor properties for models.
Emit [1, 2, 3] or array(1, 2, 3) depending on how old the codebase you are pasting into is.
Quotes and backslashes inside string values are escaped, so the literal parses on the first try.
Class mode adds array-shape docblocks, which is what PHPStan and Psalm need to check the code around them.
Fields that are not always present are typed nullable with a null default, so constructing the object never fails on a partial payload.
Any document, from a small config object to a full API response.
Array for fixtures and config; classes for typed models.
Choose short or long array syntax and the indentation width.
Paste the result into a .php file, or download it.
For runtime data you should. This is for the times you want the data in the source itself — a config file, a seeder, a test fixture, or a typed class that gives your IDE and static analyser something to work with.
Short is [1, 2, 3] and long is array(1, 2, 3). Short has been available since PHP 5.4 and is what every modern style guide uses; long only matters for very old codebases.
As associative arrays with string keys, which is what json_decode returns by default with the associative flag. Class mode gives you real objects instead.
Yes. JSON null becomes PHP null, and true and false become the PHP literals, not strings.
What people who use the JSON to PHP Array think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the JSON to PHP Array. It takes half a minute and no account.
Write the first reviewRun XPath expressions against your own XML and see every node that matches.
Encrypt text with a password using AES-GCM, and decrypt it back.
Generate and decode MongoDB ObjectIds, including their embedded timestamp.
Build a docker-compose.yml with databases, caches and health checks.
Build an accessible HTML table from pasted data or by hand.
Strip every optional byte from a JSON document and see what you saved.
Build soft extruded UI with paired light and dark shadows.
Convert file permissions between octal, symbolic and checkboxes.