
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@trim21/php-serialize
Advanced tools
serialize and deserialize php encoded string to/from js Object/Array/Map.
npm add @trim21/php-serialize
yarn add @trim21/php-serialize
pnpm add @trim21/php-serialize
import * as php from '@trim21/php-serialize'
class User {
[php.ObjectName] = 'User'
private name: string
private age: number
constructor({ name, age }) {
this.name = name
this.age = age
}
}
php.stringify({
b: true,
a: [1, 2, 3, 'a', 100n, null, undefined],
s: 'str',
m: new Map([
[1, 2],
[2, 'b'],
]),
withObjectName: {
[php.ObjectName]: 'O',
},
})
const steel = new User({ name: 'Steel Brain', age: 17 })
const serialized = php.stringify(steel)
console.log(serialized)
const deserialized = php.parse('...', { strict: false }) // won't parse serializable class with default strict=true
export declare function parse(
item: any,
{
strict = true,
encoding = 'utf-8',
}: {
strict: boolean
encoding: 'utf-8' | 'binary'
} = {},
): string
export declare function stringify(item: string | Buffer): any
export declare const ObjectName: unique symbol
php serialized object "O:1:"A":1:{...}" will be parsed to object with symbol name { {php.ObjectName]: "A", ... }
js Object with symbol as object name { {php.ObjectName]: "A" } will be serialized to php object "O:1:"A":1:{...}"
This project is licensed under the terms of MIT License. See the License file for more info.
FAQs
PHP serialize/deserialize in Javascript
The npm package @trim21/php-serialize receives a total of 12 weekly downloads. As such, @trim21/php-serialize popularity was classified as not popular.
We found that @trim21/php-serialize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.