Paste one or more documents and get the schema they imply: every field with its types and how often it appears, plus a $jsonSchema validator, a TypeScript interface and a Mongoose schema. Everything runs in your browser; nothing is uploaded.
Every example ran on the sample customers, tickets, orders, products collections before it was published, and the table under it is what MongoDB returned. Load any of them into the tool above.
Worked examples
aggregatecustomers01
Field presence across a collection
“Which top-level fields exist, and in how many documents?”
Before writing an enum in a validator or Mongoose schema, list the values that already exist.
Result of Distinct values for an enum on the sample data
_id
orders
cancelled
1
delivered
2
pending
1
shipped
1
aggregatecustomers11
Random sample for inference
“Three random customers to paste into the schema tool”
db.customers.aggregate([{$sample:{ size:3}}])
$sample picks random documents, a better input for schema inference than the first few by _id.
The result changes on every run, so there is no fixed preview.
Result depends on when it runs ($$NOW or $sample), so no fixed preview.
How the tool works
Four steps, all inside this browser tab.
1
Paste documents
A JSON array, one document per line, or mongosh output with ObjectId(...) and ISODate(...).
2
See every field
Nested paths, array element types, mixed types and the percentage of documents that have each field.
3
Copy a validator
Fields present in every document become required in the $jsonSchema validator.
4
Or copy types
A TypeScript interface and a Mongoose schema, with optional fields marked.
What it won't do
Honest limits, so you know what to expect.
Upload your documents. Inference runs entirely in this page.
Guess from one document. Paste several (or use $sample) to see which fields are optional.
Enforce anything. Apply the validator with collMod yourself, after testing it.
The same guard as the product
Generated queries pass the check wuup runs on every connected database: only read stages, no server-side JavaScript, at most 30 stages.
Writes ($out, $merge)
Refused
Server JS ($where, $function)
Refused
Stages
Read-only allowlist
Your database
Never contacted
Inputs
Never leave the page
The concepts behind the output
A short explanation of what the tool produces and the mistakes it is built to avoid.
Inferring a schema from documents
A MongoDB collection has no declared schema, but its documents do have one in practice. Looking at a sample tells you which fields always exist, which are optional, and where the same field holds different types, the usual source of bugs and empty query results.
The tool walks every document, records each field path (including inside arrays and embedded objects), counts the BSON types it sees and the share of documents that have it.
From inferred schema to validator
Fields present in 100% of the sample become required; mixed types become a bsonType list. Before applying it with db.runCommand({ collMod: ..., validator: ... }), use the $nor + $jsonSchema query from the examples below to find documents that would fail it, and start with validationAction "warn".
wuup does the same kind of scan automatically when you connect a database, so its answers use your real field names and types.
Keep going
Guides that go deeper, the product that runs these queries for you, and the other free tools.
No. The schema tool runs entirely in your browser with no server call, so you can use it on documents you can't share.
As many as is practical. With one document every field looks required. Twenty to a hundred documents from $sample give a realistic picture of optional fields.
Yes. mongosh values such as ObjectId("..."), ISODate("..."), new Date("...") and NumberDecimal("...") are recognised, as are Extended JSON forms like {"$oid": "..."} and {"$date": "..."}.
Each type is counted. The validator gets a bsonType list, the TypeScript interface a union and the Mongoose schema falls back to Mixed when a field has incompatible types.
Yes, with collMod. Existing documents are not checked until they are updated, so find violators first and consider validationLevel "moderate".
Yes, with no limits, because it never calls a server.