Swap Lodash for es-toolkit for leaner, faster utils

8/19/2025

#typescript#performance
Swap Lodash for es-toolkit for leaner, faster utils

Looking to slim down your bundle and speed up utility functions?
Meet es-toolkit — a modern, lightweight replacement for Lodash.

Simply swap imports like this:

// old Lodash import
import { pick } from 'lodash-es';
// new es-toolkit import
import { pick } from 'es-toolkit';

Why you'll love es-toolkit:

  • Tiny bundle size — up to 97% smaller than Lodash equivalents.
  • Blazing fast performance — often 2–3× faster, with some functions up to 11× faster.
  • Complete Lodash compatibility — via the es-toolkit/compat layer — seamless migration.

✨ Bonus: Utilities Lodash doesn’t have

es-toolkit also ships with handy functions that Lodash never included:

import { clamp, toggle, partitionObject } from 'es-toolkit';

// Clamp numbers between a min and max
clamp(150, 0, 100); 
// → 100

// Toggle a boolean value
toggle(true);
// → false

// Partition an object into [matching, rest]
partitionObject({ a: 1, b: 2, c: 3 }, (val) => val > 1);
// → [{ b: 2, c: 3 }, { a: 1 }]

// Attempt a promise and return data or error without throwing
const [error, data] = await attemptAsync(async () => {
  const response = await fetch('https://api.example.com/data');
  return response.json();
});
// → { data: { ... } } or { error: 'Error message' }

// ... and more!

Start your scalable and production-ready SaaS today

Save endless hours of development time and focus on what's important for your customers with our SaaS starter kits for Next.js, Nuxt 3, and TanStack Start

Get started

Stay up to date

Sign up for our newsletter and we will keep you updated on everything going on with supastarter.