PHP Serialize Converter php
Convert between JSON and the PHP serialize() format to inspect values stored in sessions or database columns.
What this tool does
The PHP serialize() function converts arrays and objects into a storable string that carries both type and length information, which gives the format its distinctive look. The fragment s:5:"alice" is a five-character string, i:30 is the integer 30, a:2:{...} is an array with two elements, b:1 is true, and N; is null.
Values in this format sit in session files, database columns, caches, and the WordPress options table. They are awkward to read directly, but the structure is regular, so converting to JSON makes the content far easier to follow.
Conversion works in both directions and handles strings, numbers, booleans, null, indexed arrays, and associative arrays, preserving nested structures.
When to use it
Use it to inspect a serialized value stored in a database, to review WordPress options or post meta, to understand how session data is laid out, or to turn JSON into a PHP structure for test fixtures.
Input and output examples
{"name":"alice","age":30}
a:2:{s:4:"name";s:5:"alice";s:3:"age";i:30;}
s:4 is the four-character key name, and i:30 marks an integer.
a:1:{s:4:"tags";a:2:{i:0;s:1:"a";i:1;s:1:"b";}}
{"tags":["a","b"]}
Nested arrays convert too; indexed arrays record positions as i:0 and i:1.
Notes and limitations
Serialized strings record string lengths in bytes, so editing a value that contains multi-byte characters in a text editor breaks the length prefix and makes unserialization fail; always re-serialize through a tool or code. Object payloads that begin with O: depend on class definitions and carry security risk, so this tool focuses on arrays and scalar types. Passing untrusted input to unserialize on a server is a well-known remote code execution vector.
Frequently asked questions
I edited the value by hand and now it fails.
The length prefix no longer matches the actual byte count. Multi-byte characters count as several bytes each, so convert with a tool instead.
Why use serialize instead of JSON?
It preserves PHP-specific type information, but it cannot be shared with other languages and carries security risks, so JSON is the usual choice today.