tools

JsonLogic to MongoDB converter

Paste a JsonLogic rule and get a MongoDB filter that matches the same documents.

  • free
  • no sign-up
  • runs in your browser
  • MIT
input · JsonLogic
output · MongoDB filter
4 rules · 5 fields · converted Runs in your browser: nothing leaves it.

How it converts

Comparisons map to $eq, $lt, $gte and friends, in over a list to $in, and and/or to $and/$or.

some, all and none over a list of objects become $elemMatch, $not $elemMatch and the double negation qnot uses for all, because JsonLogic's all is false for an empty list while Mongo's is true.

Use it in your app

follows your input and settings

The converter is qnot's codecs. Declare the fields once and the same two calls run on your server or in the browser, typed end to end.

Questions

Is my query sent anywhere?
No. The converter is qnot running in your browser: parsing, schema inference and conversion all happen on this page, and nothing you paste leaves your browser.
How are lists handled?
some over a list of records becomes $elemMatch. some over a list of plain values (tags, roles) becomes $in on that field, and an and of in checks becomes $all.
Why does it show a schema?
qnot's codecs are typed by a schema. The tool infers a permissive one from your input (numbers, booleans, dates, lists, nested arrays), so you can paste any query. In your app you declare the fields once with defineFields and get the same conversion with exact types.