Developer tools
PHP json_decode & json_encode Online
Paste JSON to see exactly what json_decode() gives you, as PHP array code or print_r() output. Or paste a PHP array and get json_encode() output with the flags you choose.
- Runs in your browser
- Free, no sign-up
Converted in your browser. Nothing is uploaded.
How to use the PHP json_decode & json_encode Online
-
1
Choose json_decode (JSON → PHP) or json_encode (PHP → JSON) and paste your input. It converts as you type.
-
2
For decoding, choose arrays or stdClass objects and PHP code or print_r(). For encoding, tick the JSON_* flags you use.
-
3
Copy or download the result, or Swap to convert it back. The line at the bottom is the matching PHP code.
Frequently asked questions
What does the second argument of json_decode do?
json_decode($json, true) returns associative arrays. Without it (or with false), JSON objects become stdClass objects, accessed as $data->name instead of $data['name'].
Why does json_encode turn my array into an object?
A PHP array becomes a JSON list only when its keys are 0, 1, 2, … in order. Any other keys (strings, gaps, a different order) give a JSON object. Use array_values() to get a list.
Why are slashes and accents escaped?
By default json_encode writes / as \/ and non-ASCII characters as \u00e9. Add JSON_UNESCAPED_SLASHES and JSON_UNESCAPED_UNICODE to keep them as they are.
What PHP code can I paste?
Arrays in [] or array() syntax, strings, numbers, true, false and null, nested as deep as you like. A full statement like $data = [...]; or return [...]; works too. Variables, constants and function calls can't be evaluated in the browser.