format · validate · convert · runs locally

Parse JSON in PHP

How to parse a JSON string into an object and serialize (stringify) an object back to JSON in PHP. json_decode and json_encode are built into PHP. Need to clean up the JSON first? Use the formatter & validator.

Parse JSON (string → object)

$obj = json_decode($text, true);

Stringify (object → JSON string)

$text = json_encode($obj, JSON_PRETTY_PRINT);

Frequently asked questions

How do I parse JSON in PHP?

json_decode and json_encode are built into PHP. Parse with the snippet above; the result is a native object/map you can read.

How do I pretty-print JSON in PHP?

Use the stringify snippet above with indentation, or paste your JSON into the formatter on this page.