Skip to content
Accessibility
Theme
Text size
High contrast
Limit animations
Readable fontAtkinson Hyperlegible
Increased text spacing
Underline links
Always show focus

Runs in your browser — nothing you paste is uploaded.

PHP Array ↔ JSON Converter

Turn a PHP array into JSON, or JSON into a PHP array literal — both directions, in your browser. Handles nesting, associative keys, and every scalar type.


      

What it does

Paste a PHP array — either [ … ] short syntax or array( … ) — and get formatted JSON. Or paste JSON and get a clean, indented PHP array literal you can drop straight into code. Everything runs client-side; nothing you paste leaves the page.

PHP → JSON

Reads the common PHP array syntax: nested arrays, 'key' => value pairs, single- and double-quoted strings, integers, floats, true, false, and null. A PHP list (sequential integer keys) becomes a JSON array; an associative array becomes a JSON object.

JSON → PHP

Produces a readable, indented PHP array using array( … ) with => for object keys — the same shape you'd write by hand or get from var_export().

Example

PHP:

['name' => 'Ada', 'roles' => ['admin', 'editor'], 'active' => true]

JSON:

{
  "name": "Ada",
  "roles": ["admin", "editor"],
  "active": true
}

Limitations

PHP → JSON understands array literals and scalars, not arbitrary PHP expressions (function calls, constants, variables, or heredocs). Working with WordPress wp_options values that are serialized rather than plain arrays? Use PHP Serialize & Unserialize instead.

Frequently asked questions

How is this different from json_encode / json_decode?

Those convert between JSON and PHP values at runtime. This converts the textual forms — a PHP array literal you'd write in source, and a JSON string — so you can move data between a PHP file and JSON config without running PHP.

Does it support PHP objects or expressions?

No. It reads array literals ([ … ] or array( … )) and scalars only — not objects, constants, variables or function calls.

Related tools