# is-identifier

> Check if a string is a valid JavaScript identifier

Latest version **1.1.0** (published 2026-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-identifier
pnpm add is-identifier
yarn add is-identifier
bun add is-identifier
```

## Health

**Score 65/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-07-05 |
| First published | 2024-05-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | identifier, keyword, word, check, test, reserved, javascript, ecmascript, variable, function, property, is, valid |

## Links

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

## Dependencies (2)

- [super-regex](https://npm.io/package/super-regex.md) ^1.1.0
- [identifier-regex](https://npm.io/package/identifier-regex.md) ^1.1.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2026-07-05
- 1.0.1 — 2024-07-12
- 1.0.0 — 2024-05-05

## README

# is-identifier

> Check if a string is a valid [JavaScript identifier](https://developer.mozilla.org/en-US/docs/Glossary/Identifier)

## Install

```sh
npm install is-identifier
```

## Usage

```js
import isIdentifier from 'is-identifier';

isIdentifier('foo');
//=> true

isIdentifier('1kg');
//=> false

isIdentifier('await'); // Reserved identifier
//=> false
```

> [!NOTE]
> Although `globalThis`, `Infinity`, `NaN`, and `undefined` are [properties of the global object](https://tc39.es/ecma262/#sec-value-properties-of-the-global-object) and not identifiers, they are treated as reserved here because they should generally not be used as identifiers.

## API

### isIdentifier(value, options?)

Returns a boolean for whether the given value is a valid JavaScript identifier.

#### options

Type: `object`

##### checkReserved

Type: `boolean`\
Default: `true`

Reject reserved words and global properties like `if`, `await`, and `undefined`.

These are valid identifier syntax but should not be used as variable names, so they are rejected by default. Disable this when you only care about the syntax, such as for property keys (`{if: 1}`) or dot notation (`foo.for`), where they are allowed.

```js
import isIdentifier from 'is-identifier';

isIdentifier('for', {checkReserved: false});
//=> true
```

## Related

- [to-valid-identifier](https://github.com/sindresorhus/to-valid-identifier) - Convert a string to a valid JavaScript identifier
- [identifier-regex](https://github.com/sindresorhus/identifier-regex) - Regular expression for matching valid JavaScript identifiers
- [reserved-identifiers](https://github.com/sindresorhus/reserved-identifiers) - Provides a list of reserved identifiers for JavaScript

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