# amf-codec

> AMF0 codec with tiny size and high performance

Latest version **1.4.1** (published 2026-07-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install amf-codec
pnpm add amf-codec
yarn add amf-codec
bun add amf-codec
```

## Health

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

Positive: no vulnerabilities; recently updated.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2026-07-13 |
| First published | 2021-01-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | David Csirmaz |
| Maintainers | csimi |
| Keywords | amf, amf0 |

## Links

- npm: https://www.npmjs.com/package/amf-codec
- Repository: https://github.com/csimi/amf-codec
- Homepage: https://github.com/csimi/amf-codec#readme
- Issues: https://github.com/csimi/amf-codec/issues
- npm.io page: https://npm.io/package/amf-codec

## Recent versions

- 1.4.1 (latest) — 2026-07-13
- 1.4.0 — 2022-04-25
- 1.3.1 — 2022-03-31
- 1.3.0 — 2021-07-11
- 1.2.0 — 2021-02-17
- 1.1.1 — 2021-02-01
- 1.1.0 — 2021-01-22
- 1.0.0 — 2021-01-14

## README

[![npm version](https://img.shields.io/npm/v/amf-codec.svg?logo=npm)](https://www.npmjs.com/package/amf-codec)
[![build status](https://github.com/csimi/amf-codec/workflows/build/badge.svg)](https://github.com/csimi/amf-codec/actions)
[![codecov](https://codecov.io/gh/csimi/amf-codec/branch/master/graph/badge.svg)](https://codecov.io/gh/csimi/amf-codec)

# About

Tiny AMF0 encoder/decoder with high performance.

# Usage

Install using npm:

```
$ npm install amf-codec
```

## Encode

```
const { toAMF } = require('amf-codec');

const data = {
	'foobar': 42,
};

console.log(toAMF(data));
```

## Decode

```
const { fromAMF } = require('amf-codec');

const data = Buffer.from([1, 1]);

console.log(fromAMF(data));
```

## Decode from arbitrary position

For example to skip the first byte of buffer:

```
const { decodeAMF, Memo } = require('amf-codec');

const data = Buffer.from([0, 1, 1]);

console.log(decodeAMF(data, new Memo(1)));
```

## Memo class

```
const { Memo } = require('amf-codec');

const data = Buffer.from([0, 1, 2, 3, 4, 5, 6]);
const memo = new Memo(1); // set initial position to ignore 1 byte

console.log(data.readUInt16BE(memo.consume(2)/* === 1 */));
// consume(amount of bytes) returns current position before increasing its value
console.log(data.slice(memo.position/* === 3*/, memo.skip(4)/* === 7*/));
// skip(amount of bytes) increases position before returning its value
```

# Supported types

- number
- boolean
- string
- ecma array
- object
- null
- undefined
- reference
- strict array
- date
- long string
- typed object

# Not supported types

- movieclip
- unsupported
- recordset
- xml document
- avmplus object

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