JSON to PHP Array Converter

Convert JSON to a PHP array literal with short array syntax.

  • 100% client-side · your data never leaves your browser
  • Instant, no rate limits
  • Free, no sign-up
Input JSON
PHP array

Your result appears here

Paste JSON into the panel on the left — everything runs privately in your browser.

Overview

JSON to PHP Array Converter — Convert JSON Online

Convert JSON into a PHP array literal using modern short array syntax. JsonDrift turns objects into associative arrays and JSON arrays into sequential arrays, escaping strings and mapping true, false, and null to their PHP equivalents — so the output is valid PHP you can paste into configs, fixtures, and scripts. Runs entirely in your browser.

No uploadsNo sign-upOpen source
  1. Why convert JSON to a PHP array?

    PHP applications often need data baked into source — default configuration, seed data, test fixtures, or lookup tables — where an inline array is clearer than reading a file at runtime. Transcribing JSON into PHP array syntax by hand is slow and easy to get wrong; generating it is instant and correct.

  2. How JSON maps to PHP

    Objects become associative arrays with 'key' => value pairs, and JSON arrays become sequential arrays. Strings are single-quoted and escaped, numbers pass through, and JSON true, false, and null become PHP true, false, and null. The output uses short array syntax ([ ]), the standard since PHP 5.4.

    • Objects to associative arrays ('key' => value)
    • Arrays to sequential arrays
    • true / false / null mapped to PHP equivalents
    • Short array syntax with clean indentation
  3. Array literal vs json_decode

    Both get JSON into PHP, but they serve different needs. json_decode($json, true) is right when the data arrives at runtime from a request or file. A pasted array literal is right when you want the data written directly into source — config files, defaults, and fixtures — where an inline structure is easier to read and version. This tool is optimized for that second case.

FAQ

Frequently asked questions

How do I convert JSON to a PHP array?

Paste your JSON and JsonDrift returns a PHP array literal using short array syntax, ready to paste into any .php file.

Does it use short array syntax?

Yes. The output uses [ ] short array syntax (PHP 5.4+) with 'key' => value pairs for objects.

How is this different from json_decode?

json_decode parses a JSON string at runtime. This tool produces an inline array literal for source code — ideal for configs, defaults, and fixtures.

Is my JSON uploaded?

No. Conversion runs locally in your browser.

Continue with a related tool

All tools

Learn more in our guides

All guides