JSON to PHP Array
Convert JSON to a PHP array in "short" (`[]`) or "long" (`array()`) syntax. Useful to generate config and seed files in Laravel/Symfony projects. Everything in your browser.
Turn an API payload into a config file
You have a JSON blob on hand, an API response, a fixture, a snippet from some docs, and you need it as a PHP array inside config/ or a seeder. Doing it by hand means swapping colons for arrows, fixing quotes, and finding the syntax error only when Artisan complains. This converter hands back the finished file, opening tag and return statement included.
Input goes through the browser's own JSON parser and the output is built recursively. A JSON array becomes a PHP list with no written indexes, an object becomes an associative array with quoted keys and arrows. Strings come out single quoted, escaping only backslash and the quote itself, which is exactly what PHP single quotes require: no accidental dollar sign interpolation. The selector at the top switches between short brackets and the older array parenthesis form.
Two things are worth checking. Very large integers, past nine quadrillion, lose precision inside the JSON parser itself, so long IDs should be strings at the source. And a numeric string key turns into an int when PHP builds the array, which can scramble a code lookup map. The generated file is a literal, with no json_decode at runtime, so it is faster and cacheable. Conversion happens in your browser and the JSON never leaves your machine.
Frequently asked questions
Short brackets or array()?
Does the output include json_decode?
Will single quotes break my text?
Related Tools
CSV to JSON
Convert CSV to JSON. The first row becomes object keys, the rest become array items. Supports separators , ; and \t. Auto-detects numbers and booleans. Everything in your browser.
JSONP to JSON Converter
Strips the callback wrapper of a JSONP response leaving only the JSON contained inside the parentheses.
JSON to Python (dataclass)
Convert JSON to a Python dataclass with type hints. Supports List, Optional and nested classes. Everything in your browser.
BSON to JSON (text) Converter
Explains differences between binary BSON and JSON with a type table and textual conversion examples.
Fixed-Width ↔ CSV/JSON Converter
Converts fixed-width text files to CSV, TSV or JSON and back, with automatic column detection, a position map and per-line warnings.
JSON to TypeScript
Convert a JSON to TypeScript interfaces with automatically inferred types. Detects strings, numbers, booleans, arrays, nested objects and union types. Everything in your browser.