Skip to content

0. Introduction

ECSON (ECMAScript Object Notation) is a JSON-based format that preserves the JavaScript (ECMAScript) types JSON cannot express, such as dates, big integers, special numbers, sets, maps and binary data. It is part of the LingoData family of specifications for data interoperability.

JSON has 6 types. JavaScript has dozens. Every attempt to bridge this gap makes a different trade-off:

  • MongoDB Extended JSON: inline $-prefixed types, but closed to extension and tied to BSON.
  • Meteor EJSON: extensible, but diverges from MongoDB Extended JSON and is incomplete for native JavaScript types.
  • Superjson: covers native JavaScript types and is extensible, but stores type metadata in a separate envelope.

ECSON combines their strengths:

  • inline $-prefixed typed values, without a separate envelope;
  • full coverage of native JavaScript types, including special numbers ($number) and Temporal;
  • formal extension through type sets and namespaced application tags;
  • exact compatibility with MongoDB Extended JSON through the BSON type set;
  • an encoding that does not depend on which types each side knows, so data can pass through any intermediary unchanged;
  • output that is always valid JSON, with JSON5 accepted as input.

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in BCP 14 (RFC 2119, RFC 8174) when, and only when, they appear in all capitals, as shown here.

Normative rules are identified by a code (for example ESCAPE_SERIALIZE). Notes, examples and rationales are informative.

  • Typed value: a JSON object with a single key starting with a single $ (section 1).
  • Tag: the key of a typed value, such as $date.
  • Plain object: any JSON object that is not a typed value. On the host side, the object that serializes to it: in ECMAScript, an object whose prototype is Object.prototype or null (section 5.5).
  • Type set: a named group of tags and their serialized forms (sections 3 and 4).
  • Writer and reader: an implementation when serializing and when deserializing, respectively.

Source: lingodata/ecson@fe27835 · spec/sections/00-introduction.md · ecson 0.2.0 (draft)

LingoData specifications, reference implementations and this site are licensed under the Apache License 2.0. Copyright 2026 Gustavo Gondim.