PHP serializer
Serialize JSON data into PHP’s data serialization format, using UTF-8 byte lengths.
A clear answer. Here’s how.
Reads JSON as data and writes PHP serialization tags N, b, i, d, s and a. Objects are represented as associative PHP arrays, not class instances. String lengths count UTF-8 bytes, not JavaScript characters. Empty JSON objects and arrays both serialize to a:0:{}. Finite numbers only, with integers limited to the JavaScript safe range. Does not execute PHP, serialize classes or create references. Up to 200,000 characters, 20,000 values and 64 nesting levels.
How this is checked
2 reference checks passed These 2 cases were run when this page was built, on 3 December 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.
See the checks and where each expected answer comes from
Case 1
- Inputs
- Source "Café"
- Expected, and what Toolmoz gave
- text expected s:5:"Café";, Toolmoz s:5:"Café";
- Where the expected answer comes from
- UTF-8 Café is 43 61 66 C3 A9: five bytes, so the serialized string length is 5.
- Allowed difference
- exact
Case 2
- Inputs
- Source [1,true,null]
- Expected, and what Toolmoz gave
- text expected a:3:{i:0;i:1;i:1;b:1;i:2;N;}, Toolmoz a:3:{i:0;i:1;i:1;b:1;i:2;N;}
- Where the expected answer comes from
- Three entries: integer key 0 to integer 1, key 1 to boolean 1, key 2 to null.
- Allowed difference
- exact
What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- Source
- {"name":"Café","enabled":true,"tags":["web","api"]}
Example result
a:3:{s:4:"name";s:5:"Café";s:7:"enabled";b:1;s:4:"tags";a:2:{i:0;s:3:"web";i:1;s:3:"api";}}