# electron-util

> Useful utilities for Electron apps and modules

Latest version **1.0.0** (published 2025-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install electron-util
pnpm add electron-util
yarn add electron-util
bun add electron-util
```

## Health

**Score 38/100 (D)** — status: maintenance-mode.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2025-09-09 |
| First published | 2017-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/electron-util) |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 2 |
| Unpacked size | 49.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1334 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | electron, app, dev, development, utility, utilities, util, utils, useful |

## Links

- npm: https://www.npmjs.com/package/electron-util
- Repository: https://github.com/sindresorhus/electron-util
- Homepage: https://github.com/sindresorhus/electron-util#readme
- Issues: https://github.com/sindresorhus/electron-util/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/electron-util

## Dependencies (2)

- [electron-is-dev](https://npm.io/package/electron-is-dev.md) ^3.0.1
- [new-github-issue-url](https://npm.io/package/new-github-issue-url.md) ^1.1.0

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2025-09-09
- 0.18.1 — 2024-02-26
- 0.18.0 — 2024-01-13
- 0.17.2 — 2021-08-29
- 0.17.1 — 2021-08-28
- 0.17.0 — 2021-06-30
- 0.16.0 — 2021-05-08
- 0.15.1 — 2021-04-24
- 0.15.0 — 2021-04-06
- 0.14.2 — 2020-06-27
- 0.14.1 — 2020-04-13
- 0.14.0 — 2020-02-16
- 0.13.1 — 2019-12-16
- 0.13.0 — 2019-11-14
- 0.12.3 — 2019-11-13
- … 22 more at https://npm.io/package/electron-util/versions

## README

# electron-util

> Useful utilities for Electron apps and modules

You can use this package directly in both the [main and renderer process](https://www.electronjs.org/docs/latest/tutorial/quick-start/#main-process).

This package is organized into three parts:

- **`shared`** - APIs that work in both the main and [renderer process](https://www.electronjs.org/docs/latest/tutorial/process-model#the-renderer-process)
- **`main`** - APIs that only work in the [main process](https://www.electronjs.org/docs/latest/tutorial/quick-start/#run-the-main-process) (requires Electron APIs)
- **`node`** - APIs that work in any Node.js environment, even outside Electron (pure Node.js utilities for detecting Electron environment, ASAR usage, etc.)

To use features from the "main" part in the renderer process, you will need to set up [IPC channels](https://www.electronjs.org/docs/latest/tutorial/ipc).

## Install

```sh
npm install electron-util
```

> [!NOTE]
> Requires Electron 37 or later.

## Usage

The “shared” API you can access directly:

```ts
import {is} from 'electron-util';

console.log(is.macos && is.main);
//=> true
```

For the “main” API, use the `/main` sub-export:

```ts
import {isDev} from 'electron-util/main';

console.log(isDev);
//=> false
```

For the “node” API, use the `/node` sub-export:

```ts
import {isElectron, fixPathForAsarUnpack} from 'electron-util/node';

console.log(isElectron);
//=> true when running in Electron, false in plain Node.js

const fixedPath = fixPathForAsarUnpack('/path/app.asar/binary');
//=> '/path/app.asar.unpacked/binary' when in ASAR, or unchanged otherwise
```

## API

~~[Documentation](https://tsdocs.dev/docs/electron-util)~~ (The service is broken)

Look at the [types](source) for now.

## Related

- [electron-store](https://github.com/sindresorhus/electron-store) - Save and load data like user preferences, app state, cache, etc
- [electron-debug](https://github.com/sindresorhus/electron-debug) - Adds useful debug features to your Electron app
- [electron-context-menu](https://github.com/sindresorhus/electron-context-menu) - Context menu for your Electron app
- [electron-dl](https://github.com/sindresorhus/electron-dl) - Simplified file downloads for your Electron app
- [electron-unhandled](https://github.com/sindresorhus/electron-unhandled) - Catch unhandled errors and promise rejections in your Electron app

---
_Source: https://npm.io/package/electron-util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
