JavaScript Object.fromEntries() Method

Definition
Object.fromEntries(iterable) builds a new object from a list of [key, value] pairs. It is the reverse of Object.entries() for plain objects.
The iterable can be an array of pairs, a Map, or any other iterable that yields two-item entries.
Syntax
Call Object.fromEntries() like this. Start with this line.
Object.fromEntries(iterable)
| Call | What it does |
|---|
Object.fromEntries(iterable) | Creates a new object from [key, value] pairs. |
Built into JavaScript. Call on Object — no import required.
Library declarations
Object.fromEntries(iterable)
fromEntries(entries: Iterable<readonly any[]>): any;
Parameters
| Parameter | Description |
|---|
| iterable | Required. An iterable of entries, where each entry is a [key, value] pair. |
Return Value
| Return Value | Description |
|---|
| object | A new plain object with a property for each pair. |
JavaScript Examples
Example 1 — Basic Use
Turn an array of pairs into a plain object.
var pairs = [
["name", "Ada"],
["role", "admin"]
];
console.log(JSON.stringify(Object.fromEntries(pairs)));
// {"name":"Ada","role":"admin"}
{"name":"Ada","role":"admin"}How It Works
- Prepare pairs. Each inner array is one key and one value.
- Build the object.
fromEntries creates a new object from those pairs. - Keys become properties.
name and role are normal own properties.
Example 2 — Map to Object
Convert a Map into a plain object in one step.
var map = new Map([
["a", 1],
["b", 2]
]);
console.log(JSON.stringify(Object.fromEntries(map))); // {"a":1,"b":2}
How It Works
- Start with a Map. A
Map already stores entries as key/value pairs. - Pass the Map.
fromEntries reads those entries because a Map is iterable. - Get a plain object. The result is a normal object you can JSON-stringify.
Example 3 — Filter Then Rebuild
Combine entries, filter, and fromEntries to make a smaller object.
var obj = { x: 1, y: 2, z: 3 };
var filtered = Object.fromEntries(
Object.entries(obj).filter(function (pair) {
return pair[1] > 1;
})
);
console.log(JSON.stringify(filtered)); // {"y":2,"z":3}
How It Works
- To pairs.
Object.entries(obj) gives every key and value. - Keep some pairs. The filter keeps only values greater than
1. - Back to an object.
fromEntries rebuilds the object with y and z.
Compatibility
Browser & Runtime Support
Object.fromEntries() arrived in ES2019 and is Baseline Widely available in modern browsers and Node.js.
✓ Baseline · ES2019
Object.fromEntries()
Supported in Chrome 73+, Firefox 63+, Safari 12.1+, Edge 79+, and Node.js 12+. Use a polyfill only for very old engines.
96% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full supportObject.fromEntries Excellent
Bottom line: Safe for modern web apps and current Node LTS. Pair it with Object.entries() for transform pipelines.
Frequently Asked Questions
It creates a new plain object from an iterable of [key, value] pairs, such as an array of pairs or a Map.
Yes for plain objects. Object.entries(obj) makes pairs, and Object.fromEntries(pairs) builds an object again.
Yes. A Map is iterable, so Object.fromEntries(map) turns it into a plain object.
The later pair overwrites the earlier one. No error is thrown.
No. It returns a new object. The original iterable is left alone.
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful