Fork me on GitHub

HydrateJS by nanodeath

Make javascript object serialization a snap! Have you found JSON.stringify and JSON.parse insufficient? HydrateJS may be what you're looking for. Note: designed mainly for browsers, but may have a place with server-side code as well. Untested though.

Native JSON serialization (via JSON.stringify) is convenient, but has a couple critical pitfalls:

  1. If your Javascript object is actually an instance of something other than a hash ({}), this information is lost when serializing -- so a method that may have existed pre-serialization on an object won't exist post-deserialization.
  2. Another problem is circular references -- they simply don't work (JSON will throw an exception).
  3. Lastly, object references -- i.e. two elements in an array that point to the exact same object -- aren't deserialized as one might expect.
HydrateJS aims to fix all those.


Only json2.js, but this is bundled with HydrateJS and automatically required into the page as needed.



Due to the nature of JavaScript, there are some limitations in order to make serialization work.


MIT license -- do what you want.


Max Aller (


Max Aller (


You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://