PHP Serialize Online — Free Serializer Tool

Convert JSON or PHP array syntax into PHP serialize() format, for WordPress-style arrays, Laravel cache values or session data. Everything runs in your browser and no data is sent to a server.

Loading…
PHP Serialize
Convert JSON or PHP array syntax into PHP serialize() format in your browser.

Basic example

Input JSON data

{ "app": "FastMinify", "version": "2.1.0", "features": { "minify": true, "0": "legacy", "1": "modern" }, "flags": [true, false, null], "metadata": { "author": "Team", "license": "MIT" } }

Serialized PHP data

a:5:{s:3:"app";s:10:"FastMinify";s:7:"version";s:5:"2.1.0";s:8:"features";a:3:{s:1:"0";s:6:"legacy";s:1:"1";s:6:"modern";s:6:"minify";b:1;}s:5:"flags";a:3:{i:0;b:1;i:1;b:0;i:2;N;}s:8:"metadata";a:2:{s:6:"author";s:4:"Team";s:7:"license";s:3:"MIT";}}

How to Serialize PHP Data Online

Paste JSON or PHP array syntax in the left editor. Leave Input format on Auto unless detection picks the wrong parser, then select Serialize. Everything runs in your browser. The output uses array and scalar tokens only (a:, s:, i:, d:, b:, N;). Nested JSON objects become PHP arrays, never O: class objects or R: references. String lengths count UTF-8 bytes, as PHP does: café gives s:5. To decode an existing a:3:{…} string, use PHP Unserialize.

PHP Serialize vs JSON (When to Use Each)

You edit JSON here; PHP serialize() is the compact string many PHP apps store (WordPress options, Laravel cache, sessions). Use JSON for APIs and other languages, and this page when a PHP stack already expects serialize() output. The encoder keeps no class names or references. To pretty-print or minify the JSON side, use the JSON tool.

Serialization options

Input format
Auto mode tells JSON from PHP array syntax (`$data = …`, `array(…)`, `=>`). Pick a format yourself when detection guesses wrong.
JSON
{"name": "test"}
PHP array
$data = ['name' => 'test'];

Both give the same serialize() output:

a:1:{s:4:"name";s:4:"test";}
Include null values
On by default: properties set to null stay in the output. When off, null values are removed from objects and lists. The arrays that held them stay, even if they end up empty.

Comparison with/without option:

Original code
$data = [ 'name' => 'test', 'value' => null, 'active' => true, 'count' => null ];
With includeNullValues: true
a:4:{s:4:"name";s:4:"test";s:5:"value";N;s:6:"active";b:1;s:5:"count";N;}
With includeNullValues: false
a:2:{s:4:"name";s:4:"test";s:6:"active";b:1;}
Difference
Properties with null values are included in the output
Remove empty arrays
Off by default. Removes empty arrays ([]) at every depth, including inside lists.

Comparison with/without option:

Original code
$data = [ 'items' => [], 'name' => 'test', 'active' => true ];
With removeEmptyArrays: true
a:2:{s:4:"name";s:4:"test";s:6:"active";b:1;}
With removeEmptyArrays: false
a:3:{s:5:"items";a:0:{}s:4:"name";s:4:"test";s:6:"active";b:1;}
Difference
Empty arrays are removed from the result
Remove empty objects
Off by default. Removes keys whose value is an empty object ({}), at every depth, including inside lists.

Comparison with/without option:

Original code
{ "config": {}, "name": "test", "active": true, "settings": {} }
With removeEmptyObjects: true
a:2:{s:4:"name";s:4:"test";s:6:"active";b:1;}
With removeEmptyObjects: false
a:4:{s:6:"config";a:0:{}s:4:"name";s:4:"test";s:6:"active";b:1;s:8:"settings";a:0:{}}
Difference
Empty objects are removed from the result
Sort keys
Off by default. Sorts object keys at every depth by character code, so A–Z comes before a–z. Lists keep their order.

Comparison with/without option:

Original code
$data = [ 'zebra' => 'striped', 'apple' => 'red', 'banana' => 'yellow' ];
With sortKeys: true
a:3:{s:5:"apple";s:3:"red";s:6:"banana";s:6:"yellow";s:5:"zebra";s:7:"striped";}
With sortKeys: false
a:3:{s:5:"zebra";s:7:"striped";s:5:"apple";s:3:"red";s:6:"banana";s:6:"yellow";}
Difference
Object keys are sorted alphabetically in the output

Decode a serialized string with PHP Unserialize

What this serializer does

Serialize JSON or PHP array syntax into serialize() strings for WordPress-style arrays and Laravel caches, entirely in your browser.

JSON or PHP array → serialize()

Convert JSON or PHP array syntax into PHP serialize() format: arrays, strings, numbers, booleans and null. JSON objects become PHP arrays.

WordPress- and Laravel-shaped arrays

Use it when you edit data as JSON or a PHP array and need serialize() output for options, cache values or session arrays.

Decode a serialized string

Paste a PHP serialized string into the PHP Unserialize tool to decode it to readable JSON or PHP array syntax.

PHP Serialize FAQ

Serialize JSON for PHP in your browser

Why serialize PHP data?

PHP stacks store arrays as a compact serialize() string in databases, sessions or caches. This page turns JSON or PHP array syntax into those array and scalar tokens. It does not emit class objects or references.

How does PHP serialization work?

PHP's serialize() writes a type prefix before each value and a length before each string. The string hello becomes s:5:"hello";, where s is the type and 5 the length. Arrays are serialized recursively. Here, JSON objects become a: arrays, not O: class objects.

Can I serialize PHP arrays and objects?

Arrays yes, class objects no. Paste JSON or PHP array syntax with indexed or associative arrays, nested maps, strings, numbers, booleans and null. Nested JSON objects come out as PHP arrays. The tool never produces PHP class objects O: or references R:.

What is the difference between PHP serialize and JSON?

JSON works across languages; serialize() is the storage format many PHP apps use. Encode JSON or a PHP array here, and decode a serialized string with PHP Unserialize.

Is my data processed securely?

Yes. Serialization runs entirely in your browser with JavaScript. No payload is sent to FastMinify servers.

Where do I decode a serialized string?

Open PHP Unserialize. That page decodes serialized PHP into readable JSON or PHP array syntax.

Verify it yourself

FastMinify processes your input in the browser. Inspect the network panel or read our validation gate to confirm nothing leaves your device.

Serialize and deserialize PHP data structures beside JSON workflows.