Skip to content
BENIBIX Learn

Serialization

Development📄 Files & FormatsData Formats

Also known as Serialisation, Serialize, Deserialization, Marshalling

Turning data into text or bytes to save or send. Reading it back builds it again.

Think of it like

Think of it like packing a toy flat in a box to post it. Your friend opens it and builds it again.

Example

Jack's game saves the player's level and score as JSON. Next time, it reads the file and puts the player back where they were.

Why it matters

Memory is wiped when a program stops. This is how data lasts, and how it moves between programs.

Definition

Serialization turns data in a program's memory into a form you can save or send. Usually that form is text, like JSON, or compact bytes. The other side reads it back and rebuilds the data. That step is called deserialization. Every API call and every saved game relies on it. Both sides must agree on the format.

Example code

javascript
JSON.stringify({ name: "Emma", age: 36 })
// '{"name":"Emma","age":36}'
The object in memory becomes one line of text that can be saved or sent.
Emma's record leaves memory as text or bytes. The other program builds it back the same.

Common mistake

Reading in data from a stranger with no check. In some formats, bad data can make your app run an attacker's code.

Key takeaways

  1. 1
    Memory to bytes. Data becomes text or bytes.
  2. 2
    Both ways. Reading it back is called deserialization.
  3. 3
    Agree on a format. The sender and the reader must match.

Learn it properly