User Rating 0.0
Total Usage 0 times
Supports object literals with getters, setters, and methods.

      
Presets:
Is this tool helpful?

Your feedback helps us improve.

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.

object descriptor property descriptor Object.defineProperties JavaScript tool getter setter object conversion descriptor map merge descriptors

Formulas

The conversion follows the ECMAScript specification for property descriptor extraction. For each own property key k on source object O:

desc = Object.getOwnPropertyDescriptor(O, k)

The result is a descriptor record. A data descriptor satisfies:

desc { value, writable, enumerable, configurable }

An accessor descriptor satisfies:

desc { get, set, enumerable, configurable }

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 KeyTypeDefaultApplies ToDescription
valueAnyundefinedDataThe value associated with the property
writableBooleanFALSEDataWhether the value can be changed with assignment
getFunctionundefinedAccessorGetter function called on property access
setFunctionundefinedAccessorSetter function called on property assignment
enumerableBooleanFALSEBothWhether property shows in for...in loops
configurableBooleanFALSEBothWhether property can be deleted or its descriptor changed
Object.definePropertyMethod - - Defines a single property descriptor on an object
Object.definePropertiesMethod - - Defines multiple property descriptors at once
Object.createMethod - - Creates object with prototype and optional descriptors
Object.getOwnPropertyDescriptorMethod - - Returns descriptor for a single own property
Object.getOwnPropertyDescriptorsMethod - - Returns all own property descriptors (ES2017)
Object.getOwnPropertyNamesMethod - - Returns array of all own property names (including non-enumerable)
__proto__Accessor - PrototypeLegacy accessor for the internal [[Prototype]] link
Object.getPrototypeOfMethod - - Standard way to read [[Prototype]]
Data DescriptorCategory - - Has value and writable. Cannot have get/set.
Accessor DescriptorCategory - - Has get and/or set. Cannot have value/writable.

Frequently Asked Questions

Accessor properties (those defined with get/set syntax) are preserved in the output descriptor as get and set function references. The tool serializes them as their function source code. When you use this descriptor with Object.defineProperties(), the getter and setter will be re-created. Note: if your getter references external closure variables, those references will break in the serialized output since the closure scope cannot be captured.
Properties defined via object literal syntax ({ key: value }) automatically receive writable: true, enumerable: true, and configurable: true per the ECMAScript specification (Section 14.3.9). This differs from Object.defineProperty(), which defaults all flags to false. The tool reports the actual runtime descriptor, not the syntax-level definition.
By default, only own properties (those directly on the object) are extracted. Enable the "Include prototype properties" toggle to walk the prototype chain via Object.getPrototypeOf() and include inherited properties. Properties from Object.prototype (toString, hasOwnProperty, etc.) are excluded to avoid pollution.
The input is evaluated as a JavaScript expression using new Function('return (' + input + ')')() inside a try-catch block. This is safer than eval() because it restricts execution to a single expression (no statements, no variable declarations, no side effects beyond the object creation). However, any functions or getters in your object literal will execute during parsing. Do not paste untrusted code.
JS Output produces valid JavaScript object literal syntax, preserving function bodies for getters, setters, and method values. JSON Output uses JSON.stringify, which discards all function values (they become undefined/omitted) since JSON cannot represent functions. Use JS Output when you need to feed the result to Object.defineProperties(). Use JSON Output only for data-only objects.
Yes. Pass the descriptor map to Object.defineProperties({}, descriptorMap) or Object.create(proto, descriptorMap). The resulting object will have the same property characteristics (including accessor properties and flag states) as the original source object.