PHP Serialize ⇄ JSON Converter

Convert PHP serialize() output to indented JSON and back — every scalar type plus arrays, which become a JSON array or a JSON object depending on their keys.

36 characters · 36 bytes in UTF-8

Result: 4 lines, 30 characters
Output
{
  "0": 42,
  "name": "Ada"
}

Convert PHP serialize() output to JSON and back

Paste the output of PHP serialize() and get clean, indented JSON, or flip the direction to turn JSON into a PHP serialized string. The parser understands every scalar PHP emits — N (null), b (boolean), i (integer), d (float) and s (string) — plus a arrays nested to any depth. A PHP array whose keys are exactly 0,1,2,… becomes a JSON array; any other array becomes a JSON object, and when you convert back, numeric-looking object keys are re-cast to integer keys exactly as PHP does. For an array or an object, the View menu also offers http_build_query, the query string PHP makes of the same value — nulls left out, true and false as 1 and 0, nested keys in encoded brackets, and only an object’s public properties — and a line under the input box counts its characters and its UTF-8 bytes side by side, since the N in s:N counts bytes. Everything runs in your browser, so serialized session data never leaves your device.

Why inspect serialized data

PHP stores serialized values in many of the places you end up debugging: $_SESSION files, remember-me and framework cookies, the wp_options table in WordPress, Laravel and Symfony cache entries, and queued job payloads. A raw string like a:2:{s:4:"name";s:3:"Ada";i:0;i:42;} is hard to read at a glance — converting it to JSON shows the structure instantly, and converting JSON back lets you craft or patch a serialized value by hand. Because the length in s:N:"…" counts bytes and the content is not escaped, this tool reads strings that contain quotes or multi-byte UTF-8 correctly where a naive split would fail.

Frequently asked questions

What is PHP serialize() format?

It is the compact text format PHP uses to store a value as a string, such as a:2:{s:4:"name";s:3:"Ada";i:0;i:42;}. Each part is tagged by type — s for string, i for integer, a for array — with lengths and counts so PHP can rebuild the exact value with unserialize().

How does a PHP array become JSON?

An array with sequential integer keys 0,1,2,… becomes a JSON array. Any other array — string keys, or gaps in the numbers — becomes a JSON object. Converting back, an object key that looks like a plain integer is turned into an integer array key, matching PHP behaviour.

Can it read serialized objects, or show the value the way PHP prints it?

Yes. Serialized objects are read, with their protected and private property names decoded, and the View menu shows the value as JSON, print_r, var_dump or var_export.

Can I fold the structure open like a tree, or see each value’s PHP type?

Yes. Pick tree in the View menu and the unserialized value is drawn as folds: each array and object is a fold whose summary names its PHP type and element count the way var_dump writes them, the outer levels start open and deeper ones open on a click, and every leaf carries its type too — so a float stays visibly a float where JSON would print a plain number. The var_dump view prints the same types and counts as text. In the tree view, Copy and Download still carry the whole value as JSON.

Can I see the query string PHP would build, or check a string’s byte length?

Yes. When the value is an array or an object, the View menu offers http_build_query, written as PHP writes it: urlencode() escaping, nested keys in encoded brackets, nulls left out, true and false as 1 and 0, and only an object’s public properties. And a line under the input box counts characters and UTF-8 bytes side by side — the bytes are what the N in s:N counts, so a Korean string’s N is about three times its length.