MotionQL

Extended JSON converter

Convert MongoDB documents between canonical Extended JSON, relaxed Extended JSON and mongosh shell syntax, keeping BSON types like ObjectId, Date, Long and Decimal128 intact.

Runs entirely in your browser. Nothing you paste is sent to any server.

Read as shell syntax · 3 string, 2 binData, 1 objectId, 1 decimal, 1 long, 1 double, 1 date, 1 regex, 1 timestamp

Output

{
  "_id": { "$oid": "65f1a2b3c4d5e6f708192a3b" },
  "name": "Ada Lovelace",
  "balance": { "$numberDecimal": "1024.50" },
  "visits": { "$numberLong": "9007199254740993" },
  "score": { "$numberDouble": "4.5" },
  "joined": { "$date": { "$numberLong": "1710322200000" } },
  "tags": [
    "admin",
    "beta"
  ],
  "avatar": { "$binary": { "base64": "iVBORw0KGgo=", "subType": "00" } },
  "sessionId": { "$binary": { "base64": "OyQRAeK7QlWMr0E2xWapYg==", "subType": "04" } },
  "email": { "$regularExpression": { "pattern": "@example\\.com$", "options": "i" } },
  "lastSync": { "$timestamp": { "t": 1710322200, "i": 1 } }
}

Do this against your real data with MotionQL

In MotionQL you can copy any document as Extended JSON or shell syntax, and import or export JSON, JSON Lines, CSV, BSON and Excel. Pro is free for a year.

Three ways to write the same document

JSON has no ObjectId, date, 64-bit integer or binary type, so MongoDB defines Extended JSON: special keys starting with $ that carry the BSON type. The same value looks different in each format:

  • Shell: ISODate("2024-03-13T09:30:00Z")
  • Relaxed: {"$date": "2024-03-13T09:30:00Z"}
  • Canonical: {"$date": {"$numberLong": "1710322200000"}}

Use canonical when the data must round-trip exactly (backups, fixtures, cross-language tests), relaxed for logs and APIs people read, and shell syntax to paste into mongosh. Query operators such as $gt or $in are left untouched, so you can convert filters and pipelines too.

FAQ

Questions, answered

Canonical mode wraps every value whose type JSON can't express exactly, including all numbers ({"$numberInt": "1"}) and dates as milliseconds ({"$date": {"$numberLong": "..."}}), so nothing is lost. Relaxed mode writes int32, doubles and safe 64-bit integers as plain JSON numbers and dates between 1970 and 9999 as ISO strings, which is easier to read but can lose type information.

More free MongoDB tools