Object to Descriptor Converter
Convert JavaScript objects to property descriptor maps. Extract getters, setters, value, writable, enumerable, configurable flags for Object.defineProperties().
About
JavaScript property descriptors define the metadata of object keys: value, writable, enumerable, configurable, and accessor pairs (get/set). When merging objects via Object.defineProperties, you need a descriptor map, not a plain object. Passing a raw object loses getter/setter semantics and non-default flags. This tool extracts the full descriptor map from any JavaScript object literal, preserving accessor properties and flag states. The output is directly usable with Object.defineProperties or Object.create. This tool approximates runtime behavior by parsing object literals in a sandboxed expression context. Arrow functions, closures referencing external scope, and symbols are not supported.
Formulas
The conversion follows the ECMAScript specification for property descriptor extraction. For each own property key k on source object O:
The result is a descriptor record. A data descriptor satisfies:
An accessor descriptor satisfies:
A descriptor cannot be both data and accessor simultaneously. If get or set is present, value and writable must be absent, and vice versa. For object literals defined with { key: val } syntax, the runtime assigns defaults: writable = TRUE, enumerable = TRUE, configurable = TRUE. Properties created via Object.defineProperty default all flags to FALSE.
Where O = source object, k = property key (string), desc = resulting descriptor record.
Reference Data
| Descriptor Key | Type | Default | Applies To | Description |
|---|---|---|---|---|
| value | Any | undefined | Data | The value associated with the property |
| writable | Boolean | FALSE | Data | Whether the value can be changed with assignment |
| get | Function | undefined | Accessor | Getter function called on property access |
| set | Function | undefined | Accessor | Setter function called on property assignment |
| enumerable | Boolean | FALSE | Both | Whether property shows in for...in loops |
| configurable | Boolean | FALSE | Both | Whether property can be deleted or its descriptor changed |
| Object.defineProperty | Method | - | - | Defines a single property descriptor on an object |
| Object.defineProperties | Method | - | - | Defines multiple property descriptors at once |
| Object.create | Method | - | - | Creates object with prototype and optional descriptors |
| Object.getOwnPropertyDescriptor | Method | - | - | Returns descriptor for a single own property |
| Object.getOwnPropertyDescriptors | Method | - | - | Returns all own property descriptors (ES2017) |
| Object.getOwnPropertyNames | Method | - | - | Returns array of all own property names (including non-enumerable) |
| __proto__ | Accessor | - | Prototype | Legacy accessor for the internal [[Prototype]] link |
| Object.getPrototypeOf | Method | - | - | Standard way to read [[Prototype]] |
| Data Descriptor | Category | - | - | Has value and writable. Cannot have get/set. |
| Accessor Descriptor | Category | - | - | Has get and/or set. Cannot have value/writable. |