JS Object-Like to True Object Converter
Convert complex JavaScript structures - functions with properties, class instances, and messy objects - into clean, valid JSON. Essential for debugging jQuery/Express objects.
Input JavaScript
Result (Plain JSON)
About
In the ecosystem of JavaScript libraries, not everything is a plain object. Libraries like jQuery and Express often use Hybrid Objects - functions that double as objects with attached properties. While powerful, these structures break standard serialization tools like JSON.stringify, which ignores properties attached to functions.
This tool implements a recursive sanitization algorithm. It takes any JavaScript variable - x - and projects it onto a pure plain object space P. It strips away the prototype chain (optional), methods, and non-enumerable artifacts, leaving you with the raw data structure. It is the definitive solution for converting "Object-like" variables into true, portable JSON.
Formulas
The core logic maps an input entity E to a plain object O by iterating over the set of enumerable keys K.
Reference Data
| Input Type | Standard JSON.stringify | This Tool (toObject) |
|---|---|---|
| Plain Object | OK | OK |
| Function w/ Props | undefined (Ignored) | { props... } |
| Class Instance | Serialized | Serialized (Clean) |
| Circular Ref | Error | [Circular] (Handled) |
| Date Object | ISO String | ISO String |
| DOM Element | Error / Empty | { nodeName... } |