Skip to content
OnlineToolStudio

JSON to PHP Array

runs in your browserno sign-upfree

Convert JSON data into ready-to-paste PHP array code with short [ ] or array( ) syntax.

Converted to a PHP array

JSON196 chars
PHP

About this tool

This tool converts JSON into PHP array code you can paste straight into a PHP file — for example config arrays, test fixtures or seed data. Choose short [ ] or classic array( ) syntax, 2 or 4 space indentation, and optionally assign the result to a variable. Numeric string keys become integers, just like PHP.

How to use

  1. Paste your JSON into the JSON box.
  2. Pick the syntax, indent and variable name (leave the name empty for just the array).
  3. Copy the PHP code or download it as a .php file.

FAQ

Is the result the same as json_decode($json, true)?

Yes. The generated array has the same keys and values as PHP’s json_decode with associative arrays enabled, written out as PHP code.

Why are list keys (0 =>, 1 =>) hidden?

Simple lists are clearer without them and mean the same thing in PHP. Turn on “Show list keys” if you prefer the var_export style with every key written out.

Is my data uploaded or run as PHP?

No. The conversion happens in your browser with a small JavaScript parser — no PHP is executed and nothing is uploaded.

Related tools

All tools