PHP's serialized format packs values, types, lengths, array keys, and object metadata into a compact string. This unserializer turns supported serialized values into indented JSON, making stored sessions, cache entries, and integration payloads easier to inspect without running PHP code.
The conversion is interpretive rather than lossless. PHP arrays and objects can express details that JSON cannot, and some PHP serialization features depend on application classes. Keep the original serialized value when exact reconstruction matters.
How to Use the PHP Unserializer
Decode a serialized value and review the JSON representation as you type.
- Confirm that Unserialize is selected in the Direction control.
- Paste the value into Serialized PHP string.
- Read the converted value in JSON; successful input shows Unserialized.
- Correct any reported error at the indicated byte position if the output is empty.
- Select Copy to copy the JSON result.
- Select Swap to place the result in the input and switch to Serialize mode.
How PHP Serialized Values Are Structured
PHP serialization is type-tagged. A value such as i:42; is an integer, b:1; is true, and N; is null. Strings include their UTF-8 byte length, not their displayed character count. For example, the name below contains three characters but four UTF-8 bytes:
s:4:"Zoë";
Arrays contain a declared entry count followed by key-value pairs. PHP uses one array type for both indexed lists and associative maps. This tool emits a JSON array only when the keys are sequential integers starting at zero in their original order; otherwise, it emits a JSON object. Numeric keys in that object become JSON property names.
The parser supports nulls, booleans, integers, floats, strings, arrays, standard objects, enum-case records, and references to previously parsed values. It reads the input as UTF-8 bytes and checks declared string lengths against those bytes. Unexpected types, invalid delimiters, missing data, or non-whitespace text after the first value produce an error with a byte position.
Use the PHP serializer for the reverse direction. If the source is a PHP array literal or var_export() output rather than serialize() data, use PHP to JSON instead.
How Objects, Properties, and References Become JSON
A serialized PHP object starts with O: and includes its class name and properties. The tool converts it to a JSON object with a __class property, followed by the serialized properties. It does not load the class, instantiate an object, or call constructors, destructors, or serialization hooks.
PHP encodes protected and private property visibility inside names using null-byte prefixes. The converter removes those prefixes so the names are readable. That simplification can cause collisions: two private properties from different declaring classes may end up with the same JSON key, and later duplicate keys replace earlier ones when the JSON object is formed.
The r: and R: forms can point to an earlier parsed value. JSON has no reference identity, so JSON.stringify() renders the resulting value as ordinary nested JSON rather than preserving PHP's reference semantics. Enum records using E: are shown as strings. Custom-serialized C: objects are rejected because their contents require the class's own unserialize() implementation.
These conversions are useful for inspection, not for recreating an application object graph. If class identity, property visibility, aliases, or reference behavior affects program logic, examine the value in the original PHP environment with the required classes and strict safeguards.
JSON Conversion Limits and Common Errors
Malformed string lengths are a frequent problem, especially after manually editing serialized text. The length must count encoded bytes between the quotes. Changing Zoë to another value without updating s:4 can shift the parser into the middle of the next token and lead to a later-looking delimiter error.
JSON also has a narrower numeric model. This browser implementation parses PHP integers and floats as JavaScript numbers, so integers beyond JavaScript's safe range can lose precision. PHP's NAN, INF, and -INF have no JSON number representation; the output shows them as null and displays the warning NAN and INF have no JSON form and are shown as null.
Invalid boolean values, non-integer counts, unsupported type tags, references to nonexistent earlier values, and truncated strings are rejected. The converter does not repair corrupted payloads or infer missing delimiters. Fix the producer or obtain the untouched serialized value instead of repeatedly patching a length-sensitive string by hand.
For ordinary data exchange, JSON is usually easier to inspect across languages. PHP serialization remains useful where PHP-specific types and application behavior are expected, but it is a fragile interchange format when another system does not share those assumptions.
Security and Privacy When Inspecting Serialized PHP
PHP's native unserialize() can instantiate objects and trigger application behavior, which is why PHP documentation warns against passing untrusted input to it. This browser tool uses its own parser and produces JSON; it does not execute PHP or invoke class methods. That lowers object-injection risk during inspection, but it does not prove that the source is trustworthy.
Serialized data may contain session identifiers, user details, access tokens, internal class names, or cached secrets. Processing occurs locally in the browser and the value is not uploaded by the tool. Even so, redact sensitive fields before sharing the input or copied output in tickets, chat, screenshots, or logs.
Do not feed an inspected payload into a production unserialize() call merely because this tool parsed it. Validate the source and expected structure, prefer a safer interchange format for untrusted data, and use PHP's allowed_classes option when native unserialization is genuinely required.
Frequently Asked Questions
Why does my serialized string report a byte-position error?
The parser found an unexpected type, delimiter, length, or end of input. String lengths count UTF-8 bytes, so a multibyte character or a manual edit can make the declared length incorrect. Start at the reported byte, but also check the preceding string and container counts because the original mistake may occur earlier.
Does the tool execute PHP objects or magic methods?
No. It parses supported syntax into JavaScript values and then writes JSON. It does not instantiate PHP classes or invoke methods such as __wakeup() or __unserialize(), and it rejects custom-serialized C: objects.
Why did a PHP array become a JSON object?
PHP arrays can mix integer and string keys, while JSON distinguishes arrays from objects. The tool produces a JSON array only for sequential integer keys starting at zero. Sparse, reordered, negative, or associative keys produce an object instead.
Why are NAN and INF shown as null?
JSON numbers do not include not-a-number or positive and negative infinity. JavaScript's JSON serializer converts those numeric values to null, and the tool displays a warning when it detects their PHP forms. Preserve the source if those distinctions matter.
Can I safely unserialize untrusted data in PHP after checking it here?
No. Successful parsing shows that this tool understands the syntax; it does not make native PHP unserialization safe. PHP object instantiation and application classes introduce risks that this JSON-only browser parser does not exercise.
References: PHP manual: unserialize() · PHP manual: serialize().