Fast etags for JSON.

etag, http, tag, hash, compress, fast, json
npm install ziptag@0.0.8


ziptag Build Status codecov Greenkeeper badge

Fast RFC-7232 compliant etags for JSON.



Available through npm: npm install --save ziptag.


This module exports a single function which takes any value as input and returns a valid ETag as a string.

For ES2015 import users: this module exports the named export ziptag. For commonjs users: you're free to do const ziptag = require('ziptag').

ziptag(object, [ignorePaths], [maxDepth]) => string


const ziptag = require('ziptag')

// W/"e21zZzonaGVsbG8gd29ybGQn"
ziptag({ msg: 'hello world' })

// W/"e25hbWU6J0pvaG4nYWdlOjIwYmRheTow"
ziptag({ name: 'John', age: 20, bday: new Date(0) })

// W/"e3BlcnNvbjp7bmFtZTonSm9obidhZ2U6MjBiZGF5OjA="
  person: {
    name: 'John',
    age: 20,
    bday: new Date(0)


  • ignorePaths: a map of paths to ignore, value of the key to ignore should be false. Example: { "": false }
  • maxDepth: the maximum depth to traverse in the entity. This is not protection against circular objects so setting this to Infinity will work (it'll just be really slow for large objects).


It's dirty

This module is designed to create a very dirty etag as fast as possible. Due to this, higher priority is given to performance than collision avoidance. As with any hash function, there are collisions. Though there will be many more collisions than with a stronger solution like JSON.stringify (which still has collisions but significantly less). However, it will outperform the native JSON stringify.

It's really fast

To see up-to-date benchmark results, check out the travis log.

Larger objects = larger etags

Makes sense, right?

Using in-browser

When packing with webpack, make sure you disable the Buffer builtin to save some bundle space. Instead, ziptag will make use of the browser's btoa helper.


Copyright © 2017-present Foko Inc. All rights reserved.

Licensed under the MIT license.