Serialize & Unserialize PHP Online — Free PHP Serializer

Serialize and unserialize your PHP data instantly with our free online PHP serialization tool. Convert your JSON data structures to PHP serialization format, or vice versa. Fast and secure processing, directly in your browser.

Loading...
PHP Serialize
Using PHP's serialize() function to convert data into compact binary format

Basic example

Input JSON data

{ "name": "FastMinify", "version": "1.0.0", "features": ["minify", "compress", "optimize"] }

Serialized PHP data

a:3:{s:4:"name";s:10:"FastMinify";s:7:"version";s:5:"1.0.0";s:8:"features";a:3:{i:0;s:6:"minify";i:1;s:8:"compress";i:2;s:8:"optimize";}}

Serialization options

Include Null Values
Includes properties with null values in serialization

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 serialization
Remove Empty Arrays
Removes empty arrays before serialization

Comparison with/without option:

Original code
$data = [ 'name' => 'test', 'items' => [], 'active' => true, 'tags' => [] ];
With removeEmptyArrays: true
a:2:{s:4:"name";s:4:"test";s:6:"active";b:1;}
With removeEmptyArrays: false
a:4:{s:4:"name";s:4:"test";s:5:"items";a:0:{};s:6:"active";b:1;s:4:"tags";a:0:{}}
Difference
Empty arrays are removed de la sérialisation
Remove Empty Objects
Removes empty objects before serialization

Comparison with/without option:

Original code
$data = [ 'name' => 'test', 'config' => (object)[], 'active' => true, 'settings' => (object)[] ];
With removeEmptyObjects: true
a:2:{s:4:"name";s:4:"test";s:6:"active";b:1;}
With removeEmptyObjects: false
a:4:{s:4:"name";s:4:"test";s:6:"config";O:8:"stdClass":0:{};s:6:"active";b:1;s:8:"settings";O:8:"stdClass":0:{}}
Difference
Empty objects are removed before serialization
Sort Keys
Sorts associative array keys alphabetically

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
Array keys are sorted alphabetically

Other minification tools