Lodash _.flow() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Util

Definition

Creates a function that invokes the given functions from left to right, passing each return value to the next. Part of Lodash Util since 3.0.0 (stable — not deprecated).

Note: Only the first function receives all outer arguments. Later steps get one value. See also _.flowRight for right-to-left order.

Syntax

Call _.flow. Start with this line.

Lodash
_.flow([funcs]) or _.flow(f, g, …)
CallWhat it does
_.flow([funcs]) or _.flow(f, g, …)Primary signature.
_.flow(...)Call the util helper.

Prefer import flow from "lodash/flow" when you want a smaller bundle.

Library declarations
Lodash
_.flow([funcs]) or _.flow(f, g, …)

Parameters

ParameterDescription
funcsOptional. Functions to invoke (array and/or rest args)

Return Value

Return ValueDescription
*New composite function

Lodash Examples

Example 1 — Official: Add, Then Square

Compose _.add and a square helper left to right.

Lodash
function square(n) {
  return n * n;
}

var addSquare = _.flow([_.add, square]);
addSquare(1, 2);
// → 9
Try It Yourself

How It Works

  1. Compose. Array order is run order: add, then square.
  2. First step. _.add(1, 2) → 3.
  3. Second step. square(3) → 9.
  4. Reuse. addSquare is one named pipeline.

Example 2 — Variadic Form

Same pipeline without wrapping functions in an array.

Lodash
function square(n) {
  return n * n;
}

var addSquare = _.flow(_.add, square);
addSquare(1, 2);
// → 9
Try It Yourself

How It Works

  1. Rest args. _.add and square are listed directly.
  2. Same as array. Equivalent to _.flow([_.add, square]).
  3. Result. Still 9 for (1, 2).
  4. Style. Use whichever reads clearer in your file.

Example 3 — String Pipeline

Trim, then uppercase — a common left-to-right cleanup chain.

Lodash
var clean = _.flow(_.trim, _.toUpper);

clean("  hello  ");
// → "HELLO"
Try It Yourself

How It Works

  1. Trim. _.trim(" hello ") → "hello".
  2. Upper. _.toUpper("hello") → "HELLO".
  3. Read left→right. Matches how you describe the steps.
  4. Reuse. Call clean on any padded string.

Example 4 — flow vs flowRight

Same unary steps, opposite invoke order.

Lodash
function addOne(n) {
  return n + 1;
}
function double(n) {
  return n * 2;
}

_.flow(addOne, double)(3);
// → 8   // (3 + 1) * 2

_.flowRight(addOne, double)(3);
// → 7   // (3 * 2) + 1
Try It Yourself

How It Works

  1. flow. Left→right: addOne → double → 8.
  2. flowRight. Right→left: double → addOne → 7.
  3. Same list. Order alone changes the result.
  4. Pick. Prefer flow when you want pipeline reading order.

Example 5 — Multi-Arg First Step Only

Extra arguments reach only the first function in the chain.

Lodash
function joinPair(a, b) {
  return a + "-" + b;
}

var shout = _.flow(joinPair, _.toUpper);
shout("hi", "there");
// → "HI-THERE"
Try It Yourself

How It Works

  1. First. joinPair("hi", "there") gets both args → "hi-there".
  2. Next. _.toUpper receives that one string.
  3. Rule. Later steps must accept a single value.
  4. Tip. Need more args mid-pipeline? Use _.partial.

Browser & Runtime Support

_.flow is a Lodash Util helper since 3.0.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.0.0+

_.flow()

Available in [email protected] full builds and the lodash/flow modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 3.0+
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 support
_.flow Lodash 3.0.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import flow from "lodash/flow" for smaller bundles. Use it for fixed left-to-right transform pipelines.

Frequently Asked Questions

_.flow(...funcs) returns a new function. It runs the first function with your arguments, then each next function with the previous return value — left to right. Official: _.flow([_.add, square])(1, 2) → 9.
As an array (_.flow([f, g])) or as separate arguments (_.flow(f, g)). Both forms work in Lodash 4.
Only the first function. Later steps receive one value — the previous return. Keep steps after the first unary.
flow is left to right (f then g). flowRight is right to left (g then f) — like mathematical compose.
Yes. The composed function uses the this binding of the created function when invoking each step.
Use import flow from "lodash/flow" or require("lodash/flow"). Full build: import _ from "lodash" then _.flow.

Next: _.flowRight()

Compose the same way, but invoke functions from right to left.

_.flowRight() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful