JSON → PHP serialize()

Convert JSON into PHP's serialize() format so unserialize() can read it. Byte-accurate string lengths and preserved key order. Runs entirely in your browser, no server, no sign-up.

PHP serialized string

What this tool does

Convert JSON into the string format produced by PHP's serialize(), so a PHP app's unserialize() can read it back. It runs entirely in your browser — nothing is sent to a server, it works offline, and there is no sign-up.

This is handy when a non-PHP system (Node, Python, a shell script) has to write a value that a PHP application will read — a session payload, a cached object, or a WordPress wp_options row stored in PHP's serialized format.

The format

PHP's serialized format is compact and type-tagged. Each value carries its type:

JSONPHP serialize()
nullN;
true / falseb:1; / b:0;
42i:42;
3.5d:3.5;
"hi"s:2:"hi";
[1, 2, 3]a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}
{"name": "Al"}a:1:{s:4:"name";s:2:"Al";}

Notes that trip people up

Examples

JSON inputPHP output
{"name": "Al", "age": 30}a:2:{s:4:"name";s:2:"Al";s:3:"age";i:30;}
[true, null, 1.5]a:3:{i:0;b:1;i:1;N;i:2;d:1.5;}
"café"s:5:"café";
{"items": [1, 2]}a:1:{s:5:"items";a:2:{i:0;i:1;i:1;i:2;}}

FAQ

Is it free and private?

Yes — your input never leaves your device, and the page keeps working offline once it has loaded.

Can I unserialize the output in PHP?

Yes. Paste the result into unserialize($string) in any PHP 7+ install and you get the equivalent array or scalar back.

Why does my string length look "too big"?

Because PHP counts string length in bytes, not characters — accented and non-Latin text takes more than one byte per character. The byte count here is what unserialize() requires.

Does it handle nested arrays and objects?

Yes, to any depth — nested arrays and objects are serialized recursively.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool php-serialize '{"name": "Al", "age": 30}'

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/php-serialize/?json=%7B%22name%22%3A%20%22Al%22%2C%20%22age%22%3A%2030%7D

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.