# @peculiar/asn1-schema

> Decorators and helper APIs for declaring ASN.1 schemas in TypeScript.

Latest version **2.9.4** (published 2026-08-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @peculiar/asn1-schema
pnpm add @peculiar/asn1-schema
yarn add @peculiar/asn1-schema
bun add @peculiar/asn1-schema
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.9.4 |
| Published | 2026-08-20 |
| First published | 2018-11-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 3 |
| Unpacked size | 108 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 45 |
| Author | PeculiarVentures, LLC |
| Maintainers | rmhrisk, microshine, yury.strozhevsky, peculiarventures, apilguk, donskov, worldthirteen |
| Keywords | asn, asn1, schema, serialize, parse, decorator, der |

## Links

- npm: https://www.npmjs.com/package/@peculiar/asn1-schema
- Repository: https://github.com/PeculiarVentures/asn1-schema
- Homepage: https://github.com/PeculiarVentures/asn1-schema/tree/master/packages/schema#readme
- Issues: https://github.com/PeculiarVentures/asn1-schema/issues
- npm.io page: https://npm.io/package/@peculiar/asn1-schema

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [asn1js](https://npm.io/package/asn1js.md) ^3.0.10
- [@peculiar/utils](https://npm.io/package/@peculiar/utils.md) ^2.0.2

## 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

- 2.9.4 (latest) — 2026-08-20
- 2.9.3 — 2026-08-18
- 2.9.2 — 2026-08-18
- 2.9.0 — 2026-08-14
- 2.8.0 — 2026-06-11
- 2.7.0 — 2026-05-01
- 2.6.0 — 2025-11-16
- 2.5.0 — 2025-09-08
- 2.4.0 — 2025-07-16
- 2.3.15 — 2024-12-23
- 2.3.13 — 2024-08-01
- 2.3.8 — 2023-10-17
- 2.3.6 — 2023-03-13
- 2.3.3 — 2022-11-08
- 2.3.0 — 2022-08-04
- … 36 more at https://npm.io/package/@peculiar/asn1-schema/versions

## README

# `@peculiar/asn1-schema`

[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/PeculiarVentures/asn1-schema/blob/master/packages/schema/LICENSE)
[![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-schema.svg)](https://badge.fury.io/js/%40peculiar%2Fasn1-schema)

[![NPM](https://nodei.co/npm/@peculiar/asn1-schema.png)](https://nodei.co/npm/@peculiar/asn1-schema/)

Decorators and helper APIs for declaring ASN.1 schemas in TypeScript.

This is the core package used by the schema modules in this repository. It lets you describe DER structures with decorators and convert them with `AsnConvert`, `AsnParser`, and `AsnSerializer`.

## Installation

```bash
npm install @peculiar/asn1-schema
```

## Overview

Abstract Syntax Notation One (ASN.1) is widely used across X.509, PKCS, CMS, OCSP, and related standards. This package keeps those mappings declarative and type-friendly by attaching schema metadata directly to classes.

## TypeScript Example

```ts
import { AsnConvert, AsnProp, AsnPropTypes, AsnType, AsnTypeTypes } from "@peculiar/asn1-schema";

@AsnType({ type: AsnTypeTypes.Sequence })
class BasicConstraints {
  @AsnProp({ type: AsnPropTypes.Boolean, defaultValue: false })
  public cA = false;
}

const basicConstraints = new BasicConstraints();
basicConstraints.cA = true;

const encoded = AsnConvert.serialize(basicConstraints);
const decoded = AsnConvert.parse(encoded, BasicConstraints);

console.log(decoded.cA);
```

## Related Links

- [Decorators overview](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841)
- [ASN.1 playground](http://lapo.it/asn1js/)

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