Toolstia / PHP serialize and unserialize
PHP serialize and unserialize
WordPress and other PHP software store arrays and objects as serialized text, such as a:2:{s:4:"name";s:3:"Ada";...}. It is hard to read and easy to break. Paste it here to see it as JSON, or turn JSON into a serialized string.
WordPress stores many settings as serialized text. If you edit one by hand, the length numbers must match exactly, so build the new string with this tool.
How it works
- Choose a direction.
- Paste a serialized string or JSON.
- Copy the result.
Why editing by hand breaks things
Each string carries its length, as in s:5:"hello". If you change the text but not the number, PHP rejects the whole value. Convert to JSON, edit, convert back, and the lengths are right.
Supported types
Strings, integers, floats, booleans, null, arrays and objects. Objects are shown with a __class key holding the class name. Private and protected property markers are removed from names.
Lists and maps
A PHP array with keys 0, 1, 2... becomes a JSON list. Other arrays become JSON objects.
Limits
References and custom serialization formats are not supported, and an object written back from JSON becomes a plain array, not a class instance.
Questions
Is it safe to unserialize untrusted data?
Here it only reads the text as data and never runs code. In PHP itself, unserializing untrusted input can be dangerous.
Why does it count bytes, not characters?
PHP string lengths are in bytes, so a letter like é counts as 2.
Is anything uploaded?
No. Your data stays in your browser and is never sent anywhere.