Transit for JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea clean up node dev build script, lean on newer Closure Compiler featur… Feb 19, 2015
bench cache hash codes on arrays, closing in on native map performance in a… Jul 16, 2014
bin typo Mar 30, 2018
build fix release script Apr 28, 2015
resources need exports for module so that Closure doesn't complain Mar 30, 2018
src/com/cognitect take transform option and use it if provided in marshall Mar 30, 2018
test fix incorrect behavior of cmaps, they should not cache their keys Dec 21, 2015
.gitignore update .gitignore Aug 4, 2015
Gruntfile.js wip update, allow for testing via grunt and nodeunit Apr 29, 2014
LICENSE Update with 0.8.861 Mar 30, 2018
VERSION_PREFIX version needs to match spec version Jul 16, 2014
package.json update deps script, update package.json May 12, 2017
pom.xml fix source and resource directories in pom Jul 29, 2014
yuidoc.json bump yuidoc.json Aug 4, 2015


Transit is a data format and a set of libraries for conveying values between applications written in different languages. This library provides support for marshalling Transit data to/from JavaScript. transit-js will work with any ECMAScript-262 Edition 3 or newer JavaScript implementation provided that a JSON module that supplies parse and stringify methods is present. transit-js does not currently support encoding to MessagePack. Unlike the Java and Clojure implementations it relies on the non-streaming JSON parsing mechanism of the host JavaScript environment.

This implementation's major.minor version number corresponds to the version of the Transit specification it supports.

NOTE: Transit is a work in progress and may evolve based on feedback. As a result, while Transit is a great option for transferring data between applications, it should not yet be used for storing data durably over time. This recommendation will change when the specification is complete.

Releases and Dependency Information


You can include either the release (10K gzipped) or development build of transit-js on your webpage. We also provide Require.js compatible release and dev builds.


transit-js is released to npm. Add transit-js to your package.json dependencies:

  "dependencies": {
    "transit-js": "0.8.861"


You can also include transit-js in your bower.json dependencies:

  "dependencies": {
    "transit-js": "0.8.861"


Maven dependency information:



Comprehensive documentation can be found here.


transit-js supports the conveyance of semantically rich and extensible data between heterogenous software systems whose components include JavaScript servers and clients.

Beyond JSON

The Transit rationale covers many of the reasons to put aside the limitations of JSON. As with the other Transit implementations, transit-js supports conveying a larger range of scalar and non-scalar values than permitted by JSON. Of these types, the transit-js handling of the map representation is the most novel from the perspective of a JavaScript applications developer.

Transit Maps

Transit representations of maps are decoded by transit-js into a high performance data structure that largely mirrors the ECMAScript Edition 6 Map data type. Doing so allows natural indexing of data using common scalars like 64 bit integers and dates without requiring the out of band application logic often encountered in systems that marshal JSON.

The adaptive implementation of transit-js maps delivers performance comparable to plain JavaScript objects and native ES6 Map implementations.


Please see the Getting Started page. For an interactive guide check out the tour.

From the browser transit-js is available at the top level:

var t = transit;

function roundtrip(x) {
  var r = t.reader("json"),
      w = t.writer("json");

function testRoundtrip() {
  var arr1 = ["red", "green", "blue"],
      arr2 = ["apple", "pear", "grape"],
      data =;
  data.set(t.integer(1), arr1);
  data.set(t.integer(2), arr2);
  return t.equals(data, roundtrip(data));

From Node.js you must require transit-js (assuming you've included it in your project dependencies):

var t = require("transit-js");

function roundtrip(x) {
  var r = t.reader("json"),
      w = t.writer("json");

function testRoundtrip() {
  var arr1 = ["red", "green", "blue"],
      arr2 = ["apple", "pear", "grape"],
      data =;
  data.set(t.integer(1), arr1);
  data.set(t.integer(2), arr2);
  return t.equals(data, roundtrip(data));

Default Type Mapping


  • t = transit
Transit type Write accepts Read returns
null null null
string String String
boolean Boolean Boolean
integer Number, t.integer Number, t.integer
decimal Number Number
keyword t.keyword t.keyword
symbol t.symbol t.symbol
big integer t.tagged t.tagged
big decimal t.tagged t.tagged
bytes Buffer, Uint8Array, t.tagged Buffer, Uint8Array, t.tagged
time Date Date
uri t.tagged t.tagged
uuid t.uuid t.uuid
char String String
array Array Array
list t.tagged t.tagged
set t.set t.set
link t.tagged t.tagged


This library is open source, developed internally by Cognitect. We welcome discussions of potential problems and enhancement suggestions on the transit-format mailing list. Issues can be filed using GitHub issues for this project. Because transit is incorporated into products and client projects, we prefer to do development internally and are not accepting pull requests or patches.



Building and testing transit-js requires Node.js. Install the project's additional development dependencies with the following command from the repo directory:


In order to build transit-js for ClojureScript, Maven must be installed.

Running the tests


In order to run the bin/verify tests from transit-format, you must first clone transit-format into the same parent directory as your transit-js checkout. Then build the production Node.js build:




The build version is automatically incremented. To determine the current build version:


Build for Node.js


Build for Browser


Building the documentation


Build JAR for ClojureScript

Assuming you have a JDK and Maven installed, the following will install a JAR suitable for use from ClojureScript into your local Maven repository.


Copyright and License

Copyright © 2014-2017 Cognitect

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.