# spdx-vir

> Easy SPDX parsing.

Latest version **1.0.0** (published 2026-07-29) · (MIT OR CC0-1.0) license · 0 weekly downloads

## Install

```sh
npm install spdx-vir
pnpm add spdx-vir
yarn add spdx-vir
bun add spdx-vir
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-07-29 |
| First published | 2026-06-04 |
| Weekly downloads | 0 |
| License | (MIT OR CC0-1.0) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 1 |
| Unpacked size | 442.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | electrovir |
| Maintainers | electrovir |
| Keywords | SPDX, parse |

## Links

- npm: https://www.npmjs.com/package/spdx-vir
- Repository: https://github.com/electrovir/spdx-vir
- Issues: https://github.com/electrovir/spdx-vir/issues
- npm.io page: https://npm.io/package/spdx-vir

## Dependencies (1)

- [@augment-vir/common](https://npm.io/package/@augment-vir/common.md) ^32.2.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2026-07-29
- 0.0.2 — 2026-07-13
- 0.0.1 — 2026-06-04
- 0.0.0 — 2026-06-04

## README

# spdx-vir

Parses and validates license strings strictly according to the SPDX grammar: https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions.

License ids have been extracted from https://spdx.org/licenses/licenses.json and exceptions from https://spdx.org/licenses/exceptions.json.

Based on https://www.npmjs.com/package/spdx-expression-parse but more strict to the grammar and written in modern ESM syntax.

Test it out here: https://codepen.io/electrovir/pen/yyVjVQR

## Install

```sh
npm i spdx-vir
```

## Usage

Validating expressions:

<!-- example-link: src/readme-examples/validate.example.ts -->

```TypeScript
import {isValidSpdxExpression} from 'spdx-vir';

// returns true
isValidSpdxExpression('(MIT OR CC0-1.0)');

// returns false
isValidSpdxExpression('(MIT or CC0 1.0)');
```

Parsing expressions:

<!-- example-link: src/readme-examples/parse.example.ts -->

```TypeScript
import {parseSpdxExpression, SpdxConjunction} from 'spdx-vir';

parseSpdxExpression('(MIT OR CC0-1.0)');
// outputs the following:
const output = {
    conjunction: SpdxConjunction.OR,
    left: {
        license: 'MIT',
    },
    right: {
        license: 'CC0-1.0',
    },
};

// throws a SpdxParseError
parseSpdxExpression('(MIT or CC0 1.0)');
```

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