PHP Serialize
runs in your browserno sign-upfree
Convert a PHP array (array() or [ ]) or JSON into a PHP serialize() string — with correct UTF-8 byte lengths, floats and stdClass objects.
Converted to serialize() output · 223 bytes
About this tool
PHP Serialize turns a PHP array — written with array() or short [ ] syntax — or a JSON object into the string PHP’s serialize() would produce, ready to store in a database, a WordPress option or a test fixture. String lengths are counted in UTF-8 bytes like PHP, whole floats such as 2.0 stay floats (d:2;), and (object) arrays become stdClass objects.
How to use
- Paste a PHP array (with or without $var = … ;) or JSON.
- For JSON, choose whether objects become arrays or stdClass objects.
- Copy the serialized string or download it.
FAQ
Does it give the same result as PHP’s serialize()?
Yes, for arrays, strings, integers, floats, booleans, null and stdClass objects — checked against real PHP 8 output, including byte lengths for non-English text and emoji.
JSON objects: arrays or stdClass?
By default JSON objects become associative arrays, like json_decode($json, true) — what most code and WordPress expect. Tick "JSON objects → stdClass" to get objects instead, like plain json_decode($json).
Can I use variables or function calls in the array?
No — only literal values (strings, numbers, true/false/null, nested arrays and (object) casts), because the tool reads the code without running it.
How do I read serialized data?
Use PHP Unserialize to see it as print_r(), var_dump(), var_export(), a PHP array or JSON.