Deserialization

Deserialization in session replay is the reverse of serialization: rebuilding real DOM nodes from the stored data structure so the page can be rendered again inside the player. Replay quality depends on deserialization producing a document that renders the way the original did, without executing any of its code.

How it works

The rebuilder walks the serialized tree and creates each element, attribute, and text node in the replay document, restoring the id-to-node mapping (see mirror) so incremental events can find their targets. Scripts are recreated as inert placeholders so layout is preserved while execution stays impossible. The rebuilt document lives inside a sandboxed iframe (see sandboxing), which is what makes it safe to replay sessions recorded from arbitrary pages. In rrweb the rebuild logic ships in the rrweb-snapshot package alongside the serializer, so both sides share one set of rules; see the sandbox documentation for the security boundary.

Where you encounter it

Inside every player, and in headless contexts: analysis pipelines deserialize recordings without a browser using virtual DOM implementations like rrdom to inspect state programmatically. The rrdom-nodejs package provides the Node.js implementation.