PHP Serialize / Unserialize.
Convert PHP serialize() strings to JSON and JSON back to serialized PHP, objects and enums included.
Runs in your browserAbout PHP Serialize / Unserialize
PHP Serialize / Unserialize converts the compact format produced by PHP's serialize() into readable JSON and turns JSON back into a serialized string. You meet this format in WordPress options and post meta, Laravel cache and queue payloads, session files, Magento and Drupal tables, and legacy APIs. Paste a value such as a:1:{s:4:"name";s:3:"Ann";} and you get {"name": "Ann"}. Lists with keys 0, 1, 2… become JSON arrays, other arrays become objects with their original key order, and objects keep their class name in a "__class" member. Protected and private properties keep PHP's internal names (with \u0000 markers), so the conversion is lossless and serializing the JSON again gives the exact original string. Enums (PHP 8.1+), custom-serialized C: objects and references are represented with "__enum", "__serialized" and "__reference" members, and integers larger than JavaScript can hold are kept exact. The most common problem with serialized data is a wrong length: s:5: counts UTF-8 bytes, not characters, so a search-and-replace in a database dump or a charset conversion corrupts every string it touches and unserialize() fails. The error message here points at the broken string, and the Repair string lengths switch recalculates them so you can recover the data. Unlike PHP's own unserialize(), this tool never instantiates classes or runs __wakeup, so pasting untrusted data is safe. When serializing, JSON numbers with a fraction become d: floats and whole numbers become i: integers. Everything runs in your browser.
How to Use
- Paste a serialized PHP string, or JSON if you want to serialize.
- Pick unserialize or serialize; turn on Repair string lengths for corrupted data.
- Copy the JSON or the serialized result.
Frequently Asked Questions
Why does unserialize() fail after a database search-and-replace?
Each string stores its length in bytes (s:12:"…"). Replacing a URL with a longer or shorter one, or converting the charset, changes the bytes but not the stored length. Turn on Repair string lengths to recalculate them.
How are PHP objects shown in JSON?
As an object with a "__class" member followed by the properties. Protected properties appear as "\u0000*\u0000name" and private ones as "\u0000Class\u0000name", exactly as PHP stores them, so serializing back gives the original string.
Is it safe to paste untrusted serialized data?
Yes. This tool only parses text; it never creates PHP objects or calls magic methods, so the object-injection attacks that make unserialize() dangerous in PHP do not apply.
Is my data uploaded?
No. Parsing and serializing happen in your browser.
Related Tools
Pretty print, minify, and validate JSON.
Decode MessagePack bytes to JSON and encode JSON to MessagePack, with binary, ext and timestamps.
Escape and unescape strings for different formats.
Encode and decode Base64 strings.
Convert URL query strings to JSON (nested brackets, arrays) and JSON objects back to query strings.
Decode, inspect, and verify JSON Web Tokens.