A black and white infrared photo of the Gothic Revival-style Catholic Cathedral of Saint Stephen
Saint Stephen's Cathedral, 950nm infrared filter Download

PHP Serialised Data Viewer

I made a tiny client-side app that parses PHP serialised data using JavaScript and displays it in a nice tree structure. You can also view/copy the result as JSON.

If you work with WordPress enough, eventually you’ll come across PHP values that have been stored in the database. These values are serialised using PHP’s serialize() function.

Most of the time I can see what’s going on with simple structures — like arrays of strings — but anything more complex and I find myself copying the value into my text editor to add some much-needed line breaks in an effort to untangle all that verbosity.

You might be tempted to pull up an interactive PHP session in your console and paste something like var_dump( unserialize( ... ) ), but that’s probably unwise if you don’t trust the source.

So I made a data viewer that runs entirely in the browser. It’s pretty bare-bones, but it does what I need it to.

While building it I had to write a parser for these serialised values. A couple of parsers already exist in this space, but they each lacked some feature I wanted (private properties, multi-byte strings, etc). PHP’s serialize() function doesn’t have an official spec to reference, so I used the handy Kaitai Struct spec instead.