Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

avsc

> 数据库
Open source

Avro for JavaScript :zap:

1.4K stars0 likes4 views
WebsiteGitHub

About

Avro for JavaScript :zap:

Avsc

Pure JavaScript implementation of the Avro specification.

Features

  • Blazingly fast and compact serialization! Typically faster than JSON with much smaller encodings.
  • All the Avro goodness and more: type inference, schema evolution...
  • Support for serializing arbitrary JavaScript objects.
  • Unopinionated 64-bit integer compatibility.

Installation

bash
$ npm install avsc

Documentation

  • Home
  • API
  • Quickstart
  • Advanced usage
  • Benchmarks

Examples

javascript
const avro = require('avsc');
  • Encode and decode values from a known schema:

    javascript
    const type = avro.Type.forSchema({
      type: 'record',
      name: 'Pet',
      fields: [
        {
          name: 'kind',
          type: {type: 'enum', name: 'PetKind', symbols: ['CAT', 'DOG']}
        },
        {name: 'name', type: 'string'}
      ]
    });
    
    const buf = type.toBuffer({kind: 'CAT', name: 'Albert'}); // Encoded buffer.
    const val = type.fromBuffer(buf); // = {kind: 'CAT', name: 'Albert'}
  • Infer a value's schema and encode similar values:

    javascript
    const type = avro.Type.forValue({
      city: 'Cambridge',
      zipCodes: ['02138', '02139'],
      visits: 2
    });
    
    // We can use `type` to encode any values with the same structure:
    const bufs = [
      type.toBuffer({city: 'Seattle', zipCodes: ['98101'], visits: 3}),
      type.toBuffer({city: 'NYC', zipCodes: [], visits: 0})
    ];
  • Get a readable stream of decoded values from an Avro container file (see the BlockDecoder API for an example compressed using Snappy):

    javascript
    avro.createFileDecoder('./values.avro')
      .on('metadata', function (type) { /* `type` is the writer's type. */ })
      .on('data', function (val) { /* Do something with the decoded value. */ });

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptavrobig-databinary-formatencoding

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库