A helper that builds a new object from a list of [key, value] pairs. Each pair becomes one property, and if a key repeats, the rightmost pair wins. It has been part of Ramda List since v0.3.0 (stable, not deprecated, experimental, or non-standard).
Why not the native method?Object.fromEntries() does the same job but needs ES2019. R.fromPairs works on older engines too, and it is a plain one-argument function that fits straight into R.pipe, usually right after R.toPairs.
Syntax
Call R.fromPairs. Start with this line.
Ramda
R.fromPairs(pairs)
Call
What it does
R.fromPairs(pairs)
Primary signature.
R.fromPairs(...)
Call the list helper.
Prefer import { fromPairs } from "ramda" when you want a named import.
Values stay strings."2" is text. For real URLs with encoded characters, use the browser’s URLSearchParams.
Compatibility
Browser & Runtime Support
R.fromPairs has been a Ramda List helper since v0.3.0. It uses a plain loop with property assignment, so it runs anywhere Ramda runs, including engines without the ES2019 Object.fromEntries. In the browser, load it from a CDN or a bundler. In Node.js, Bun, or Deno, run npm install ramda.
✓ Stable · Ramda 0.3.0+
R.fromPairs()
Support depends on the Ramda version you load, not on a browser feature. Your own code must also be valid in that runtime. For example, arrow functions and destructuring need an ES2015 engine.
100%Modern browsers & runtimes
Google ChromeModern versions · Desktop & Mobile
Full support
Mozilla FirefoxModern versions · Desktop & Mobile
Full support
Apple SafariModern versions · macOS & iOS
Full support
Microsoft EdgeChromium-based
Full support
OperaModern versions
Full support
Samsung InternetModern versions · Android
Full support
Android WebViewModern WebView
Full support
Internet ExplorerNot a target for current Ramda releases
Legacy
Node.jsMaintained LTS · npm install ramda
Supported
Bunimport from "ramda"
Supported
Denoimport from "npm:ramda"
Supported
R.fromPairsRamda 0.3.0+
Bottom line: Safe for production in any modern browser or JavaScript runtime once Ramda is loaded. The labs on this page use [email protected] from a CDN.
Frequently Asked Questions
R.fromPairs(pairs) builds a new object from a list of [key, value] pairs. Docs sample: R.fromPairs([['a', 1], ['b', 2], ['c', 3]]) //=> {a: 1, b: 2, c: 3}.
The rightmost pair wins. R.fromPairs([['a', 1], ['a', 2]]) gives {a: 2}. No error or warning is raised, so remove duplicates first if they matter.
Both turn pairs into an object. Object.fromEntries is native (ES2019) and accepts any iterable, including a Map. R.fromPairs reads an array-like list by index, works on older engines, and is a curried function that fits into R.pipe.
R.fromPairs takes one list of pairs: [['a', 1], ['b', 2]]. R.zipObj takes two separate lists, one of keys and one of values: R.zipObj(['a', 'b'], [1, 2]). Both return {a: 1, b: 2}.
Use R.toPairs(obj). R.fromPairs(R.toPairs(obj)) rebuilds a shallow copy of the object's own enumerable properties, which makes toPairs, map or filter, then fromPairs a common way to transform objects.
No. R.fromPairs has been part of Ramda since v0.3.0 and is stable. It is not deprecated, experimental, or non-standard.