A developer ships an AI agent on a Friday. In the demo it's flawless: the model reads a request, calls a tool, returns a clean answer the app renders perfectly.
A week later, production dashboards are full of garbage. A date is showing up as raw text. A field that was definitely there is silently gone. Under one big payload, the whole server froze for two seconds. And here's the maddening part — nothing threw an error. The model returned JSON. The code parsed it. Everything "worked."
The bug wasn't in the model, and it wasn't in the parser. It lived in the narrow gap between text and data — the place every JSON value has to cross twice. That gap is serialization, and in 2026 it has quietly become one of the most important things a JavaScript engineer can actually understand.
Why now? Because the most important conversations in modern software aren't between humans anymore. They're between models and machines — an LLM deciding which tool to call, a server answering, an agent chaining ten steps together. And every one of those conversations happens in the same format: JSON.
So let's open up the refinery and see how raw structure becomes a clean stream of bytes — and back again — without losing anything precious on the way.
JSON is not a JavaScript object
This is the misunderstanding that creates most JSON bugs, so it's worth saying plainly: JSON only looks like a JavaScript object. It isn't one.
JSON is a transport format — flat, inert text meant to travel across a network or sit on a disk. A JavaScript object is a live structure in memory that your application can read, mutate, and call methods on. They resemble each other the way a flat-packed cardboard box resembles assembled furniture: same thing in spirit, completely different states.
const user = { name: "Joao" }; // a live object in memory
typeof user; // "object"
const text = JSON.stringify(user); // '{"name":"Joao"}' — just characters
typeof text;
The V8 engine has to do active work to move between these two worlds. Until you parse it, {"name":"Joao"} is no more "an object" than the word cake is something you can eat. Hold on to that mental model — everything below is just the two machines that cross the gap: one that packs, one that unpacks.
Packing the container: JSON.stringify and the serialization funnel JSON.stringify walks the enumerable properties of a value and compresses them into a single JSON string for travel over the network or to disk. But it is not a neutral photocopier. Think of it as a funnel with three filters, and knowing what each filter does is what saves you at 2am.
Filter 1 — types that pass through cleanly: strings, numbers, booleans, arrays, and plain objects survive untouched.
Filter 2 — types that get quietly transformed: a Date is converted to an ISO 8601 string; NaN and Infinity are turned into null.
Filter 3 — types that are dropped entirely: functions, undefined, and symbols simply vanish from the output.