MongoDB Schema Explorer Online

Explore a MongoDB document or collection sample and infer its field schema in your browser. Your data stays local.

Your MongoDB documents are parsed and analyzed locally in your browser; nothing you paste leaves your device or is uploaded to a server.

Built and maintained by Udit Agarwal

Need TypeScript types from this sample? Try JSON to TypeScript.

About MongoDB Explorer

This mongodb schema explorer takes a single MongoDB document or an array of documents as JSON and infers the underlying field schema for you. Paste a sample from Compass, mongosh, or an application log and it walks every document, builds a flat list of field paths (including nested objects and array-of-object elements), labels each with a loose BSON-ish type such as int, double, string, bool, object, array, or null, and shows how many documents in the sample contain each field. It is built for backend developers, data engineers, and QA testers who need to understand a collection's shape, spot optional or inconsistent fields, and document a schema quickly. Everything runs locally in your browser, so the documents you paste never leave your device and nothing is uploaded to a server.

Features

  • Accepts a single document or an array of documents as JSON
  • Infers a flat list of field paths sorted alphabetically
  • Labels each field with a BSON-ish type: int, double, string, bool, object, array, or null
  • Descends into nested objects and into the first element of object arrays (path[].field)
  • Counts how many documents contain each field so you can spot optional fields
  • Merges multiple types per field when documents disagree (e.g. int | null)
  • Shows a document and field count summary at the top of the schema
  • Runs live as you paste and works entirely offline in your browser

How to use the MongoDB Explorer

  1. Paste a MongoDB document or an array of documents as JSON into the input box.
  2. Read the inferred schema table on the right, with field paths, types, and coverage.
  3. Check the present/total count beside each field to find optional or sparse fields.
  4. Expand nested paths and array fields to see deep structure.
  5. Copy or download the normalized JSON to share the sample.

Example

Input

[
  { "_id": 1, "name": "Ada", "age": 36, "roles": ["admin"] },
  { "_id": 2, "name": "Linus", "active": true, "address": { "city": "Helsinki" } }
]

Output

_id        int        2/2
active     bool       1/2
address    object     1/2
address.city string   1/2
age        int        1/2
name       string     2/2
roles      array      1/2

Two documents inferred into field paths, types, and per-field coverage.

Common errors & troubleshooting

  • The input is rejected with a JSON parse error. — Make sure the sample is valid JSON: double-quoted keys and strings, no trailing commas, and no mongosh helpers like ObjectId() or ISODate().
  • You pasted ObjectId(...), ISODate(...), or NumberLong(...) straight from the shell. — Replace these extended-JSON constructors with plain JSON values (e.g. a quoted string) before pasting, since the explorer parses standard JSON.
  • You get a message asking for a document or an array of documents. — Provide an object or an array of objects. Bare arrays of scalars or a single primitive value have no fields to infer.
  • An array of objects only shows fields from the first element. — This is expected: array-of-object schemas are inferred from the first element (path[]). Reorder the sample so a representative object comes first.
  • A field shows two types like int | double or string | null. — That means documents in your sample disagree on that field's type; it is informational, not an error.

Frequently asked questions

What is the MongoDB schema explorer?
It is an in-browser tool that takes a MongoDB document or a sample array of documents as JSON and infers the schema: every field path, a BSON-ish type for each, and how many documents in the sample contain that field.
How does it infer field types?
It inspects each value and assigns a loose BSON-ish label: integers become int, non-integers become double, plus string, bool, object, array, and null. When documents disagree, the field shows every type it saw joined with a pipe.
Does it handle nested objects and arrays?
Yes. Nested objects produce dotted paths like address.city, and arrays of objects are explored through their first element using a path[].field notation.
What does the count next to each field mean?
It is the field's coverage, shown as present/total, meaning how many documents in your pasted sample include that field. A value below the total flags an optional or sparse field.
Can I paste extended JSON from mongosh or Compass?
Paste standard JSON. Replace constructors such as ObjectId(), ISODate(), and NumberLong() with plain values first, otherwise JSON parsing will fail.
Is my data safe when I use this MongoDB schema explorer?
Yes. The explorer runs entirely in your browser, so the documents you paste never leave your device and nothing is uploaded to a server.

Related tools

Guides

More Code Formatters tools

  • OpenAPI / Swagger Formatter — Format and validate OpenAPI / Swagger specs (JSON or YAML) and count paths and operations.
  • CSS Unit Converter — Convert between px, rem, em, pt and % live with a configurable root font size.
  • Glob to Regex — Convert a glob or wildcard pattern into an equivalent JavaScript regex.
  • HTML to Markdown — Paste HTML and convert it to clean Markdown live, with GFM tables, lists and code blocks.
  • TOML Formatter & Converter — Format and validate TOML, and convert TOML ↔ JSON.
  • logfmt to JSON — Convert logfmt key=value logs to JSON and back.
  • dotenv to JSON — Convert a .env file to JSON and JSON back to .env, with quoting and comments handled.
  • CSV to Markdown Table — Convert CSV or TSV data into a Markdown table, with alignment and header options.
  • INI to JSON — Convert INI config files to JSON and JSON back to INI, with sections and comments.
  • Markdown Table Generator — Build a table in an editable grid and export Markdown, HTML, AsciiDoc and LaTeX.
  • Data Size Converter — Convert between bits, bytes, KB, MB, GB and KiB, MiB, GiB, with decimal and binary units.
  • Java Properties ↔ JSON — Convert Java .properties files to JSON and JSON back to .properties, in your browser.

See all Code Formatters tools (32) · All tools