Get Started Free
Live in your browser

MongoDB Playground

Try VisuaLeaf's MongoDB shell, query builder and visual aggregation builder on a real database that runs inside this page. No install, no sign-up, and nothing you type leaves your browser.

Working in SQL? Try the DuckDB playground

×

MongoDB shell

Starting the database in your browser…

Embed

Use these tools outside the playground

The playground is built from web components. A blog post, a course or your product docs can show a live shell, collection or pipeline with one script tag. The snippet follows the tool and size you picked above.

  1. Load the script from visualeaf.com

    One script tag from https://visualeaf.com/playground-mongodb/widget/20261121-2019/main.js. We host the editor and the database engine, and keep them up to date. Nothing to install or build.

  2. Add your license key

    The database engine runs on licensed domains only, and on localhost without a key, so you can try it first. Contact us for a license key for your domain.

  3. Place the element

    Put a <visualeaf-shell>, <visualeaf-collection> or <visualeaf-aggregation> where it should appear, and size it with CSS like any block. Use your own data with data-url, or the sample shop. Each reader gets their own in-memory database.

Your snippet ·

Inline data

Collections as keys, documents as arrays, in Extended JSON so ObjectIds, dates and decimals keep their types.

<visualeaf-shell database="shop"
  script="db.products.find()"
  data='{"products": [
    {"name": "Pen", "price": 2.5},
    {"name": "Notebook", "price": 7}
  ]}'></visualeaf-shell>

A setup script

init runs mongosh code once before the reader sees the widget: inserts, indexes, validators, views.

<visualeaf-shell database="shop"
  init='
    db.products.insertMany([
      { name: "Pen", price: NumberDecimal("2.50") }
    ])
    db.products.createIndex({ price: 1 })
  '></visualeaf-shell>

One database, many widgets

Widgets with the same shared-db share a database, like on this page. Insert in a shell, query it further down.

<visualeaf-shell shared-db="shop"
  data-url="https://visualeaf.com/playground-mongodb/widget/20261121-2019/shop.json"></visualeaf-shell>

<!-- …the text of your post… -->

<visualeaf-collection shared-db="shop"
  collection="products"></visualeaf-collection>

Reference

Attributes

Attributes are read when the element starts, so set them before adding it to the page.

AttributeWhat it does
databaseThe database the widget works in, and where data goes (default test).
dataDocuments to load first, Extended JSON: {"collection": [docs]} or {"db": {"collection": [docs]}}.
data-urlThe same, fetched from a URL.
initA shell script run once at start, before the reader sees the widget (after data).
init-urlThe same, fetched from a .js file.
license-keyYour domain's license key (or window.MINILEAF_LICENSE_KEY = "…" once for every widget of the page). Not needed on localhost. Contact us for one.
shared-dbWidgets on the page with the same value share one database. The first to start loads its data.
nameThe connection's name in the bar (default “Minileaf (in your browser)”).
themedark or light. Without it: the reader's choice from the ☀ / ☾ toggle, else dark.
resizablefalse hides the handle readers drag to make the widget taller.
min-heightThe smallest height that handle allows, in px (default 320).

Like it? Use it on your own databases.

The desktop app has the same shell, query builder and aggregation builder, plus schema, charts, explain plans and more, for MongoDB, PostgreSQL, MySQL, SQLite, SQL Server and more.