Skip to content

How to Use Serialize & Unserialize

Unserialize PHP data into print_r, var_dump, var_export, JSON or tree views, turn JSON into PHP serialize format, and repair broken string lengths.

About this tool

PHP's serialize() format stores arrays and objects as strings, and you often find it in WordPress options, sessions and cache tables. Paste PHP serialized data, JSON, or either one Base64 or URL encoded, and the input type is detected for you. View the result the way PHP would print it (print_r, var_dump or var_export), as a collapsible Krumo tree, as dBug-style nested tables, as JSON, or serialized again. String lengths are counted in UTF-8 bytes exactly like PHP, and lengths broken by a search-and-replace are repaired automatically.

How to use Serialize & Unserialize

  1. Paste your data, or load the PHP, JSON or broken example. The input type is detected automatically.
  2. Pick an output view: print_r, var_dump, var_export, Krumo tree, dBug tables, JSON, serialize or Base64.
  3. Copy or download the result, or use it as the new input.

Worked example

a:1:{s:3:"url";s:19:"https://toolzhive.com";} fails in PHP because the URL is 21 bytes, not 19. The tool fixes the length; choose the serialize view to copy the repaired string.

Why does unserialize() fail after a search-and-replace?

Serialized strings store their length. Replacing text changes the length without updating it, which breaks the data. This tool recalculates the lengths so the data loads again.

How are PHP objects shown?

The print_r, var_dump and var_export views show objects exactly as PHP would, including protected and private properties. In JSON, objects get a "__class" key holding the class name.

Can I convert JSON to PHP serialized data?

Yes. Paste JSON and choose the serialize view. JSON objects become associative arrays, or stdClass objects if you tick the option.

Is it safe to unserialize untrusted data?

This tool only parses text and never runs code, so it is safe to use here. In PHP, never call unserialize() on untrusted input; use JSON instead.

Put this guide into practice

Explore Coding Tools · More practical guides

Accessibility Menu

Personalize your experience. Open with Ctrl+U (Option+U on Mac). Preferences stay in this browser when storage is available.

Move / Hide Widget

Restore at any time with Ctrl+U (Option+U on Mac).

Accessibility statement and help